2018-06-26 20:24:09 +00:00
|
|
|
# ~~~
|
2024-05-09 08:32:02 +00:00
|
|
|
# Copyright 2018-2023 The Khronos Group Inc.
|
|
|
|
# Copyright 2018-2023 Valve Corporation
|
|
|
|
# Copyright 2018-2023 LunarG, Inc.
|
2018-06-26 20:24:09 +00:00
|
|
|
#
|
2024-05-09 08:32:02 +00:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
2018-06-26 20:24:09 +00:00
|
|
|
# ~~~
|
2023-12-29 09:49:47 +00:00
|
|
|
cmake_minimum_required(VERSION 3.15...3.25)
|
2018-06-26 20:24:09 +00:00
|
|
|
|
2024-05-09 08:32:02 +00:00
|
|
|
# NOTE: Parsing the version like this is suboptimal but neccessary due to our release process:
|
|
|
|
# https://github.com/KhronosGroup/Vulkan-Headers/pull/346
|
|
|
|
#
|
|
|
|
# As shown a more robust approach would be just to add basic test code to check the project version.
|
2023-12-29 09:49:47 +00:00
|
|
|
function(vlk_get_header_version)
|
|
|
|
set(vulkan_core_header_file "${CMAKE_CURRENT_SOURCE_DIR}/include/vulkan/vulkan_core.h")
|
|
|
|
if (NOT EXISTS ${vulkan_core_header_file})
|
|
|
|
message(FATAL_ERROR "Couldn't find vulkan_core.h!")
|
|
|
|
endif()
|
2018-07-04 21:23:41 +00:00
|
|
|
|
2023-12-29 09:49:47 +00:00
|
|
|
file(READ ${vulkan_core_header_file} ver)
|
2018-05-30 22:43:14 +00:00
|
|
|
|
2023-12-29 09:49:47 +00:00
|
|
|
if (ver MATCHES "#define[ ]+VK_HEADER_VERSION_COMPLETE[ ]+VK_MAKE_API_VERSION\\([ ]*[0-9]+,[ ]*([0-9]+),[ ]*([0-9]+),[ ]*VK_HEADER_VERSION[ ]*\\)")
|
|
|
|
set(MAJOR_VERSION "${CMAKE_MATCH_1}")
|
|
|
|
set(MINOR_VERSION "${CMAKE_MATCH_2}")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Couldn't get major/minor version")
|
|
|
|
endif()
|
2018-05-30 22:43:14 +00:00
|
|
|
|
2023-12-29 09:49:47 +00:00
|
|
|
if (ver MATCHES "#define[ ]+VK_HEADER_VERSION[ ]+([0-9]+)")
|
|
|
|
set(PATCH_VERSION "${CMAKE_MATCH_1}")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Couldn't get the patch version")
|
|
|
|
endif()
|
2018-07-04 21:23:41 +00:00
|
|
|
|
2023-12-29 09:49:47 +00:00
|
|
|
set(VK_VERSION_STRING "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
vlk_get_header_version()
|
2018-07-04 21:23:41 +00:00
|
|
|
|
2023-12-29 09:49:47 +00:00
|
|
|
project(VULKAN_HEADERS LANGUAGES C VERSION ${VK_VERSION_STRING})
|
2018-07-04 21:23:41 +00:00
|
|
|
|
2019-02-08 03:32:29 +00:00
|
|
|
add_library(Vulkan-Headers INTERFACE)
|
|
|
|
add_library(Vulkan::Headers ALIAS Vulkan-Headers)
|
2023-12-29 09:49:47 +00:00
|
|
|
target_include_directories(Vulkan-Headers INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
|
|
|
|
|
|
|
|
if (CMAKE_VERSION VERSION_LESS "3.21")
|
|
|
|
# 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)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (PROJECT_IS_TOP_LEVEL)
|
|
|
|
option(BUILD_TESTS "Build the tests")
|
|
|
|
if (BUILD_TESTS)
|
2024-05-09 08:32:02 +00:00
|
|
|
enable_testing()
|
2023-12-29 09:49:47 +00:00
|
|
|
add_subdirectory(tests)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
|
|
|
|
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/vk_video" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
|
|
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/vulkan" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
|
|
# Preserve source permissions https://github.com/KhronosGroup/Vulkan-Headers/issues/336
|
2024-05-09 08:32:02 +00:00
|
|
|
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/registry" DESTINATION "${CMAKE_INSTALL_DATADIR}/vulkan" USE_SOURCE_PERMISSIONS)
|
2023-12-29 09:49:47 +00:00
|
|
|
|
|
|
|
set_target_properties(Vulkan-Headers PROPERTIES EXPORT_NAME "Headers")
|
|
|
|
|
2024-05-09 08:32:02 +00:00
|
|
|
install(TARGETS Vulkan-Headers EXPORT VulkanHeadersConfig INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|
|
|
install(EXPORT VulkanHeadersConfig NAMESPACE "Vulkan::" DESTINATION "share/cmake/VulkanHeaders")
|
2019-02-08 03:32:29 +00:00
|
|
|
|
2024-05-09 08:32:02 +00:00
|
|
|
set(version_config "${CMAKE_CURRENT_BINARY_DIR}/generated/VulkanHeadersConfigVersion.cmake")
|
|
|
|
write_basic_package_version_file("${version_config}" COMPATIBILITY SameMajorVersion ARCH_INDEPENDENT)
|
|
|
|
install(FILES "${version_config}" DESTINATION "share/cmake/VulkanHeaders")
|
2018-06-26 20:24:09 +00:00
|
|
|
endif()
|