From 01fe4105481b0f7b2daace5bde8205b795eaae2d Mon Sep 17 00:00:00 2001 From: Adam Sawicki Date: Tue, 11 Jul 2023 18:00:37 +0200 Subject: [PATCH] Fixes in Cmake scripts after merging #350 --- CMakeLists.txt | 2 +- README.md | 4 +--- include/vk_mem_alloc.h | 4 +--- src/CMakeLists.txt | 51 +++++++++++++++++++----------------------- 4 files changed, 26 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cfc31a3..8ac8f69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.15...3.26) -project(VMA LANGUAGES CXX) +project(VulkanMemoryAllocator LANGUAGES CXX) add_library(VulkanMemoryAllocator INTERFACE) add_library(GPUOpen::VulkanMemoryAllocator ALIAS VulkanMemoryAllocator) diff --git a/README.md b/README.md index d9a4296..af45fe4 100644 --- a/README.md +++ b/README.md @@ -120,9 +120,7 @@ cmake --install build --prefix build/install ## How to use After calling either `find_package` or `add_subdirectory` simply link the library. -This automatically handles configuring the include directory. - -EX: +This automatically handles configuring the include directory. Example: ```cmake find_package(VulkanMemoryAllocator CONFIG REQUIRED) diff --git a/include/vk_mem_alloc.h b/include/vk_mem_alloc.h index fbe4f13..465e013 100644 --- a/include/vk_mem_alloc.h +++ b/include/vk_mem_alloc.h @@ -126,9 +126,7 @@ See documentation chapter: \ref statistics. extern "C" { #endif -#ifndef VULKAN_H_ - #include -#endif +#include #if !defined(VMA_VULKAN_VERSION) #if defined(VK_VERSION_1_3) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7f8ea55..b72bbcd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,35 +21,8 @@ set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) -add_library(VmaUsage STATIC) -target_sources(VmaUsage PRIVATE - VmaUsage.cpp - VmaUsage.h -) - -target_link_libraries(VmaUsage PUBLIC GPUOpen::VulkanMemoryAllocator) - -# Provides MSVC users nicer debugging support -target_sources(VmaUsage PRIVATE vk_mem_alloc.natvis) - find_package(Vulkan REQUIRED) -# Only link to Vulkan library if static linking is used, but always add Vulkan headers directory -if(VMA_STATIC_VULKAN_FUNCTIONS) - target_link_libraries(VmaUsage PUBLIC Vulkan::Vulkan) -else() - target_link_libraries(VmaUsage PUBLIC Vulkan::Headers) -endif() - -target_compile_definitions(VmaUsage PUBLIC - VMA_STATIC_VULKAN_FUNCTIONS=$ - VMA_DYNAMIC_VULKAN_FUNCTIONS=$ - VMA_DEBUG_ALWAYS_DEDICATED_MEMORY=$ - VMA_DEBUG_INITIALIZE_ALLOCATIONS=$ - VMA_DEBUG_GLOBAL_MUTEX=$ - VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT=$ -) - add_executable(VmaSample) target_sources(VmaSample PRIVATE Common.cpp @@ -58,10 +31,30 @@ target_sources(VmaSample PRIVATE SparseBindingTest.h Tests.cpp Tests.h + VmaUsage.cpp + VmaUsage.h VulkanSample.cpp + ../include/vk_mem_alloc.h ) -target_link_libraries(VmaSample PRIVATE VmaUsage) +# Only link to Vulkan library if static linking is used, but always add Vulkan headers directory +if(VMA_STATIC_VULKAN_FUNCTIONS) + target_link_libraries(VmaSample PUBLIC Vulkan::Vulkan) +else() + target_link_libraries(VmaSample PUBLIC Vulkan::Headers) +endif() + +target_compile_definitions(VmaSample PUBLIC + VMA_STATIC_VULKAN_FUNCTIONS=$ + VMA_DYNAMIC_VULKAN_FUNCTIONS=$ + VMA_DEBUG_ALWAYS_DEDICATED_MEMORY=$ + VMA_DEBUG_INITIALIZE_ALLOCATIONS=$ + VMA_DEBUG_GLOBAL_MUTEX=$ + VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT=$ +) + +# Provides MSVC users nicer debugging support +target_sources(VmaSample PRIVATE vk_mem_alloc.natvis) add_subdirectory(Shaders) add_dependencies(VmaSample VmaSampleShaders) @@ -74,3 +67,5 @@ add_compile_options(/permissive- /sdl /W3) # Set VmaSample as startup project set_property(DIRECTORY "${PROJECT_SOURCE_DIR}" PROPERTY VS_STARTUP_PROJECT "VmaSample") + +set_target_properties(VmaSample PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/bin")