David Neto | 2065e59 | 2016-03-17 16:23:57 -0400 | [diff] [blame] | 1 | # Copyright (c) 2015-2016 The Khronos Group Inc. |
| 2 | # |
| 3 | # Permission is hereby granted, free of charge, to any person obtaining a |
| 4 | # copy of this software and/or associated documentation files (the |
| 5 | # "Materials"), to deal in the Materials without restriction, including |
| 6 | # without limitation the rights to use, copy, modify, merge, publish, |
| 7 | # distribute, sublicense, and/or sell copies of the Materials, and to |
| 8 | # permit persons to whom the Materials are furnished to do so, subject to |
| 9 | # the following conditions: |
| 10 | # |
| 11 | # The above copyright notice and this permission notice shall be included |
| 12 | # in all copies or substantial portions of the Materials. |
| 13 | # |
| 14 | # MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS |
| 15 | # KHRONOS STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS |
| 16 | # SPECIFICATIONS AND HEADER INFORMATION ARE LOCATED AT |
| 17 | # https://www.khronos.org/registry/ |
| 18 | # |
| 19 | # THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 20 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 21 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
| 22 | # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY |
| 23 | # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
| 24 | # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE |
| 25 | # MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. |
| 26 | |
| 27 | # |
| 28 | # The SPIR-V headers from the SPIR-V Registry |
| 29 | # https://www.khronos.org/registry/spir-v/ |
| 30 | # |
Matt Chiasson | f7b06c2 | 2019-05-16 07:45:30 -0400 | [diff] [blame] | 31 | cmake_minimum_required(VERSION 3.0) |
Andrei Malashkin | c8213b3 | 2021-10-11 15:45:36 +0200 | [diff] [blame] | 32 | project(SPIRV-Headers VERSION 1.5.5) |
David Neto | 2065e59 | 2016-03-17 16:23:57 -0400 | [diff] [blame] | 33 | |
| 34 | # There are two ways to use this project. |
| 35 | # |
| 36 | # Using this source tree directly from a CMake-based project: |
| 37 | # 1. Add an add_subdirectory directive to include this sub directory. |
| 38 | # 2. Use ${SPIRV-Headers_SOURCE_DIR}/include} in a target_include_directories |
| 39 | # command. |
| 40 | # |
| 41 | # Installing the headers first, then using them with an implicit include |
| 42 | # directory. To install the headers: |
| 43 | # 1. mkdir build ; cd build |
| 44 | # 2. cmake .. |
James Knight | 4ca4743 | 2017-09-27 23:05:35 -0400 | [diff] [blame] | 45 | # 3. cmake --build . --target install |
David Neto | 2065e59 | 2016-03-17 16:23:57 -0400 | [diff] [blame] | 46 | |
James Knight | 4ca4743 | 2017-09-27 23:05:35 -0400 | [diff] [blame] | 47 | # legacy |
David Neto | 2065e59 | 2016-03-17 16:23:57 -0400 | [diff] [blame] | 48 | add_custom_target(install-headers |
James Knight | 4ca4743 | 2017-09-27 23:05:35 -0400 | [diff] [blame] | 49 | COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv |
James Knight | 7de7b23 | 2018-06-01 20:54:54 -0400 | [diff] [blame] | 50 | $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/include/spirv) |
David Neto | 2065e59 | 2016-03-17 16:23:57 -0400 | [diff] [blame] | 51 | |
dan sinclair | 7cb4300 | 2018-11-16 13:03:23 -0500 | [diff] [blame] | 52 | option(SPIRV_HEADERS_SKIP_EXAMPLES "Skip building examples" |
| 53 | ${SPIRV_HEADERS_SKIP_EXAMPLES}) |
lgotszal | 3f9bad6 | 2019-09-24 16:44:13 +0200 | [diff] [blame] | 54 | |
| 55 | option(SPIRV_HEADERS_SKIP_INSTALL "Skip install" |
| 56 | ${SPIRV_HEADERS_SKIP_INSTALL}) |
| 57 | |
dan sinclair | 7cb4300 | 2018-11-16 13:03:23 -0500 | [diff] [blame] | 58 | if(NOT ${SPIRV_HEADERS_SKIP_EXAMPLES}) |
| 59 | set(SPIRV_HEADERS_ENABLE_EXAMPLES ON) |
| 60 | endif() |
lgotszal | 3f9bad6 | 2019-09-24 16:44:13 +0200 | [diff] [blame] | 61 | |
| 62 | if(NOT ${SPIRV_HEADERS_SKIP_INSTALL}) |
| 63 | set(SPIRV_HEADERS_ENABLE_INSTALL ON) |
| 64 | endif() |
| 65 | |
dan sinclair | 7cb4300 | 2018-11-16 13:03:23 -0500 | [diff] [blame] | 66 | if (SPIRV_HEADERS_ENABLE_EXAMPLES) |
| 67 | message(STATUS "Building SPIRV-Header examples") |
| 68 | add_subdirectory(example) |
| 69 | endif() |
Mathieu-Andre Chiasson | c5a291f | 2019-05-11 15:49:18 -0400 | [diff] [blame] | 70 | |
| 71 | include(GNUInstallDirs) |
| 72 | add_library(${PROJECT_NAME} INTERFACE) |
| 73 | target_include_directories(${PROJECT_NAME} INTERFACE |
| 74 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
Mathieu-Andre Chiasson | c5a291f | 2019-05-11 15:49:18 -0400 | [diff] [blame] | 75 | ) |
| 76 | |
| 77 | # Installation |
| 78 | |
lgotszal | 3f9bad6 | 2019-09-24 16:44:13 +0200 | [diff] [blame] | 79 | if (SPIRV_HEADERS_ENABLE_INSTALL) |
| 80 | message(STATUS "Installing SPIRV-Header") |
Mathieu-Andre Chiasson | c5a291f | 2019-05-11 15:49:18 -0400 | [diff] [blame] | 81 | |
orbea | eae955f | 2020-11-05 22:08:24 -0800 | [diff] [blame] | 82 | set(config_install_dir "${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}") |
Mathieu-Andre Chiasson | c5a291f | 2019-05-11 15:49:18 -0400 | [diff] [blame] | 83 | |
lgotszal | 3f9bad6 | 2019-09-24 16:44:13 +0200 | [diff] [blame] | 84 | set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") |
Mathieu-Andre Chiasson | c5a291f | 2019-05-11 15:49:18 -0400 | [diff] [blame] | 85 | |
lgotszal | 3f9bad6 | 2019-09-24 16:44:13 +0200 | [diff] [blame] | 86 | set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake") |
| 87 | set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake") |
| 88 | set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets") |
| 89 | set(namespace "${PROJECT_NAME}::") |
Mathieu-Andre Chiasson | c5a291f | 2019-05-11 15:49:18 -0400 | [diff] [blame] | 90 | |
lgotszal | 3f9bad6 | 2019-09-24 16:44:13 +0200 | [diff] [blame] | 91 | include(CMakePackageConfigHelpers) |
| 92 | write_basic_package_version_file( |
| 93 | "${version_config}" |
| 94 | COMPATIBILITY SameMajorVersion |
| 95 | ) |
Mathieu-Andre Chiasson | c5a291f | 2019-05-11 15:49:18 -0400 | [diff] [blame] | 96 | |
lgotszal | 3f9bad6 | 2019-09-24 16:44:13 +0200 | [diff] [blame] | 97 | configure_package_config_file( |
| 98 | "cmake/Config.cmake.in" |
| 99 | "${project_config}" |
| 100 | INSTALL_DESTINATION "${config_install_dir}" |
| 101 | ) |
Mathieu-Andre Chiasson | c5a291f | 2019-05-11 15:49:18 -0400 | [diff] [blame] | 102 | |
lgotszal | 3f9bad6 | 2019-09-24 16:44:13 +0200 | [diff] [blame] | 103 | install( |
| 104 | TARGETS ${PROJECT_NAME} |
| 105 | EXPORT "${TARGETS_EXPORT_NAME}" |
| 106 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 107 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 108 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
| 109 | INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} |
| 110 | ) |
Mathieu-Andre Chiasson | c5a291f | 2019-05-11 15:49:18 -0400 | [diff] [blame] | 111 | |
lgotszal | 3f9bad6 | 2019-09-24 16:44:13 +0200 | [diff] [blame] | 112 | install( |
| 113 | DIRECTORY include/spirv |
| 114 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} |
| 115 | ) |
Mathieu-Andre Chiasson | c5a291f | 2019-05-11 15:49:18 -0400 | [diff] [blame] | 116 | |
lgotszal | 3f9bad6 | 2019-09-24 16:44:13 +0200 | [diff] [blame] | 117 | install( |
| 118 | FILES "${project_config}" "${version_config}" |
| 119 | DESTINATION "${config_install_dir}" |
| 120 | ) |
Mathieu-Andre Chiasson | c5a291f | 2019-05-11 15:49:18 -0400 | [diff] [blame] | 121 | |
lgotszal | 3f9bad6 | 2019-09-24 16:44:13 +0200 | [diff] [blame] | 122 | install( |
| 123 | EXPORT "${TARGETS_EXPORT_NAME}" |
| 124 | NAMESPACE "${namespace}" |
| 125 | DESTINATION "${config_install_dir}" |
| 126 | ) |
Tomasz Kłoczko | d234957 | 2021-05-18 13:55:35 +0100 | [diff] [blame] | 127 | |
BedrockDotPng | 7ec2a12 | 2021-09-09 18:54:44 +0400 | [diff] [blame] | 128 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/SPIRV-Headers.pc.in ${CMAKE_BINARY_DIR}/SPIRV-Headers.pc @ONLY) |
Tomasz Kłoczko | d234957 | 2021-05-18 13:55:35 +0100 | [diff] [blame] | 129 | install( |
Tomasz Kłoczko | 60a5738 | 2021-05-20 09:45:33 +0100 | [diff] [blame] | 130 | FILES "${CMAKE_BINARY_DIR}/SPIRV-Headers.pc" |
Tomasz Kłoczko | d234957 | 2021-05-18 13:55:35 +0100 | [diff] [blame] | 131 | DESTINATION ${CMAKE_INSTALL_DATADIR}/pkgconfig |
| 132 | ) |
lgotszal | 3f9bad6 | 2019-09-24 16:44:13 +0200 | [diff] [blame] | 133 | endif() |