Fixed usage of VMA_STATIC_VULKAN_FUNCTIONS, VMA_DYNAMIC_VULKAN_FUNCTIONS in CmakeLists.txt

Fixes #215
This commit is contained in:
Adam Sawicki 2021-12-17 12:11:06 +01:00
parent e9c083b4d2
commit 4586be47d8
3 changed files with 18 additions and 6 deletions

View File

@ -16,8 +16,8 @@ message(STATUS "VMA_BUILD_REPLAY = ${VMA_BUILD_REPLAY}")
option(VMA_RECORDING_ENABLED "Enable VMA memory recording for debugging" OFF) option(VMA_RECORDING_ENABLED "Enable VMA memory recording for debugging" OFF)
option(VMA_USE_STL_CONTAINERS "Use C++ STL containers instead of VMA's containers" OFF) option(VMA_USE_STL_CONTAINERS "Use C++ STL containers instead of VMA's containers" OFF)
option(VMA_STATIC_VULKAN_FUNCTIONS "Link statically with Vulkan API" OFF) option(VMA_STATIC_VULKAN_FUNCTIONS "Link statically with Vulkan API" ON)
option(VMA_DYNAMIC_VULKAN_FUNCTIONS "Fetch pointers to Vulkan functions internally (no static linking)" ON) option(VMA_DYNAMIC_VULKAN_FUNCTIONS "Fetch pointers to Vulkan functions internally (no static linking)" OFF)
option(VMA_DEBUG_ALWAYS_DEDICATED_MEMORY "Every allocation will have its own memory block" OFF) option(VMA_DEBUG_ALWAYS_DEDICATED_MEMORY "Every allocation will have its own memory block" OFF)
option(VMA_DEBUG_INITIALIZE_ALLOCATIONS "Automatically fill new allocations and destroyed allocations with some bit pattern" OFF) option(VMA_DEBUG_INITIALIZE_ALLOCATIONS "Automatically fill new allocations and destroyed allocations with some bit pattern" OFF)
option(VMA_DEBUG_GLOBAL_MUTEX "Enable single mutex protecting all entry calls to the library" OFF) option(VMA_DEBUG_GLOBAL_MUTEX "Enable single mutex protecting all entry calls to the library" OFF)
@ -25,6 +25,7 @@ option(VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT "Never exceed VkPhysica
message(STATUS "VMA_RECORDING_ENABLED = ${VMA_RECORDING_ENABLED}") message(STATUS "VMA_RECORDING_ENABLED = ${VMA_RECORDING_ENABLED}")
message(STATUS "VMA_USE_STL_CONTAINERS = ${VMA_USE_STL_CONTAINERS}") message(STATUS "VMA_USE_STL_CONTAINERS = ${VMA_USE_STL_CONTAINERS}")
message(STATUS "VMA_STATIC_VULKAN_FUNCTIONS = ${VMA_STATIC_VULKAN_FUNCTIONS}")
message(STATUS "VMA_DYNAMIC_VULKAN_FUNCTIONS = ${VMA_DYNAMIC_VULKAN_FUNCTIONS}") message(STATUS "VMA_DYNAMIC_VULKAN_FUNCTIONS = ${VMA_DYNAMIC_VULKAN_FUNCTIONS}")
message(STATUS "VMA_DEBUG_ALWAYS_DEDICATED_MEMORY = ${VMA_DEBUG_ALWAYS_DEDICATED_MEMORY}") message(STATUS "VMA_DEBUG_ALWAYS_DEDICATED_MEMORY = ${VMA_DEBUG_ALWAYS_DEDICATED_MEMORY}")
message(STATUS "VMA_DEBUG_INITIALIZE_ALLOCATIONS = ${VMA_DEBUG_INITIALIZE_ALLOCATIONS}") message(STATUS "VMA_DEBUG_INITIALIZE_ALLOCATIONS = ${VMA_DEBUG_INITIALIZE_ALLOCATIONS}")

View File

@ -26,8 +26,20 @@ set_target_properties(
target_include_directories(VulkanMemoryAllocator PUBLIC "${PROJECT_SOURCE_DIR}/include") target_include_directories(VulkanMemoryAllocator PUBLIC "${PROJECT_SOURCE_DIR}/include")
if(${VMA_DYNAMIC_VULKAN_FUNCTIONS})
set(VULKAN_USE_DYNAMIC ${VMA_DYNAMIC_VULKAN_FUNCTIONS})
else()
set(VULKAN_USE_DYNAMIC 0)
endif()
if(${VMA_STATIC_VULKAN_FUNCTIONS})
set(VULKAN_USE_STATIC ${VMA_STATIC_VULKAN_FUNCTIONS})
else()
set(VULKAN_USE_STATIC 1)
endif()
# Only link to Vulkan if static linking is used # Only link to Vulkan if static linking is used
if(NOT ${VMA_DYNAMIC_VULKAN_FUNCTIONS}) if(${VULKAN_USE_STATIC})
target_link_libraries(VulkanMemoryAllocator PUBLIC Vulkan::Vulkan) target_link_libraries(VulkanMemoryAllocator PUBLIC Vulkan::Vulkan)
endif() endif()
@ -36,7 +48,8 @@ target_compile_definitions(
PUBLIC PUBLIC
VMA_USE_STL_CONTAINERS=$<BOOL:${VMA_USE_STL_CONTAINERS}> VMA_USE_STL_CONTAINERS=$<BOOL:${VMA_USE_STL_CONTAINERS}>
VMA_DYNAMIC_VULKAN_FUNCTIONS=$<BOOL:${VMA_DYNAMIC_VULKAN_FUNCTIONS}> VMA_STATIC_VULKAN_FUNCTIONS=$<BOOL:${VULKAN_USE_STATIC}>
VMA_DYNAMIC_VULKAN_FUNCTIONS=$<BOOL:${VULKAN_USE_DYNAMIC}>
VMA_DEBUG_ALWAYS_DEDICATED_MEMORY=$<BOOL:${VMA_DEBUG_ALWAYS_DEDICATED_MEMORY}> VMA_DEBUG_ALWAYS_DEDICATED_MEMORY=$<BOOL:${VMA_DEBUG_ALWAYS_DEDICATED_MEMORY}>
VMA_DEBUG_INITIALIZE_ALLOCATIONS=$<BOOL:${VMA_DEBUG_INITIALIZE_ALLOCATIONS}> VMA_DEBUG_INITIALIZE_ALLOCATIONS=$<BOOL:${VMA_DEBUG_INITIALIZE_ALLOCATIONS}>
VMA_DEBUG_GLOBAL_MUTEX=$<BOOL:${VMA_DEBUG_GLOBAL_MUTEX}> VMA_DEBUG_GLOBAL_MUTEX=$<BOOL:${VMA_DEBUG_GLOBAL_MUTEX}>

View File

@ -56,8 +56,6 @@ include all public interface declarations. Example:
//#define VMA_DEBUG_MIN_BUFFER_IMAGE_GRANULARITY 256 //#define VMA_DEBUG_MIN_BUFFER_IMAGE_GRANULARITY 256
//#define VMA_USE_STL_SHARED_MUTEX 0 //#define VMA_USE_STL_SHARED_MUTEX 0
//#define VMA_MEMORY_BUDGET 0 //#define VMA_MEMORY_BUDGET 0
#define VMA_STATIC_VULKAN_FUNCTIONS 0
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1
#define VMA_VULKAN_VERSION 1002000 // Vulkan 1.2 #define VMA_VULKAN_VERSION 1002000 // Vulkan 1.2
//#define VMA_VULKAN_VERSION 1001000 // Vulkan 1.1 //#define VMA_VULKAN_VERSION 1001000 // Vulkan 1.1