blob: 5fd0196a695baadb2f48d0894e60bc6d86e1f731 [file] [log] [blame]
David Neto2065e592016-03-17 16:23:57 -04001# 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 Chiassonf7b06c22019-05-16 07:45:30 -040031cmake_minimum_required(VERSION 3.0)
Matt Chiassoned8674d2019-05-18 19:44:18 -040032project(SPIRV-Headers VERSION 1.4.1)
David Neto2065e592016-03-17 16:23:57 -040033
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 Knight4ca47432017-09-27 23:05:35 -040045# 3. cmake --build . --target install
David Neto2065e592016-03-17 16:23:57 -040046
James Knight4ca47432017-09-27 23:05:35 -040047# legacy
David Neto2065e592016-03-17 16:23:57 -040048add_custom_target(install-headers
James Knight4ca47432017-09-27 23:05:35 -040049 COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv
James Knight7de7b232018-06-01 20:54:54 -040050 $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/include/spirv)
David Neto2065e592016-03-17 16:23:57 -040051
dan sinclair7cb43002018-11-16 13:03:23 -050052option(SPIRV_HEADERS_SKIP_EXAMPLES "Skip building examples"
53 ${SPIRV_HEADERS_SKIP_EXAMPLES})
54if(NOT ${SPIRV_HEADERS_SKIP_EXAMPLES})
55 set(SPIRV_HEADERS_ENABLE_EXAMPLES ON)
56endif()
57if (SPIRV_HEADERS_ENABLE_EXAMPLES)
58 message(STATUS "Building SPIRV-Header examples")
59 add_subdirectory(example)
60endif()
Mathieu-Andre Chiassonc5a291f2019-05-11 15:49:18 -040061
62include(GNUInstallDirs)
63add_library(${PROJECT_NAME} INTERFACE)
64target_include_directories(${PROJECT_NAME} INTERFACE
65 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
Mathieu-Andre Chiassonc5a291f2019-05-11 15:49:18 -040066)
67
68# Installation
69
Matt Chiassoned8674d2019-05-18 19:44:18 -040070set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
Mathieu-Andre Chiassonc5a291f2019-05-11 15:49:18 -040071
72set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
73
74set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
75set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
76set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
77set(namespace "${PROJECT_NAME}::")
78
79include(CMakePackageConfigHelpers)
80write_basic_package_version_file(
81 "${version_config}"
Mathieu-Andre Chiassonc5a291f2019-05-11 15:49:18 -040082 COMPATIBILITY SameMajorVersion
83)
84
85configure_package_config_file(
86 "cmake/Config.cmake.in"
87 "${project_config}"
88 INSTALL_DESTINATION "${config_install_dir}"
89)
90
91install(
92 TARGETS ${PROJECT_NAME}
93 EXPORT "${TARGETS_EXPORT_NAME}"
94 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
95 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
96 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
97 INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
98)
99
100install(
101 DIRECTORY include/spirv
102 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
103)
104
105install(
106 FILES "${project_config}" "${version_config}"
107 DESTINATION "${config_install_dir}"
108)
109
110install(
111 EXPORT "${TARGETS_EXPORT_NAME}"
112 NAMESPACE "${namespace}"
113 DESTINATION "${config_install_dir}"
114)
115