blob: bcb91ba106297987cc7d658e24094b36fcf9a9a8 [file] [log] [blame]
Ryan Harrisone87ac762022-04-06 15:37:27 -04001# Copyright 2022 The Dawn & Tint Authors
Corentin Wallez7fe6efb2020-02-05 17:16:05 +00002#
Austin Engcc2516a2023-10-17 20:57:54 +00003# Redistribution and use in source and binary forms, with or without
4# modification, are permitted provided that the following conditions are met:
Corentin Wallez7fe6efb2020-02-05 17:16:05 +00005#
Austin Engcc2516a2023-10-17 20:57:54 +00006# 1. Redistributions of source code must retain the above copyright notice, this
7# list of conditions and the following disclaimer.
Corentin Wallez7fe6efb2020-02-05 17:16:05 +00008#
Austin Engcc2516a2023-10-17 20:57:54 +00009# 2. Redistributions in binary form must reproduce the above copyright notice,
10# this list of conditions and the following disclaimer in the documentation
11# and/or other materials provided with the distribution.
12#
13# 3. Neither the name of the copyright holder nor the names of its
14# contributors may be used to endorse or promote products derived from
15# this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Corentin Wallez7fe6efb2020-02-05 17:16:05 +000027
Erin Meluccid1e92bb2024-03-27 15:43:05 +000028# As per https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md
29cmake_minimum_required(VERSION 3.13)
Corentin Wallez7fe6efb2020-02-05 17:16:05 +000030
Erin Meluccid1e92bb2024-03-27 15:43:05 +000031# - Since we are past CMake 3.12 we can add CONFIGURE_DEPENDS to DawnGenerator to rerun CMake
Corentin Walleza3014cc2024-03-27 13:53:14 +000032# in case any of the generator files changes. We should also remove the CACHE "" FORCE stuff to
Erin Meluccid1e92bb2024-03-27 15:43:05 +000033# override options in third_party dependencies.
Corentin Walleza3014cc2024-03-27 13:53:14 +000034# - When upgrading to CMake 3.20 we can take advantage of the GENERATED property being global in
Jaswant Panchumarti5a26bdd2024-07-04 14:13:55 +000035# DawnGenerator. We should also use the path utilities in dawn_install_target.
Corentin Walleza3014cc2024-03-27 13:53:14 +000036
Corentin Wallez7fe6efb2020-02-05 17:16:05 +000037project(
38 Dawn
39 DESCRIPTION "Dawn, a WebGPU implementation"
Corentin Wallez7fe6efb2020-02-05 17:16:05 +000040 LANGUAGES C CXX
Erin Meluccid1e92bb2024-03-27 15:43:05 +000041 HOMEPAGE_URL "https://dawn.googlesource.com/dawn"
Jaswant Panchumarti5a26bdd2024-07-04 14:13:55 +000042 VERSION 0.0.0
Corentin Wallez7fe6efb2020-02-05 17:16:05 +000043)
Dan Sinclair6e581892020-03-02 15:47:43 -050044enable_testing()
Corentin Wallez7fe6efb2020-02-05 17:16:05 +000045
Jaswant Panchumarti72b712f2024-06-21 13:16:18 +000046list(INSERT CMAKE_MODULE_PATH 0 "${Dawn_SOURCE_DIR}/src/cmake")
47
Corentin Wallez7fe6efb2020-02-05 17:16:05 +000048set_property(GLOBAL PROPERTY USE_FOLDERS ON)
49
Dan Sinclair6e581892020-03-02 15:47:43 -050050set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
51set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Dan Sinclair6e581892020-03-02 15:47:43 -050052set(CMAKE_DEBUG_POSTFIX "")
dan sinclair2df80912023-11-20 13:22:14 +000053set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
Dan Sinclair6e581892020-03-02 15:47:43 -050054
Jaswant Panchumarti72b712f2024-06-21 13:16:18 +000055include(DawnSetIfNotDefined)
56
Jaswant Panchumartie9cc8e42024-07-02 16:26:36 +000057set(DAWN_BUILD_GEN_DIR "${Dawn_BINARY_DIR}/gen" CACHE PATH "Directory that contains generated source files")
58set(DAWN_GENERATOR_DIR "${Dawn_SOURCE_DIR}/generator" CACHE PATH "Directory that contains scripts to generate sources and headers")
59set(DAWN_SRC_DIR "${Dawn_SOURCE_DIR}/src" CACHE PATH "Directory that contains source files for dawn")
60set(DAWN_INCLUDE_DIR "${Dawn_SOURCE_DIR}/include" CACHE PATH "Directory that contains public headers for dawn")
61set(DAWN_TEMPLATE_DIR "${DAWN_GENERATOR_DIR}/templates" CACHE PATH "Directory that contains templates for generators")
Corentin Wallez7fe6efb2020-02-05 17:16:05 +000062
Jaswant Panchumarti72b712f2024-06-21 13:16:18 +000063################################################################################
64# Configuration options
65################################################################################
Corentin Wallez7fe6efb2020-02-05 17:16:05 +000066# Default values for the backend-enabling options
Peng Huang925b7762023-05-01 16:13:00 +000067set(ENABLE_D3D11 OFF)
Corentin Wallez7fe6efb2020-02-05 17:16:05 +000068set(ENABLE_D3D12 OFF)
69set(ENABLE_METAL OFF)
Loko Kung90fdaa82024-07-24 00:59:58 +000070set(ENABLE_NULL ON)
Sergey Karchevsky3a75b1c2021-06-30 15:06:43 +000071set(ENABLE_OPENGLES OFF)
72set(ENABLE_DESKTOP_GL OFF)
Corentin Wallez7fe6efb2020-02-05 17:16:05 +000073set(ENABLE_VULKAN OFF)
Loko Kung90fdaa82024-07-24 00:59:58 +000074set(ENABLE_EMSCRIPTEN OFF)
Jaswant Panchumarti5bdf8762024-06-22 11:12:38 +000075set(ENABLE_SPIRV_VALIDATION OFF)
Corentin Wallez2e22d922022-06-01 09:30:50 +000076set(USE_WAYLAND OFF)
Corentin Wallezd353ca02020-02-18 02:12:35 +000077set(USE_X11 OFF)
Stephen Gutekanst55623702023-07-01 11:43:55 +000078set(USE_WINDOWS_UI OFF)
Ben Claytona6750752022-02-04 18:35:55 +000079set(BUILD_SAMPLES OFF)
Lokbondo Kung868a4672024-10-25 20:17:03 +000080set(BUILD_TESTS OFF)
AlexVestin5c3645c2023-10-18 14:08:26 +000081set(TARGET_MACOS OFF)
Loko Kung90fdaa82024-07-24 00:59:58 +000082if (CMAKE_SYSTEM_NAME MATCHES "Emscripten")
83 # Only the samples are supported for Emscripten at the moment.
84 # TODO(crbug.com/42240181): Make dawn_end2end_tests work too.
85 set(ENABLE_EMSCRIPTEN ON)
86 set(BUILD_SAMPLES ON)
Lokbondo Kung868a4672024-10-25 20:17:03 +000087 set(BUILD_TESTS ON)
Loko Kung90fdaa82024-07-24 00:59:58 +000088 set(ENABLE_NULL OFF)
89elseif (WIN32)
90 set(ENABLE_D3D11 ON)
91 set(USE_WINDOWS_UI ON)
92 set(ENABLE_D3D12 ON)
Jaswant Panchumarti5bdf8762024-06-22 11:12:38 +000093 if (NOT WINDOWS_STORE)
94 # Enable Vulkan in win32 compilation only
95 # since UWP only supports d3d
96 set(ENABLE_VULKAN ON)
97 set(ENABLE_SPIRV_VALIDATION ON)
98 endif()
Corentin Wallez7fe6efb2020-02-05 17:16:05 +000099elseif(APPLE)
Jaswant Panchumarti5bdf8762024-06-22 11:12:38 +0000100 set(ENABLE_METAL ON)
101 if(CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "MacOS")
102 set(TARGET_MACOS ON)
103 endif()
Alexander Vestinf2556ab2022-03-25 13:18:46 +0000104elseif(ANDROID)
Jaswant Panchumarti5bdf8762024-06-22 11:12:38 +0000105 set(ENABLE_VULKAN ON)
106 set(ENABLE_OPENGLES ON)
107 # Disable SPIR-V validation on Android because it adds a significant amount
108 # to the binary size, and Tint's output should be well-formed.
109 set(ENABLE_SPIRV_VALIDATION OFF)
Corentin Wallez7fe6efb2020-02-05 17:16:05 +0000110elseif(UNIX)
Jaswant Panchumarti5bdf8762024-06-22 11:12:38 +0000111 set(ENABLE_OPENGLES ON)
112 set(ENABLE_DESKTOP_GL ON)
113 set(ENABLE_VULKAN ON)
114 set(ENABLE_SPIRV_VALIDATION ON)
115 set(USE_X11 ON)
Corentin Wallez7fe6efb2020-02-05 17:16:05 +0000116endif()
117
陈俊嘉b2bc57a2021-06-24 07:00:16 +0000118# GLFW is not supported in UWP
Albin Bernhardssonb8a1b6d2023-07-13 08:51:17 +0000119set(DAWN_SUPPORTS_GLFW_FOR_WINDOWING OFF)
Loko Kung90fdaa82024-07-24 00:59:58 +0000120if (NOT ENABLE_EMSCRIPTEN AND ((WIN32 AND NOT WINDOWS_STORE) OR (UNIX AND NOT ANDROID)))
陈俊嘉b2bc57a2021-06-24 07:00:16 +0000121 set(DAWN_SUPPORTS_GLFW_FOR_WINDOWING ON)
122endif()
123
124# Current examples are depend on GLFW
125if (DAWN_SUPPORTS_GLFW_FOR_WINDOWING)
Ben Claytona6750752022-02-04 18:35:55 +0000126 set(BUILD_SAMPLES ON)
陈俊嘉b2bc57a2021-06-24 07:00:16 +0000127endif()
128
Jaswant Panchumartidb4c4022024-06-10 09:23:49 +0000129option(DAWN_ENABLE_ASAN "Enable address sanitizer" OFF)
130option(DAWN_ENABLE_INSTALL "Enable install step for Dawn libraries" OFF)
131option(DAWN_ENABLE_TSAN "Enable thread sanitizer" OFF)
132option(DAWN_ENABLE_MSAN "Enable memory sanitizer" OFF)
133option(DAWN_ENABLE_UBSAN "Enable undefined behaviour sanitizer" OFF)
Ben Clayton96e245e2022-04-08 18:08:36 +0000134
Jaswant Panchumartidb4c4022024-06-10 09:23:49 +0000135option(DAWN_ENABLE_D3D11 "Enable compilation of the D3D11 backend" ${ENABLE_D3D11})
136option(DAWN_ENABLE_D3D12 "Enable compilation of the D3D12 backend" ${ENABLE_D3D12})
137option(DAWN_ENABLE_METAL "Enable compilation of the Metal backend" ${ENABLE_METAL})
Loko Kung90fdaa82024-07-24 00:59:58 +0000138option(DAWN_ENABLE_NULL "Enable compilation of the Null backend" ${ENABLE_NULL})
Jaswant Panchumartidb4c4022024-06-10 09:23:49 +0000139option(DAWN_ENABLE_DESKTOP_GL "Enable compilation of the OpenGL backend" ${ENABLE_DESKTOP_GL})
140option(DAWN_ENABLE_OPENGLES "Enable compilation of the OpenGL ES backend" ${ENABLE_OPENGLES})
141option(DAWN_ENABLE_VULKAN "Enable compilation of the Vulkan backend" ${ENABLE_VULKAN})
Jaswant Panchumarti5bdf8762024-06-22 11:12:38 +0000142option(DAWN_ENABLE_SPIRV_VALIDATION "Enable validation of SPIR-V" ${ENABLE_SPIRV_VALIDATION})
dan sinclair194c1772022-06-21 17:54:03 +0000143
Loko Kung90fdaa82024-07-24 00:59:58 +0000144# Optional path to Emscripten toolchain to allow for building WASM.
145option(DAWN_EMSCRIPTEN_TOOLCHAIN "Directory in which to find Emscripten toolchain" "")
146set(DAWN_ENABLE_EMSCRIPTEN OFF)
147if (NOT ${DAWN_EMSCRIPTEN_TOOLCHAIN} STREQUAL "" AND ENABLE_EMSCRIPTEN)
148 set(DAWN_ENABLE_EMSCRIPTEN ON)
149endif()
150
dan sinclair6ddfddd2024-09-17 20:30:54 +0000151message(STATUS "Dawn build D3D11 backend: ${DAWN_ENABLE_D3D11}")
152message(STATUS "Dawn build D3D12 backend: ${DAWN_ENABLE_D3D12}")
153message(STATUS "Dawn build Metal backend: ${DAWN_ENABLE_METAL}")
154message(STATUS "Dawn build Vulkan backend: ${DAWN_ENABLE_VULKAN}")
155message(STATUS "Dawn build OpenGL backend: ${DAWN_ENABLE_DESKTOP_GL}")
156message(STATUS "Dawn build OpenGL ES backend: ${DAWN_ENABLE_OPENGLES}")
157message(STATUS "Dawn build Emscripten: ${DAWN_ENABLE_EMSCRIPTEN}")
158message(STATUS "Dawn build Null backend: ${DAWN_ENABLE_NULL}")
159message(STATUS "")
160message(STATUS "Dawn enable SPIR-V validation: ${DAWN_ENABLE_SPIRV_VALIDATION}")
161message(STATUS "")
162message(STATUS "Dawn build with ASAN: ${DAWN_ENABLE_ASAN}")
163message(STATUS "Dawn build with TSAN: ${DAWN_ENABLE_TSAN}")
164message(STATUS "Dawn build with MSAN: ${DAWN_ENABLE_MSAN}")
165message(STATUS "Dawn build with UBSAN: ${DAWN_ENABLE_UBSAN}")
166message(STATUS "Dawn enable install: ${DAWN_ENABLE_INSTALL}")
167message(STATUS "")
168
Jaswant Panchumartidb4c4022024-06-10 09:23:49 +0000169option(DAWN_ALWAYS_ASSERT "Enable assertions on all build types" OFF)
170option(DAWN_USE_WAYLAND "Enable support for Wayland surface" ${USE_WAYLAND})
171option(DAWN_USE_X11 "Enable support for X11 surface" ${USE_X11})
172option(DAWN_USE_GLFW "Enable compilation of the GLFW windowing utils" ${DAWN_SUPPORTS_GLFW_FOR_WINDOWING})
173option(DAWN_USE_WINDOWS_UI "Enable support for Windows UI surface" ${USE_WINDOWS_UI})
174option(DAWN_USE_BUILT_DXC "Enable building and using DXC by the D3D12 backend" OFF)
Antonio Maioranoc5c74802024-08-08 14:45:08 +0000175option(DAWN_DXC_ENABLE_ASSERTS_IN_NDEBUG "Enable DXC asserts in non-debug builds" ON)
Jaswant Panchumartidb4c4022024-06-10 09:23:49 +0000176option(DAWN_TARGET_MACOS "Manually link Apple core frameworks" ${TARGET_MACOS})
Corentin Wallez7fe6efb2020-02-05 17:16:05 +0000177
Jaswant Panchumartidb4c4022024-06-10 09:23:49 +0000178option(DAWN_BUILD_SAMPLES "Enables building Dawn's samples" ${BUILD_SAMPLES})
Lokbondo Kung868a4672024-10-25 20:17:03 +0000179option(DAWN_BUILD_TESTS "Enables building Dawn's tests" ${BUILD_TESTS})
Jaswant Panchumartidb4c4022024-06-10 09:23:49 +0000180option(DAWN_BUILD_NODE_BINDINGS "Enables building Dawn's NodeJS bindings" OFF)
181option(DAWN_ENABLE_SWIFTSHADER "Enables building Swiftshader as part of the build and Vulkan adapter discovery" OFF)
182option(DAWN_BUILD_BENCHMARKS "Build Dawn benchmarks" OFF)
dan sinclair0c27cf22024-06-11 12:31:38 +0000183option(DAWN_BUILD_PROTOBUF "Build the protobuf dependencies" OFF)
Ben Claytonaffb7a32021-09-28 11:14:42 +0000184
Jaswant Panchumartidb4c4022024-06-10 09:23:49 +0000185option(DAWN_WERROR "Build with -Werror (or equivalent)" OFF)
186option(DAWN_ENABLE_PIC "Build with Position-Independent-Code enabled" OFF)
Corentin Wallez7fe6efb2020-02-05 17:16:05 +0000187
Jaswant Panchumartidb4c4022024-06-10 09:23:49 +0000188option(DAWN_EMIT_COVERAGE "Emit code coverage information" OFF)
Ben Claytonf927bcb2022-12-12 21:21:54 +0000189set_if_not_defined(LLVM_SOURCE_DIR "${Dawn_LLVM_SOURCE_DIR}" "Directory to an LLVM source checkout. Required to build turbo-cov")
Ben Claytone38993f2022-12-10 00:15:57 +0000190
dan sinclair6ddfddd2024-09-17 20:30:54 +0000191message(STATUS "Dawn build with asserts in all configurations: ${DAWN_ALWAYS_ASSERT}")
192message(STATUS "Dawn build Wayland support: ${DAWN_USE_WAYLAND}")
193message(STATUS "Dawn build X11 support: ${DAWN_USE_X11}")
194message(STATUS "Dawn build GLFW support: ${DAWN_USE_GLFW}")
195message(STATUS "Dawn build Windows UI support: ${DAWN_USE_WINDOWS_UI}")
196message(STATUS "Dawn build and use DXC: ${DAWN_USE_BUILT_DXC}")
197message(STATUS "Dawn enable DXC asserts in non-debug builds: ${DAWN_DXC_ENABLE_ASSERTS_IN_NDEBUG}")
198message(STATUS "Dawn target MacOS: ${TARGET_MACOS}")
199message(STATUS "")
200message(STATUS "Dawn build samples: ${DAWN_BUILD_SAMPLES}")
201message(STATUS "Dawn build Node bindings: ${DAWN_BUILD_NODE_BINDINGS}")
202message(STATUS "Dawn build Swiftshader: ${DAWN_ENABLE_SWIFTSHADER}")
203message(STATUS "Dawn build benchmarks: ${DAWN_BUILD_BENCHMARKS}")
204message(STATUS "Dawn build protobuf: ${DAWN_BUILD_PROTOBUF}")
205message(STATUS "")
206message(STATUS "Dawn build PIC: ${DAWN_ENABLE_PIC}")
207message(STATUS "DAWN Werror: ${DAWN_WERROR}")
208message(STATUS "")
209message(STATUS "Dawn emit coverage: ${DAWN_EMIT_COVERAGE}")
210message(STATUS "LLVM Source dir: ${LLVM_SOURCE_DIR}")
211message(STATUS "")
212
dan sinclair194c1772022-06-21 17:54:03 +0000213if (DAWN_ENABLE_OPENGLES OR DAWN_ENABLE_DESKTOP_GL)
214 set(TINT_DEFAULT_GLSL ON)
215else()
216 set(TINT_DEFAULT_GLSL OFF)
217endif()
218
Jaswant Panchumartidb4c4022024-06-10 09:23:49 +0000219option(TINT_ENABLE_INSTALL "Enable install step for Tint libraries" OFF)
220option(TINT_BUILD_CMD_TOOLS "Build the Tint command line tools" ON)
dan sinclair194c1772022-06-21 17:54:03 +0000221
Loko Kung90fdaa82024-07-24 00:59:58 +0000222if (DAWN_BUILD_SAMPLES)
223 if (NOT DAWN_USE_GLFW AND NOT DAWN_ENABLE_EMSCRIPTEN)
224 message(SEND_ERROR "Dawn samples require GLFW or Emscripten")
225 endif()
Erin Melucci38b58e42023-06-14 16:45:33 +0000226endif()
227
Jaswant Panchumartidb4c4022024-06-10 09:23:49 +0000228option(TINT_BUILD_SPV_READER "Build the SPIR-V input reader" ${DAWN_ENABLE_VULKAN})
229option(TINT_BUILD_WGSL_READER "Build the WGSL input reader" ON)
230option(TINT_BUILD_GLSL_WRITER "Build the GLSL output writer" ${TINT_DEFAULT_GLSL})
231option(TINT_BUILD_GLSL_VALIDATOR "Build the GLSL output validator" ON)
232option(TINT_BUILD_HLSL_WRITER "Build the HLSL output writer" ${DAWN_ENABLE_D3D12})
233option(TINT_BUILD_MSL_WRITER "Build the MSL output writer" ${DAWN_ENABLE_METAL})
234option(TINT_BUILD_SPV_WRITER "Build the SPIR-V output writer" ${DAWN_ENABLE_VULKAN})
235option(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON)
Jaswant Panchumartidb4c4022024-06-10 09:23:49 +0000236option(TINT_BUILD_SYNTAX_TREE_WRITER "Build the syntax tree writer" OFF)
dan sinclairc22b8b9d2022-11-01 17:02:31 +0000237
Ryan Harrison45788092024-06-19 02:26:57 +0000238if (DAWN_BUILD_PROTOBUF AND TARGET libprotobuf)
239 set(TINT_DEFAULT_BUILD_IR_BINARY ON)
240else()
241 set(TINT_DEFAULT_BUILD_IR_BINARY OFF)
242endif()
Ryan Harrison724dd782024-05-16 16:27:48 +0000243
Ryan Harrison45788092024-06-19 02:26:57 +0000244option(TINT_BUILD_IR_BINARY "Build IR binary format support" ${TINT_DEFAULT_BUILD_IR_BINARY})
Jaswant Panchumartidb4c4022024-06-10 09:23:49 +0000245option(TINT_BUILD_FUZZERS "Build fuzzers" OFF)
Jaswant Panchumartidb4c4022024-06-10 09:23:49 +0000246option(TINT_BUILD_IR_FUZZER "Build IR fuzzer" OFF)
247option(TINT_BUILD_BENCHMARKS "Build Tint benchmarks" OFF)
248option(TINT_BUILD_TESTS "Build tests" ON)
249option(TINT_BUILD_AS_OTHER_OS "Override OS detection to force building of *_other.cc files" OFF)
dan sinclair194c1772022-06-21 17:54:03 +0000250
dan sinclair0ee0afa2024-10-22 22:58:25 +0000251if (DAWN_ENABLE_EMSCRIPTEN)
252 # Skip tint tests in emscripten build
253 set(TINT_BUILD_TESTS OFF)
254 # Skip GLSL validation in Emscripten
255 set(TINT_BUILD_GLSL_VALIDATOR OFF)
256endif()
257
Jaswant Panchumartidb4c4022024-06-10 09:23:49 +0000258option(TINT_BUILD_TINTD "Build the WGSL language server" OFF)
Ben Claytonf9a5b712024-03-13 17:37:33 +0000259
Jaswant Panchumartidb4c4022024-06-10 09:23:49 +0000260option(TINT_ENABLE_BREAK_IN_DEBUGGER "Enable tint::debugger::Break()" OFF)
261option(TINT_CHECK_CHROMIUM_STYLE "Check for [chromium-style] issues during build" OFF)
262option(TINT_RANDOMIZE_HASHES "Randomize the hash seed value to detect non-deterministic output" OFF)
Corentin Walleze5570872020-10-20 14:26:10 +0000263
dan sinclair6ddfddd2024-09-17 20:30:54 +0000264message(STATUS "Tint build SPIR-V reader: ${TINT_BUILD_SPV_READER}")
265message(STATUS "Tint build WGSL reader: ${TINT_BUILD_WGSL_READER}")
266message(STATUS "Tint build GLSL writer: ${TINT_BUILD_GLSL_WRITER}")
267message(STATUS "Tint build GLSL validator: ${TINT_BUILD_GLSL_VALIDATOR}")
268message(STATUS "Tint build HLSL writer: ${TINT_BUILD_HLSL_WRITER}")
269message(STATUS "Tint build MSL writer: ${TINT_BUILD_MSL_WRITER}")
270message(STATUS "Tint build SPIR-V writer: ${TINT_BUILD_SPV_WRITER}")
271message(STATUS "Tint build WGSL writer: ${TINT_BUILD_WGSL_WRITER}")
272message(STATUS "Tint build Syntax Tree writer: ${TINT_BUILD_SYNTAX_TREE_WRITER}")
273message(STATUS "")
274message(STATUS "Tint build command line executable tools: ${TINT_BUILD_CMD_TOOLS}")
275message(STATUS "Tint install: ${TINT_ENABLE_INSTALL}")
276message(STATUS "Tint build fuzzers: ${TINT_BUILD_FUZZERS}")
277message(STATUS "Tint build IR binary: ${TINT_BUILD_IR_BINARY}")
278message(STATUS "Tint build IR fuzzer: ${TINT_BUILD_IR_FUZZER}")
279message(STATUS "Tint build benchmarks: ${TINT_BUILD_BENCHMARKS}")
280message(STATUS "Tint build tests: ${TINT_BUILD_TESTS}")
281message(STATUS "Tint build tintd: ${TINT_BUILD_TINTD}")
282message(STATUS "")
283message(STATUS "Tint enable break in debugger: ${TINT_ENABLE_BREAK_IN_DEBUGGER}")
284message(STATUS "Tint build checking [chromium-style]: ${TINT_CHECK_CHROMIUM_STYLE}")
285message(STATUS "Tint randomize hashes: ${TINT_RANDOMIZE_HASHES}")
286message(STATUS "")
dan sinclair6ddfddd2024-09-17 20:30:54 +0000287
dan sinclair194c1772022-06-21 17:54:03 +0000288set_if_not_defined(DAWN_THIRD_PARTY_DIR "${Dawn_SOURCE_DIR}/third_party" "Directory in which to find third-party dependencies.")
dan sinclairc1f6dbd2023-04-11 15:45:18 +0000289
Ben Clayton30eeac72021-09-24 10:38:18 +0000290set_if_not_defined(DAWN_ABSEIL_DIR "${DAWN_THIRD_PARTY_DIR}/abseil-cpp" "Directory in which to find Abseil")
291set_if_not_defined(DAWN_GLFW_DIR "${DAWN_THIRD_PARTY_DIR}/glfw" "Directory in which to find GLFW")
Ben Clayton30eeac72021-09-24 10:38:18 +0000292set_if_not_defined(DAWN_JINJA2_DIR "${DAWN_THIRD_PARTY_DIR}/jinja2" "Directory in which to find Jinja2")
Arthur Sonzognic5f72f72023-11-29 15:27:40 +0000293set_if_not_defined(DAWN_MARKUPSAFE_DIR "${DAWN_THIRD_PARTY_DIR}/markupsafe" "Directory in which to find MarkupSafe")
Arthur Sonzogni58f8ed22023-11-30 09:30:52 +0000294set_if_not_defined(DAWN_KHRONOS_DIR "${DAWN_THIRD_PARTY_DIR}/khronos" "Directory in which to find Khronos GL headers")
Corentin Wallezbe352ea2022-04-11 16:48:43 +0000295set_if_not_defined(DAWN_SWIFTSHADER_DIR "${DAWN_THIRD_PARTY_DIR}/swiftshader" "Directory in which to find swiftshader")
Ben Claytonfb07fa92023-11-17 18:48:59 +0000296set_if_not_defined(DAWN_PROTOBUF_DIR "${DAWN_THIRD_PARTY_DIR}/protobuf" "Directory in which to find protobuf")
Ryan Harrison25e23b32024-05-27 23:21:05 +0000297set_if_not_defined(DAWN_LPM_DIR "${DAWN_THIRD_PARTY_DIR}/libprotobuf-mutator/src" "Directory in which to find libprotobuf")
Loko Kung90fdaa82024-07-24 00:59:58 +0000298set_if_not_defined(DAWN_EMDAWNWEBGPU_DIR "${DAWN_THIRD_PARTY_DIR}/emdawnwebgpu" "Directory in which to find Dawn specific Emscripten bindings")
Lokbondo Kung868a4672024-10-25 20:17:03 +0000299set_if_not_defined(DAWN_GOOGLETEST_DIR "${DAWN_THIRD_PARTY_DIR}/googletest" "Directory in which to find googletest")
dan sinclairc1f6dbd2023-04-11 15:45:18 +0000300
Yuly Novikov143523a2024-05-23 15:59:58 +0000301set_if_not_defined(DAWN_SPIRV_TOOLS_DIR "${DAWN_THIRD_PARTY_DIR}/spirv-tools/src" "Directory in which to find SPIRV-Tools")
302set_if_not_defined(DAWN_SPIRV_HEADERS_DIR "${DAWN_THIRD_PARTY_DIR}/spirv-headers/src" "Directory in which to find SPIRV-Headers")
dan sinclair12c428f2024-06-21 01:14:24 +0000303set_if_not_defined(DAWN_GLSLANG_DIR "${DAWN_THIRD_PARTY_DIR}/glslang/src" "Directory in which to find GLSLang")
Yuly Novikov143523a2024-05-23 15:59:58 +0000304set_if_not_defined(DAWN_VULKAN_HEADERS_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-headers/src" "Directory in which to find Vulkan-Headers")
305set_if_not_defined(DAWN_VULKAN_UTILITY_LIBRARIES_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-utility-libraries/src" "Directory in which to find Vulkan-Utility-Libraries")
Corentin Wallez7fe6efb2020-02-05 17:16:05 +0000306
dan sinclair6ddfddd2024-09-17 20:30:54 +0000307message(STATUS "Dawn third_party dir: ${DAWN_THIRD_PARTY_DIR}")
308message(STATUS "Dawn GLFW dir: ${DAWN_GLFW_DIR}")
309message(STATUS "Dawn Jinja2 dir: ${DAWN_JINJA2_DIR}")
310message(STATUS "Dawn MarkupSafe dir: ${DAWN_MARKUPSAFE_DIR}")
311message(STATUS "Dawn Khronos dir: ${DAWN_KHRONOS_DIR}")
312message(STATUS "Dawn Swiftshader dir: ${DAWN_SWIFTSHADER_DIR}")
313message(STATUS "Dawn Protobuf dir: ${DAWN_PROTOBUF_DIR}")
314message(STATUS "Dawn LPM dir: ${DAWN_LPM_DIR}")
315message(STATUS "Dawn Emdawnwebgpu dir: ${DAWN_EMDAWNWEBGPU_DIR}")
316message(STATUS "Dawn Spir-Tools dir: ${DAWN_SPIRV_TOOLS_DIR}")
317message(STATUS "Dawn Spirv-Headers dir: ${DAWN_SPIRV_HEADERS_DIR}")
318message(STATUS "Dawn Glslang dir: ${DAWN_GLSLANG_DIR}")
319message(STATUS "Dawn Vulkan Headers dir: ${DAWN_VULKAN_HEADERS_DIR}")
320message(STATUS "Dawn Vulkan Utility Libraries dir: ${DAWN_VULKAN_UTILITY_LIBRARIES_DIR}")
321message(STATUS "")
322
Ben Claytonaffb7a32021-09-28 11:14:42 +0000323# Dependencies for DAWN_BUILD_NODE_BINDINGS
324set_if_not_defined(NODE_ADDON_API_DIR "${DAWN_THIRD_PARTY_DIR}/node-addon-api" "Directory in which to find node-addon-api")
Ben Clayton72e3ba62021-09-30 18:04:01 +0000325set_if_not_defined(NODE_API_HEADERS_DIR "${DAWN_THIRD_PARTY_DIR}/node-api-headers" "Directory in which to find node-api-headers")
Ben Claytonaffb7a32021-09-28 11:14:42 +0000326set_if_not_defined(WEBGPU_IDL_PATH "${DAWN_THIRD_PARTY_DIR}/gpuweb/webgpu.idl" "Path to the webgpu.idl definition file")
Austin Eng4948c812021-10-15 14:28:32 +0000327set_if_not_defined(GO_EXECUTABLE "go" "Golang executable for running the IDL generator")
Ben Claytonaffb7a32021-09-28 11:14:42 +0000328
dan sinclair6ddfddd2024-09-17 20:30:54 +0000329message(STATUS "Node Addon API dir: ${NODE_ADDON_API_DIR}")
330message(STATUS "Node API Headers dir: ${NODE_API_HEADERS_DIR}")
331message(STATUS "Webgpu IDL path: ${WEBGPU_IDL_PATH}")
332message(STATUS "Go exe: ${GO_EXECUTABLE}")
333message(STATUS "")
Elie Michel9ae8ed22023-05-12 20:19:41 +0000334
dan sinclair6ddfddd2024-09-17 20:30:54 +0000335option(DAWN_FETCH_DEPENDENCIES "Use fetch_dawn_dependencies.py as an alternative to using depot_tools" OFF)
Jaswant Panchumarti5a26bdd2024-07-04 14:13:55 +0000336option(DAWN_BUILD_MONOLITHIC_LIBRARY "Bundle all dawn components into a single shared library." ON)
337
dan sinclair6ddfddd2024-09-17 20:30:54 +0000338message(STATUS "Dawn fetch dependencies: ${DAWN_FETCH_DEPENDENCIES}")
339message(STATUS "Dawn build monolithic library: ${DAWN_BUILD_MONOLITHIC_LIBRARY}")
340message(STATUS "")
341
Loko Kung90fdaa82024-07-24 00:59:58 +0000342# Optional path to Emscripten toolchain to allow for building WASM.
343set_if_not_defined(DAWN_EMSCRIPTEN_TOOLCHAIN "" "Directory in which to find Emscripten toolchain")
344set(DAWN_ENABLE_EMSCRIPTEN OFF)
345if (NOT ${DAWN_EMSCRIPTEN_TOOLCHAIN} STREQUAL "" AND ENABLE_EMSCRIPTEN)
346 set(DAWN_ENABLE_EMSCRIPTEN ON)
347endif()
348
dan sinclair6ddfddd2024-09-17 20:30:54 +0000349message(STATUS "Dawn Emscripten toolchain: ${DAWN_EMSCRIPTEN_TOOLCHAIN}")
350message(STATUS "")
351
Sergey Karchevsky3a75b1c2021-06-30 15:06:43 +0000352# Much of the backend code is shared among desktop OpenGL and OpenGL ES
353if (${DAWN_ENABLE_DESKTOP_GL} OR ${DAWN_ENABLE_OPENGLES})
354 set(DAWN_ENABLE_OPENGL ON)
355endif()
356
Ben Claytonaffb7a32021-09-28 11:14:42 +0000357if(DAWN_ENABLE_PIC)
358 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
359endif()
360
Jaswant Panchumarti5a26bdd2024-07-04 14:13:55 +0000361# Defines `CMAKE_INSTALL_*DIR` variables
362include(GNUInstallDirs)
Jaswant Panchumarti34cca842024-06-25 00:30:37 +0000363# The public config contains only the include paths for the Dawn headers.
364add_library(dawn_public_config INTERFACE)
365target_include_directories(dawn_public_config INTERFACE
Jaswant Panchumarti5a26bdd2024-07-04 14:13:55 +0000366 "$<BUILD_INTERFACE:${DAWN_INCLUDE_DIR}>"
367 "$<BUILD_INTERFACE:${DAWN_BUILD_GEN_DIR}/include>"
368 "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
Jaswant Panchumarti34cca842024-06-25 00:30:37 +0000369)
370
371# The internal config contains additional path but includes the dawn_public_config include paths
372add_library(dawn_internal_config INTERFACE)
373target_include_directories(dawn_internal_config INTERFACE
dan sinclaird90557b2024-08-28 16:15:03 +0000374 "${PROJECT_SOURCE_DIR}"
Jaswant Panchumarti34cca842024-06-25 00:30:37 +0000375 "${DAWN_SRC_DIR}"
376 "${DAWN_BUILD_GEN_DIR}/src"
377)
378target_link_libraries(dawn_internal_config INTERFACE dawn_public_config)
379
Jaswant Panchumartieb93d8c2024-06-22 10:51:37 +0000380################################################################################
381# Include utility CMake modules
382################################################################################
Jaswant Panchumarti064f5442024-06-22 11:19:03 +0000383include(DawnCompilerChecks)
Jaswant Panchumartieb93d8c2024-06-22 10:51:37 +0000384include(DawnCompilerExtraFlags)
Jaswant Panchumarti61f9bc02024-06-22 10:56:48 +0000385include(DawnCompilerPlatformFlags)
Jaswant Panchumarti34cca842024-06-25 00:30:37 +0000386include(DawnCompilerWarningFlags)
Jaswant Panchumartifa416492024-06-22 11:08:57 +0000387include(DawnInitializeBuildType)
Jaswant Panchumarti85b76752024-06-25 04:24:49 +0000388include(DawnLibrary)
Jaswant Panchumartieb93d8c2024-06-22 10:51:37 +0000389
Ryan Harrison88e0d752024-06-14 02:02:10 +0000390set(IS_ASAN ${DAWN_ENABLE_ASAN})
dan sinclair194c1772022-06-21 17:54:03 +0000391
392if (NOT ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS} STREQUAL "")
393 message(STATUS "Using provided LIB_FUZZING_ENGINE options: ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS}")
394endif()
395
Corentin Wallez179e84a2024-03-27 20:20:15 +0000396find_package(Python3 REQUIRED)
Corentin Wallez2f18c9a2024-04-02 08:51:45 +0000397message(STATUS "Dawn: using python at ${Python3_EXECUTABLE}")
dan sinclair194c1772022-06-21 17:54:03 +0000398
Ben Clayton94181522022-11-09 20:55:33 +0000399set(IS_DEBUG_BUILD 0)
400string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type)
401if ((NOT ${build_type} STREQUAL "RELEASE") AND (NOT ${build_type} STREQUAL "RELWITHDEBINFO"))
402 set(IS_DEBUG_BUILD 1)
403endif()
404
Corentin Wallez7fe6efb2020-02-05 17:16:05 +0000405# Compile definitions for the internal config
Ben Clayton94181522022-11-09 20:55:33 +0000406if (DAWN_ALWAYS_ASSERT OR IS_DEBUG_BUILD)
Corentin Wallez7fe6efb2020-02-05 17:16:05 +0000407 target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_ASSERTS")
408endif()
Peng Huang5c2f1672023-05-01 23:05:42 +0000409if (DAWN_ENABLE_D3D11)
410 target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_D3D11")
411endif()
Corentin Wallez7fe6efb2020-02-05 17:16:05 +0000412if (DAWN_ENABLE_D3D12)
413 target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_D3D12")
414endif()
415if (DAWN_ENABLE_METAL)
416 target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_METAL")
417endif()
418if (DAWN_ENABLE_NULL)
419 target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_NULL")
420endif()
Sergey Karchevsky3a75b1c2021-06-30 15:06:43 +0000421if (DAWN_ENABLE_DESKTOP_GL)
422 target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_DESKTOP_GL")
423endif()
424if (DAWN_ENABLE_OPENGLES)
425 target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_OPENGLES")
426endif()
Corentin Wallez7fe6efb2020-02-05 17:16:05 +0000427if (DAWN_ENABLE_OPENGL)
428 target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_OPENGL")
429endif()
430if (DAWN_ENABLE_VULKAN)
431 target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_VULKAN")
432endif()
Corentin Wallez2e22d922022-06-01 09:30:50 +0000433if (DAWN_USE_WAYLAND)
434 target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_WAYLAND")
435endif()
Corentin Wallezd353ca02020-02-18 02:12:35 +0000436if (DAWN_USE_X11)
Corentin Wallez7fe6efb2020-02-05 17:16:05 +0000437 target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_X11")
438endif()
Stephen Gutekanst55623702023-07-01 11:43:55 +0000439if (DAWN_USE_WINDOWS_UI)
440 target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_WINDOWS_UI")
441endif()
Corentin Wallez33466972020-02-24 13:27:28 +0000442if (WIN32)
443 target_compile_definitions(dawn_internal_config INTERFACE "NOMINMAX" "WIN32_LEAN_AND_MEAN")
444endif()
445
Corentin Wallez7fe6efb2020-02-05 17:16:05 +0000446################################################################################
Ryan Harrisone87ac762022-04-06 15:37:27 -0400447# Tint
448################################################################################
449
Alastair Donaldson6a1eb452021-09-02 23:49:25 +0000450set(TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS "" CACHE STRING "Used by OSS-Fuzz to control, via link options, which fuzzing engine should be used")
451
Ben Claytonfb07fa92023-11-17 18:48:59 +0000452set(TINT_ROOT_SOURCE_DIR ${PROJECT_SOURCE_DIR})
Ben Clayton3a3cb362023-08-16 01:05:21 +0000453set(TINT_SPIRV_HEADERS_DIR ${DAWN_SPIRV_HEADERS_DIR})
454set(TINT_SPIRV_TOOLS_DIR ${DAWN_SPIRV_TOOLS_DIR})
Ben Clayton54cfa0b2021-07-08 19:35:53 +0000455
Antonio Maiorano88d3d2e2021-03-23 20:51:09 +0000456
Ryan Harrisone87ac762022-04-06 15:37:27 -0400457################################################################################
Corentin Wallez7fe6efb2020-02-05 17:16:05 +0000458# Run on all subdirectories
459################################################################################
dan sinclair0c27cf22024-06-11 12:31:38 +0000460if (DAWN_BUILD_PROTOBUF AND EXISTS "${DAWN_PROTOBUF_DIR}/cmake")
Ben Clayton01fa7c82024-01-31 21:07:17 +0000461 if (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") AND WIN32)
462 set(protobuf_HAVE_BUILTIN_ATOMICS 1)
463 endif()
464
Ben Claytonfb07fa92023-11-17 18:48:59 +0000465 # Needs to come before SPIR-V Tools
466 include("third_party/protobuf.cmake")
467endif()
Corentin Wallez7fe6efb2020-02-05 17:16:05 +0000468
469add_subdirectory(third_party)
James Price8d9adb02022-05-22 00:41:53 +0000470
471# TODO(crbug.com/tint/455): Tint does not currently build with CMake when
472# BUILD_SHARED_LIBS=1, so always build it as static for now.
473set(BUILD_SHARED_LIBS_SAVED ${BUILD_SHARED_LIBS})
474set(BUILD_SHARED_LIBS 0)
dan sinclaird90557b2024-08-28 16:15:03 +0000475
476add_subdirectory(src/utils)
dan sinclair0ee0afa2024-10-22 22:58:25 +0000477add_subdirectory(src/tint)
dan sinclaird90557b2024-08-28 16:15:03 +0000478
James Price8d9adb02022-05-22 00:41:53 +0000479set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_SAVED})
dan sinclair12c428f2024-06-21 01:14:24 +0000480
Loko Kung90fdaa82024-07-24 00:59:58 +0000481if (DAWN_ENABLE_D3D11 OR DAWN_ENABLE_D3D12 OR DAWN_ENABLE_METAL OR DAWN_ENABLE_NULL OR DAWN_ENABLE_DESKTOP_GL OR DAWN_ENABLE_OPENGLES OR DAWN_ENABLE_VULKAN OR DAWN_ENABLE_EMSCRIPTEN)
dan sinclair12c428f2024-06-21 01:14:24 +0000482 add_subdirectory(generator)
Loko Kung90fdaa82024-07-24 00:59:58 +0000483 # Note that we must add Emscripten directory first to ensure the correct
484 # headers will be exported upwards.
485 add_subdirectory(src/emdawnwebgpu)
dan sinclair12c428f2024-06-21 01:14:24 +0000486 add_subdirectory(src/dawn)
487endif()
Ben Clayton7b778552022-02-04 18:59:15 +0000488
489################################################################################
490# Samples
491################################################################################
dan sinclairb5950522020-03-19 13:03:35 +0000492add_custom_target(tint-lint
493 COMMAND ./tools/lint
Ben Clayton54cfa0b2021-07-08 19:35:53 +0000494 WORKING_DIRECTORY ${TINT_ROOT_SOURCE_DIR}
dan sinclairb5950522020-03-19 13:03:35 +0000495 COMMENT "Running linter"
496 VERBATIM)
497
498add_custom_target(tint-format
499 COMMAND ./tools/format
Ben Clayton54cfa0b2021-07-08 19:35:53 +0000500 WORKING_DIRECTORY ${TINT_ROOT_SOURCE_DIR}
dan sinclairb5950522020-03-19 13:03:35 +0000501 COMMENT "Running formatter"
502 VERBATIM)
Ben Claytonadb10d62020-10-27 21:04:59 +0000503
Ben Clayton78e45302023-01-26 15:57:27 +0000504if (DAWN_EMIT_COVERAGE)
505 add_subdirectory(tools/src/cmd/turbo-cov)
Ben Claytonadb10d62020-10-27 21:04:59 +0000506
Ben Clayton78e45302023-01-26 15:57:27 +0000507 # The tint-generate-coverage target generates a lcov.info file at the project
508 # root, holding the code coverage for all the tint_unitests.
Ben Claytonadb10d62020-10-27 21:04:59 +0000509 # This can be used by tools such as VSCode's Coverage Gutters extension to
510 # visualize code coverage in the editor.
511 get_filename_component(CLANG_BIN_DIR ${CMAKE_C_COMPILER} DIRECTORY)
512 set(PATH_WITH_CLANG "${CLANG_BIN_DIR}:$ENV{PATH}")
513 add_custom_target(tint-generate-coverage
514 COMMAND ${CMAKE_COMMAND} -E env PATH=${PATH_WITH_CLANG} ./tools/tint-generate-coverage $<TARGET_FILE:tint_unittests>
515 DEPENDS tint_unittests
Ben Clayton54cfa0b2021-07-08 19:35:53 +0000516 WORKING_DIRECTORY ${TINT_ROOT_SOURCE_DIR}
Ben Claytonadb10d62020-10-27 21:04:59 +0000517 COMMENT "Generating tint coverage data"
518 VERBATIM)
519endif()
Jaswant Panchumarti5a26bdd2024-07-04 14:13:55 +0000520
521if (DAWN_BUILD_MONOLITHIC_LIBRARY AND DAWN_ENABLE_INSTALL)
522 # This series of functions add the necessary information so that other CMake projects
523 # can use Dawn, be it from a build directory, a local install or when packaged.
524 install(EXPORT DawnTargets
525 FILE DawnTargets.cmake
526 NAMESPACE dawn::
527 DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Dawn")
528 export(EXPORT DawnTargets
529 FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/DawnTargets.cmake"
530 NAMESPACE dawn::
531 )
532 # Create a ConfigVersion.cmake file:
533 include(CMakePackageConfigHelpers)
534 write_basic_package_version_file(
535 "${CMAKE_CURRENT_BINARY_DIR}/DawnConfigVersion.cmake"
536 COMPATIBILITY AnyNewerVersion)
537 # Configure config file
538 configure_package_config_file("${CMAKE_CURRENT_LIST_DIR}/src/cmake/DawnConfig.cmake.in"
539 "${CMAKE_CURRENT_BINARY_DIR}/DawnConfig.cmake"
540 INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Dawn"
541 )
542 # Install the fully generated config and configVersion files
543 install(FILES
544 "${CMAKE_CURRENT_BINARY_DIR}/DawnConfig.cmake"
545 "${CMAKE_CURRENT_BINARY_DIR}/DawnConfigVersion.cmake"
546 DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Dawn"
547 )
548endif ()