Merge pull request #274 from pnarvor/cmake-targets

[cmake] Updated installation process to use modern CMake targets
This commit is contained in:
Adam Sawicki 2022-06-15 16:42:48 +02:00 committed by GitHub
commit 46bae938a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 3 deletions

View File

@ -24,7 +24,9 @@ set_target_properties(
CXX_STANDARD_REQUIRED ON
)
target_include_directories(VulkanMemoryAllocator PUBLIC "${PROJECT_SOURCE_DIR}/include")
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})
@ -44,8 +46,7 @@ target_compile_definitions(
VMA_RECORDING_ENABLED=$<BOOL:${VMA_RECORDING_ENABLED}>
)
install(TARGETS VulkanMemoryAllocator DESTINATION "lib")
install(FILES "${PROJECT_SOURCE_DIR}/include/vk_mem_alloc.h" DESTINATION "include")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/install_target.cmake)
if(VMA_BUILD_SAMPLE)
if(WIN32)

10
src/cmake/Config.cmake.in Normal file
View File

@ -0,0 +1,10 @@
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_package(Vulkan REQUIRED)
include("${CMAKE_CURRENT_LIST_DIR}/VulkanMemoryAllocatorTargets.cmake")
check_required_components("@PROJECT_NAME@")

View File

@ -0,0 +1,32 @@
include(GNUInstallDirs)
target_include_directories(VulkanMemoryAllocator PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDE_DIRS}>
)
install(TARGETS VulkanMemoryAllocator
EXPORT VulkanMemoryAllocatorTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
# install(FILES "${PROJECT_SOURCE_DIR}/include/vk_mem_alloc.h" DESTINATION "include")
install(FILES "${PROJECT_SOURCE_DIR}/include/vk_mem_alloc.h"
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(EXPORT VulkanMemoryAllocatorTargets
FILE VulkanMemoryAllocatorTargets.cmake
NAMESPACE VulkanMemoryAllocator::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/VulkanMemoryAllocator
)
include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/VulkanMemoryAllocatorConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/VulkanMemoryAllocator
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/VulkanMemoryAllocatorConfig.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/VulkanMemoryAllocator
)