Merge pull request #65 from bmarques1995/master

Added cmake find_package option
This commit is contained in:
Adam Sawicki 2024-06-17 13:47:15 +02:00 committed by GitHub
commit 2b7c0d4e31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 2 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.9)
project(D3D12MemoryAllocator)
project(D3D12MemoryAllocator VERSION 3.0.0)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

View File

@ -27,7 +27,7 @@ set_target_properties(
)
target_include_directories(D3D12MemoryAllocator PUBLIC
"${PROJECT_SOURCE_DIR}/include"
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:./include>
)
target_link_libraries(D3D12MemoryAllocator PUBLIC
@ -46,7 +46,32 @@ if(BUILD_SHARED_LIBS)
)
endif()
set(D3D12MA_GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
set(D3D12MA_VERSION_CONFIG "${D3D12MA_GENERATED_DIR}/${PROJECT_NAME}ConfigVersion.cmake")
set(D3D12MA_PROJECT_CONFIG "${D3D12MA_GENERATED_DIR}/${PROJECT_NAME}Config.cmake")
set(D3D12MA_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
set(D3D12MA_CONFIG_INSTALL_DIR "share/cmake/${PROJECT_NAME}")
set(D3D12MA_NAMESPACE "GPUOpen::")
set(D3D12MA_VERSION ${PROJECT_VERSION})
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${D3D12MA_VERSION_CONFIG}" VERSION ${D3D12MA_VERSION} COMPATIBILITY SameMajorVersion
)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.cmake.in" "${D3D12MA_PROJECT_CONFIG}" @ONLY)
# Install cmake config files
install(
FILES "${D3D12MA_PROJECT_CONFIG}" "${D3D12MA_VERSION_CONFIG}"
DESTINATION "${D3D12MA_CONFIG_INSTALL_DIR}")
install(
EXPORT "${D3D12MA_TARGETS_EXPORT_NAME}"
NAMESPACE "${D3D12MA_NAMESPACE}"
DESTINATION "${D3D12MA_CONFIG_INSTALL_DIR}")
install(TARGETS D3D12MemoryAllocator
EXPORT ${D3D12MA_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION "bin"
ARCHIVE DESTINATION "lib"
LIBRARY DESTINATION "lib")

View File

@ -0,0 +1,3 @@
include(CMakeFindDependencyMacro)
include("${CMAKE_CURRENT_LIST_DIR}/@D3D12MA_TARGETS_EXPORT_NAME@.cmake")