Export versioned targets for CMake

Generate VulkanHeadersConfig.cmake and version file and install them.
To get the version information the header file vulkan_core.h is parsed.

In client code one can use `find_package(VulkanHeaders)` and get the
targets `Vulkan::Headers` and `Vulkan::Registry`.

The following additional files are generated and installed by CMake:
- VulkanHeadersConfig.cmake:        searched for by find_package(VulkanHeaders)
- VulkanHeadersConfigVersion.cmake: provides version numbers
- VulkanHeadersTargets.cmake:       CMake target definitions used by config file
This commit is contained in:
Rahul Sheth 2019-11-14 16:45:58 -05:00 committed by Mike Weiblen (LunarG)
parent e01f13e1f7
commit 382bf3de06
2 changed files with 109 additions and 11 deletions

25
cmake/Config.cmake.in Normal file
View file

@ -0,0 +1,25 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake")
check_required_components("@PROJECT_NAME@")
# ALIAS for imported target requires CMake >= 3.11:
# - https://cmake.org/cmake/help/latest/release/3.11.html#other
if(NOT CMAKE_VERSION VERSION_LESS 3.11)
if(NOT TARGET Vulkan::Headers)
set_target_properties(
Vulkan::Vulkan-Headers
PROPERTIES
IMPORTED_GLOBAL True
)
add_library(Vulkan::Headers ALIAS Vulkan::Vulkan-Headers)
endif()
if(NOT TARGET Vulkan::Registry)
set_target_properties(
Vulkan::Vulkan-Registry
PROPERTIES
IMPORTED_GLOBAL True
)
add_library(Vulkan::Registry ALIAS Vulkan::Vulkan-Registry)
endif()
endif()