Merge pull request #345 from abouvier/cmake-fix

cmake: always add vulkan headers dir
This commit is contained in:
Adam Sawicki 2023-07-04 13:46:16 +02:00 committed by GitHub
commit db15ce374e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 10 deletions

View File

@ -2,14 +2,6 @@ cmake_minimum_required(VERSION 3.9)
project(VulkanMemoryAllocator LANGUAGES CXX)
# https://cmake.org/cmake/help/latest/variable/PROJECT_IS_TOP_LEVEL.html
string(COMPARE EQUAL ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} PROJECT_IS_TOP_LEVEL)
if(PROJECT_IS_TOP_LEVEL)
find_package(Vulkan REQUIRED)
include_directories(${Vulkan_INCLUDE_DIR})
endif()
# VulkanMemoryAllocator contains an sample application which is not built by default
option(VMA_BUILD_SAMPLE "Build VulkanMemoryAllocator sample application" OFF)
option(VMA_BUILD_SAMPLE_SHADERS "Build VulkanMemoryAllocator sample application's shaders" OFF)
@ -31,6 +23,12 @@ message(STATUS "VMA_DEBUG_INITIALIZE_ALLOCATIONS = ${VMA_DEBUG_INITIALIZE_ALLOCA
message(STATUS "VMA_DEBUG_GLOBAL_MUTEX = ${VMA_DEBUG_GLOBAL_MUTEX}")
message(STATUS "VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT = ${VMA_DEBUG_DONT_EXCEED_MAX_MEMORY_ALLOCATION_COUNT}")
if(VMA_STATIC_VULKAN_FUNCTIONS OR VMA_BUILD_SAMPLE)
find_package(Vulkan REQUIRED)
else()
find_package(VulkanHeaders REQUIRED)
endif()
if(VMA_BUILD_SAMPLE)
set(VMA_BUILD_SAMPLE_SHADERS ON)
endif()

View File

@ -25,9 +25,11 @@ target_include_directories(VulkanMemoryAllocator PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
)
# Only link to Vulkan if static linking is used
if(${VMA_STATIC_VULKAN_FUNCTIONS})
# Only link to Vulkan library if static linking is used, but always add Vulkan headers directory
if(VMA_STATIC_VULKAN_FUNCTIONS)
target_link_libraries(VulkanMemoryAllocator PUBLIC Vulkan::Vulkan)
else()
target_link_libraries(VulkanMemoryAllocator PUBLIC Vulkan::Headers)
endif()
target_compile_definitions(

View File

@ -27,6 +27,7 @@ install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/VulkanMemoryAllocatorConfig.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/VulkanMemoryAllocator
)
add_library(VulkanMemoryAllocator::VulkanMemoryAllocator ALIAS VulkanMemoryAllocator)