Ryan Harrison | e87ac76 | 2022-04-06 15:37:27 -0400 | [diff] [blame] | 1 | # Copyright 2022 The Dawn & Tint Authors |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 15 | cmake_minimum_required(VERSION 3.10.2) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 16 | |
dan sinclair | fb5a492 | 2022-04-19 22:25:45 +0000 | [diff] [blame] | 17 | # When upgrading to CMake 3.11 we can remove DAWN_PLACEHOLDER_FILE because source-less add_library |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 18 | # becomes available. |
| 19 | # When upgrading to CMake 3.12 we should add CONFIGURE_DEPENDS to DawnGenerator to rerun CMake in |
Corentin Wallez | 42450c6 | 2020-04-10 17:04:31 +0000 | [diff] [blame] | 20 | # case any of the generator files changes. We should also remove the CACHE "" FORCE stuff to |
dan sinclair | 1877c27 | 2020-10-20 19:46:21 +0000 | [diff] [blame] | 21 | # override options in third_party dependencies. We can also add the HOMEPAGE_URL |
| 22 | # entry to the project `HOMEPAGE_URL "https://dawn.googlesource.com/dawn"` |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 23 | |
| 24 | project( |
| 25 | Dawn |
| 26 | DESCRIPTION "Dawn, a WebGPU implementation" |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 27 | LANGUAGES C CXX |
| 28 | ) |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 29 | enable_testing() |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 30 | |
| 31 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 32 | |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 33 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) |
| 34 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
Ben Clayton | 7b0686a | 2022-01-06 09:23:11 +0000 | [diff] [blame] | 35 | set(CMAKE_CXX_STANDARD 17) |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 36 | set(CMAKE_DEBUG_POSTFIX "") |
| 37 | |
| 38 | if ("${CMAKE_BUILD_TYPE}" STREQUAL "") |
| 39 | message(STATUS "No build type selected, default to Debug") |
| 40 | set(CMAKE_BUILD_TYPE "Debug") |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 41 | endif() |
| 42 | |
| 43 | set(DAWN_BUILD_GEN_DIR "${Dawn_BINARY_DIR}/gen") |
| 44 | set(DAWN_GENERATOR_DIR "${Dawn_SOURCE_DIR}/generator") |
| 45 | set(DAWN_SRC_DIR "${Dawn_SOURCE_DIR}/src") |
Ben Clayton | 9fb7a51 | 2022-02-04 18:18:18 +0000 | [diff] [blame] | 46 | set(DAWN_INCLUDE_DIR "${Dawn_SOURCE_DIR}/include") |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 47 | set(DAWN_TEMPLATE_DIR "${DAWN_GENERATOR_DIR}/templates") |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 48 | |
dan sinclair | fb5a492 | 2022-04-19 22:25:45 +0000 | [diff] [blame] | 49 | set(DAWN_PLACEHOLDER_FILE "${DAWN_SRC_DIR}/Placeholder.cpp") |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 50 | |
| 51 | ################################################################################ |
| 52 | # Configuration options |
| 53 | ################################################################################ |
| 54 | |
Ben Clayton | 30eeac7 | 2021-09-24 10:38:18 +0000 | [diff] [blame] | 55 | # option_if_not_defined(name description default) |
| 56 | # Behaves like: |
| 57 | # option(name description default) |
| 58 | # If a variable is not already defined with the given name, otherwise the |
| 59 | # function does nothing. |
| 60 | # Simplifies customization by projects that use Dawn as a dependency. |
| 61 | function (option_if_not_defined name description default) |
| 62 | if(NOT DEFINED ${name}) |
| 63 | option(${name} ${description} ${default}) |
| 64 | endif() |
| 65 | endfunction() |
| 66 | |
| 67 | # set_if_not_defined(name value description) |
| 68 | # Behaves like: |
| 69 | # set(${name} ${value} CACHE STRING ${description}) |
| 70 | # If a variable is not already defined with the given name, otherwise the |
| 71 | # function does nothing. |
| 72 | # Simplifies customization by projects that use Dawn as a dependency. |
| 73 | function (set_if_not_defined name value description) |
| 74 | if(NOT DEFINED ${name}) |
| 75 | set(${name} ${value} CACHE STRING ${description}) |
| 76 | endif() |
| 77 | endfunction() |
| 78 | |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 79 | # Default values for the backend-enabling options |
Peng Huang | 925b776 | 2023-05-01 16:13:00 +0000 | [diff] [blame] | 80 | set(ENABLE_D3D11 OFF) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 81 | set(ENABLE_D3D12 OFF) |
| 82 | set(ENABLE_METAL OFF) |
Sergey Karchevsky | 3a75b1c | 2021-06-30 15:06:43 +0000 | [diff] [blame] | 83 | set(ENABLE_OPENGLES OFF) |
| 84 | set(ENABLE_DESKTOP_GL OFF) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 85 | set(ENABLE_VULKAN OFF) |
Corentin Wallez | 2e22d92 | 2022-06-01 09:30:50 +0000 | [diff] [blame] | 86 | set(USE_WAYLAND OFF) |
Corentin Wallez | d353ca0 | 2020-02-18 02:12:35 +0000 | [diff] [blame] | 87 | set(USE_X11 OFF) |
Stephen Gutekanst | 5562370 | 2023-07-01 11:43:55 +0000 | [diff] [blame] | 88 | set(USE_WINDOWS_UI OFF) |
Ben Clayton | a675075 | 2022-02-04 18:35:55 +0000 | [diff] [blame] | 89 | set(BUILD_SAMPLES OFF) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 90 | if (WIN32) |
Peng Huang | 925b776 | 2023-05-01 16:13:00 +0000 | [diff] [blame] | 91 | set(ENABLE_D3D11 ON) |
Stephen Gutekanst | 5562370 | 2023-07-01 11:43:55 +0000 | [diff] [blame] | 92 | set(USE_WINDOWS_UI ON) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 93 | set(ENABLE_D3D12 ON) |
陈俊嘉 | 610de1d | 2021-06-28 08:19:28 +0000 | [diff] [blame] | 94 | if (NOT WINDOWS_STORE) |
陈俊嘉 | b2bc57a | 2021-06-24 07:00:16 +0000 | [diff] [blame] | 95 | # Enable Vulkan in win32 compilation only |
| 96 | # since UWP only supports d3d |
| 97 | set(ENABLE_VULKAN ON) |
| 98 | endif() |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 99 | elseif(APPLE) |
| 100 | set(ENABLE_METAL ON) |
Alexander Vestin | f2556ab | 2022-03-25 13:18:46 +0000 | [diff] [blame] | 101 | elseif(ANDROID) |
| 102 | set(ENABLE_VULKAN ON) |
| 103 | set(ENABLE_OPENGLES ON) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 104 | elseif(UNIX) |
Sergey Karchevsky | 3a75b1c | 2021-06-30 15:06:43 +0000 | [diff] [blame] | 105 | set(ENABLE_OPENGLES ON) |
| 106 | set(ENABLE_DESKTOP_GL ON) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 107 | set(ENABLE_VULKAN ON) |
Corentin Wallez | d353ca0 | 2020-02-18 02:12:35 +0000 | [diff] [blame] | 108 | set(USE_X11 ON) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 109 | endif() |
| 110 | |
陈俊嘉 | b2bc57a | 2021-06-24 07:00:16 +0000 | [diff] [blame] | 111 | # GLFW is not supported in UWP |
Ryan Harrison | e87ac76 | 2022-04-06 15:37:27 -0400 | [diff] [blame] | 112 | if ((WIN32 AND NOT WINDOWS_STORE) OR UNIX AND NOT ANDROID) |
陈俊嘉 | b2bc57a | 2021-06-24 07:00:16 +0000 | [diff] [blame] | 113 | set(DAWN_SUPPORTS_GLFW_FOR_WINDOWING ON) |
| 114 | endif() |
| 115 | |
| 116 | # Current examples are depend on GLFW |
| 117 | if (DAWN_SUPPORTS_GLFW_FOR_WINDOWING) |
Ben Clayton | a675075 | 2022-02-04 18:35:55 +0000 | [diff] [blame] | 118 | set(BUILD_SAMPLES ON) |
陈俊嘉 | b2bc57a | 2021-06-24 07:00:16 +0000 | [diff] [blame] | 119 | endif() |
| 120 | |
Ben Clayton | 96e245e | 2022-04-08 18:08:36 +0000 | [diff] [blame] | 121 | option_if_not_defined(DAWN_ENABLE_ASAN "Enable address sanitizer" OFF) |
Ben Clayton | d0ccb1a | 2022-08-19 21:33:01 +0000 | [diff] [blame] | 122 | option_if_not_defined(DAWN_ENABLE_TSAN "Enable thread sanitizer" OFF) |
| 123 | option_if_not_defined(DAWN_ENABLE_MSAN "Enable memory sanitizer" OFF) |
Ben Clayton | 96e245e | 2022-04-08 18:08:36 +0000 | [diff] [blame] | 124 | option_if_not_defined(DAWN_ENABLE_UBSAN "Enable undefined behaviour sanitizer" OFF) |
| 125 | |
Peng Huang | 5c2f167 | 2023-05-01 23:05:42 +0000 | [diff] [blame] | 126 | option_if_not_defined(DAWN_ENABLE_D3D11 "Enable compilation of the D3D11 backend" ${ENABLE_D3D11}) |
Ben Clayton | 30eeac7 | 2021-09-24 10:38:18 +0000 | [diff] [blame] | 127 | option_if_not_defined(DAWN_ENABLE_D3D12 "Enable compilation of the D3D12 backend" ${ENABLE_D3D12}) |
| 128 | option_if_not_defined(DAWN_ENABLE_METAL "Enable compilation of the Metal backend" ${ENABLE_METAL}) |
| 129 | option_if_not_defined(DAWN_ENABLE_NULL "Enable compilation of the Null backend" ON) |
| 130 | option_if_not_defined(DAWN_ENABLE_DESKTOP_GL "Enable compilation of the OpenGL backend" ${ENABLE_DESKTOP_GL}) |
| 131 | option_if_not_defined(DAWN_ENABLE_OPENGLES "Enable compilation of the OpenGL ES backend" ${ENABLE_OPENGLES}) |
| 132 | option_if_not_defined(DAWN_ENABLE_VULKAN "Enable compilation of the Vulkan backend" ${ENABLE_VULKAN}) |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 133 | |
Ben Clayton | 30eeac7 | 2021-09-24 10:38:18 +0000 | [diff] [blame] | 134 | option_if_not_defined(DAWN_ALWAYS_ASSERT "Enable assertions on all build types" OFF) |
Corentin Wallez | 2e22d92 | 2022-06-01 09:30:50 +0000 | [diff] [blame] | 135 | option_if_not_defined(DAWN_USE_WAYLAND "Enable support for Wayland surface" ${USE_WAYLAND}) |
Ben Clayton | 30eeac7 | 2021-09-24 10:38:18 +0000 | [diff] [blame] | 136 | option_if_not_defined(DAWN_USE_X11 "Enable support for X11 surface" ${USE_X11}) |
Erin Melucci | 38b58e4 | 2023-06-14 16:45:33 +0000 | [diff] [blame] | 137 | option_if_not_defined(DAWN_USE_GLFW "Enable compilation of the GLFW windowing utils" ${DAWN_SUPPORTS_GLFW_FOR_WINDOWING}) |
Stephen Gutekanst | 5562370 | 2023-07-01 11:43:55 +0000 | [diff] [blame] | 138 | option_if_not_defined(DAWN_USE_WINDOWS_UI "Enable support for Windows UI surface" ${USE_WINDOWS_UI}) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 139 | |
Ben Clayton | a675075 | 2022-02-04 18:35:55 +0000 | [diff] [blame] | 140 | option_if_not_defined(DAWN_BUILD_SAMPLES "Enables building Dawn's samples" ${BUILD_SAMPLES}) |
Ben Clayton | affb7a3 | 2021-09-28 11:14:42 +0000 | [diff] [blame] | 141 | option_if_not_defined(DAWN_BUILD_NODE_BINDINGS "Enables building Dawn's NodeJS bindings" OFF) |
Corentin Wallez | be352ea | 2022-04-11 16:48:43 +0000 | [diff] [blame] | 142 | option_if_not_defined(DAWN_ENABLE_SWIFTSHADER "Enables building Swiftshader as part of the build and Vulkan adapter discovery" OFF) |
Austin Eng | 6a7bba5 | 2023-04-17 18:11:51 +0000 | [diff] [blame] | 143 | option_if_not_defined(DAWN_BUILD_BENCHMARKS "Build Dawn benchmarks" OFF) |
Ben Clayton | affb7a3 | 2021-09-28 11:14:42 +0000 | [diff] [blame] | 144 | |
| 145 | option_if_not_defined(DAWN_ENABLE_PIC "Build with Position-Independent-Code enabled" OFF) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 146 | |
Ben Clayton | e38993f | 2022-12-10 00:15:57 +0000 | [diff] [blame] | 147 | option_if_not_defined(DAWN_EMIT_COVERAGE "Emit code coverage information" OFF) |
Ben Clayton | f927bcb | 2022-12-12 21:21:54 +0000 | [diff] [blame] | 148 | set_if_not_defined(LLVM_SOURCE_DIR "${Dawn_LLVM_SOURCE_DIR}" "Directory to an LLVM source checkout. Required to build turbo-cov") |
Ben Clayton | e38993f | 2022-12-10 00:15:57 +0000 | [diff] [blame] | 149 | |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 150 | if (DAWN_ENABLE_OPENGLES OR DAWN_ENABLE_DESKTOP_GL) |
| 151 | set(TINT_DEFAULT_GLSL ON) |
| 152 | else() |
| 153 | set(TINT_DEFAULT_GLSL OFF) |
| 154 | endif() |
| 155 | |
| 156 | option_if_not_defined(TINT_BUILD_SAMPLES "Build samples" ${DAWN_BUILD_SAMPLES}) |
| 157 | option_if_not_defined(TINT_BUILD_DOCS "Build documentation" ON) |
| 158 | option_if_not_defined(TINT_DOCS_WARN_AS_ERROR "When building documentation, treat warnings as errors" OFF) |
| 159 | |
Erin Melucci | 38b58e4 | 2023-06-14 16:45:33 +0000 | [diff] [blame] | 160 | if (NOT DAWN_USE_GLFW AND (TINT_BUILD_SAMPLES OR DAWN_BUILD_SAMPLES)) |
| 161 | message(SEND_ERROR "Dawn samples require GLFW") |
| 162 | endif() |
| 163 | |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 164 | option_if_not_defined(TINT_BUILD_SPV_READER "Build the SPIR-V input reader" ${DAWN_ENABLE_VULKAN}) |
| 165 | option_if_not_defined(TINT_BUILD_WGSL_READER "Build the WGSL input reader" ON) |
| 166 | option_if_not_defined(TINT_BUILD_GLSL_WRITER "Build the GLSL output writer" ${TINT_DEFAULT_GLSL}) |
| 167 | option_if_not_defined(TINT_BUILD_HLSL_WRITER "Build the HLSL output writer" ${DAWN_ENABLE_D3D12}) |
| 168 | option_if_not_defined(TINT_BUILD_MSL_WRITER "Build the MSL output writer" ${DAWN_ENABLE_METAL}) |
| 169 | option_if_not_defined(TINT_BUILD_SPV_WRITER "Build the SPIR-V output writer" ${DAWN_ENABLE_VULKAN}) |
| 170 | option_if_not_defined(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON) |
| 171 | |
dan sinclair | 0917fbb | 2023-03-07 18:28:38 +0000 | [diff] [blame] | 172 | option_if_not_defined(TINT_BUILD_SYNTAX_TREE_WRITER "Build the syntax tree writer" OFF) |
dan sinclair | 9261261 | 2022-11-01 18:15:50 +0000 | [diff] [blame] | 173 | option_if_not_defined(TINT_BUILD_IR "Build the IR" ON) |
dan sinclair | c22b8b9d | 2022-11-01 17:02:31 +0000 | [diff] [blame] | 174 | |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 175 | option_if_not_defined(TINT_BUILD_FUZZERS "Build fuzzers" OFF) |
| 176 | option_if_not_defined(TINT_BUILD_SPIRV_TOOLS_FUZZER "Build SPIRV-Tools fuzzer" OFF) |
| 177 | option_if_not_defined(TINT_BUILD_AST_FUZZER "Build AST fuzzer" OFF) |
| 178 | option_if_not_defined(TINT_BUILD_REGEX_FUZZER "Build regex fuzzer" OFF) |
Austin Eng | 6a7bba5 | 2023-04-17 18:11:51 +0000 | [diff] [blame] | 179 | option_if_not_defined(TINT_BUILD_BENCHMARKS "Build Tint benchmarks" OFF) |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 180 | option_if_not_defined(TINT_BUILD_TESTS "Build tests" ON) |
| 181 | option_if_not_defined(TINT_BUILD_AS_OTHER_OS "Override OS detection to force building of *_other.cc files" OFF) |
| 182 | option_if_not_defined(TINT_BUILD_REMOTE_COMPILE "Build the remote-compile tool for validating shaders on a remote machine" OFF) |
| 183 | |
Ben Clayton | 8fc9b86 | 2023-04-19 15:03:19 +0000 | [diff] [blame] | 184 | set_if_not_defined(TINT_EXTERNAL_BENCHMARK_CORPUS_DIR "" "Directory that holds a corpus of external shaders to benchmark.") |
| 185 | |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 186 | option_if_not_defined(TINT_ENABLE_BREAK_IN_DEBUGGER "Enable tint::debugger::Break()" OFF) |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 187 | option_if_not_defined(TINT_CHECK_CHROMIUM_STYLE "Check for [chromium-style] issues during build" OFF) |
Ben Clayton | f2b86aa | 2022-12-13 14:46:02 +0000 | [diff] [blame] | 188 | option_if_not_defined(TINT_RANDOMIZE_HASHES "Randomize the hash seed value to detect non-deterministic output" OFF) |
Corentin Wallez | e557087 | 2020-10-20 14:26:10 +0000 | [diff] [blame] | 189 | |
Brandon Jones | a04663c | 2021-09-23 20:36:03 +0000 | [diff] [blame] | 190 | # Recommended setting for compability with future abseil releases. |
| 191 | set(ABSL_PROPAGATE_CXX_STD ON) |
Brandon Jones | a04663c | 2021-09-23 20:36:03 +0000 | [diff] [blame] | 192 | |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 193 | set_if_not_defined(DAWN_THIRD_PARTY_DIR "${Dawn_SOURCE_DIR}/third_party" "Directory in which to find third-party dependencies.") |
dan sinclair | c1f6dbd | 2023-04-11 15:45:18 +0000 | [diff] [blame] | 194 | set_if_not_defined(DAWN_VULKAN_DEPS_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-deps" "Directory in which to find vulkan-deps") |
| 195 | |
Ben Clayton | 30eeac7 | 2021-09-24 10:38:18 +0000 | [diff] [blame] | 196 | set_if_not_defined(DAWN_ABSEIL_DIR "${DAWN_THIRD_PARTY_DIR}/abseil-cpp" "Directory in which to find Abseil") |
| 197 | set_if_not_defined(DAWN_GLFW_DIR "${DAWN_THIRD_PARTY_DIR}/glfw" "Directory in which to find GLFW") |
Ben Clayton | 30eeac7 | 2021-09-24 10:38:18 +0000 | [diff] [blame] | 198 | set_if_not_defined(DAWN_JINJA2_DIR "${DAWN_THIRD_PARTY_DIR}/jinja2" "Directory in which to find Jinja2") |
dan sinclair | 6b67a90 | 2023-04-07 07:52:36 +0000 | [diff] [blame] | 199 | set_if_not_defined(DAWN_MARKUPSAFE_DIR "${DAWN_THIRD_PARTY_DIR}/markupsafe" "Directory in which to find MarkupSafe") |
Stephen White | 9434949 | 2022-06-29 15:29:41 +0000 | [diff] [blame] | 200 | set_if_not_defined(DAWN_KHRONOS_DIR "${DAWN_THIRD_PARTY_DIR}/khronos" "Directory in which to find Khronos GL headers") |
Corentin Wallez | be352ea | 2022-04-11 16:48:43 +0000 | [diff] [blame] | 201 | set_if_not_defined(DAWN_SWIFTSHADER_DIR "${DAWN_THIRD_PARTY_DIR}/swiftshader" "Directory in which to find swiftshader") |
dan sinclair | c1f6dbd | 2023-04-11 15:45:18 +0000 | [diff] [blame] | 202 | |
| 203 | set_if_not_defined(DAWN_SPIRV_TOOLS_DIR "${DAWN_VULKAN_DEPS_DIR}/spirv-tools/src" "Directory in which to find SPIRV-Tools") |
| 204 | set_if_not_defined(DAWN_SPIRV_HEADERS_DIR "${DAWN_VULKAN_DEPS_DIR}/spirv-headers/src" "Directory in which to find SPIRV-Headers") |
Loko Kung | 23d09c6 | 2022-04-09 00:10:08 +0000 | [diff] [blame] | 205 | set_if_not_defined(DAWN_VULKAN_HEADERS_DIR "${DAWN_VULKAN_DEPS_DIR}/vulkan-headers/src" "Directory in which to find Vulkan-Headers") |
Loko Kung | 83a5d52 | 2022-04-13 19:14:46 +0000 | [diff] [blame] | 206 | set_if_not_defined(DAWN_VULKAN_TOOLS_DIR "${DAWN_VULKAN_DEPS_DIR}/vulkan-tools/src" "Directory in which to find Vulkan-Tools") |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 207 | |
Ben Clayton | affb7a3 | 2021-09-28 11:14:42 +0000 | [diff] [blame] | 208 | # Dependencies for DAWN_BUILD_NODE_BINDINGS |
| 209 | set_if_not_defined(NODE_ADDON_API_DIR "${DAWN_THIRD_PARTY_DIR}/node-addon-api" "Directory in which to find node-addon-api") |
Ben Clayton | 72e3ba6 | 2021-09-30 18:04:01 +0000 | [diff] [blame] | 210 | set_if_not_defined(NODE_API_HEADERS_DIR "${DAWN_THIRD_PARTY_DIR}/node-api-headers" "Directory in which to find node-api-headers") |
Ben Clayton | affb7a3 | 2021-09-28 11:14:42 +0000 | [diff] [blame] | 211 | set_if_not_defined(WEBGPU_IDL_PATH "${DAWN_THIRD_PARTY_DIR}/gpuweb/webgpu.idl" "Path to the webgpu.idl definition file") |
Austin Eng | 4948c81 | 2021-10-15 14:28:32 +0000 | [diff] [blame] | 212 | set_if_not_defined(GO_EXECUTABLE "go" "Golang executable for running the IDL generator") |
Ben Clayton | affb7a3 | 2021-09-28 11:14:42 +0000 | [diff] [blame] | 213 | |
Elie Michel | 9ae8ed2 | 2023-05-12 20:19:41 +0000 | [diff] [blame] | 214 | option_if_not_defined(DAWN_FETCH_DEPENDENCIES "Use fetch_dawn_dependencies.py as an alternative to using depot_tools" OFF) |
| 215 | |
Sergey Karchevsky | 3a75b1c | 2021-06-30 15:06:43 +0000 | [diff] [blame] | 216 | # Much of the backend code is shared among desktop OpenGL and OpenGL ES |
| 217 | if (${DAWN_ENABLE_DESKTOP_GL} OR ${DAWN_ENABLE_OPENGLES}) |
| 218 | set(DAWN_ENABLE_OPENGL ON) |
| 219 | endif() |
| 220 | |
Ben Clayton | affb7a3 | 2021-09-28 11:14:42 +0000 | [diff] [blame] | 221 | if(DAWN_ENABLE_PIC) |
| 222 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
| 223 | endif() |
| 224 | |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 225 | if (${TINT_BUILD_SPIRV_TOOLS_FUZZER}) |
| 226 | message(STATUS "TINT_BUILD_SPIRV_TOOLS_FUZZER is ON - setting |
| 227 | TINT_BUILD_FUZZERS |
| 228 | TINT_BUILD_SPV_READER |
| 229 | TINT_BUILD_SPV_WRITER |
| 230 | TINT_BUILD_WGSL_READER |
| 231 | TINT_BUILD_WGSL_WRITER |
| 232 | TINT_BUILD_GLSL_WRITER |
| 233 | TINT_BUILD_HLSL_WRITER |
| 234 | TINT_BUILD_MSL_WRITER to ON") |
| 235 | set(TINT_BUILD_FUZZERS ON CACHE BOOL "Build tint fuzzers" FORCE) |
| 236 | set(TINT_BUILD_SPV_READER ON CACHE BOOL "Build SPIR-V reader" FORCE) |
| 237 | set(TINT_BUILD_SPV_WRITER ON CACHE BOOL "Build SPIR-V writer" FORCE) |
| 238 | set(TINT_BUILD_WGSL_READER ON CACHE BOOL "Build WGSL reader" FORCE) |
| 239 | set(TINT_BUILD_WGSL_WRITER ON CACHE BOOL "Build WGSL writer" FORCE) |
| 240 | set(TINT_BUILD_GLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE) |
| 241 | set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE) |
| 242 | set(TINT_BUILD_MSL_WRITER ON CACHE BOOL "Build MSL writer" FORCE) |
| 243 | endif() |
| 244 | |
| 245 | if (${TINT_BUILD_AST_FUZZER}) |
| 246 | message(STATUS "TINT_BUILD_AST_FUZZER is ON - setting |
| 247 | TINT_BUILD_FUZZERS |
| 248 | TINT_BUILD_WGSL_READER |
| 249 | TINT_BUILD_WGSL_WRITER |
| 250 | TINT_BUILD_SPV_WRITER |
| 251 | TINT_BUILD_MSL_WRITER |
| 252 | TINT_BUILD_GLSL_WRITER |
| 253 | TINT_BUILD_HLSL_WRITER to ON") |
| 254 | set(TINT_BUILD_FUZZERS ON CACHE BOOL "Build tint fuzzers" FORCE) |
| 255 | set(TINT_BUILD_WGSL_READER ON CACHE BOOL "Build WGSL reader" FORCE) |
| 256 | set(TINT_BUILD_WGSL_WRITER ON CACHE BOOL "Build WGSL writer" FORCE) |
| 257 | set(TINT_BUILD_SPV_WRITER ON CACHE BOOL "Build SPIR-V writer" FORCE) |
| 258 | set(TINT_BUILD_MSL_WRITER ON CACHE BOOL "Build MSL writer" FORCE) |
| 259 | set(TINT_BUILD_GLSL_WRITER ON CACHE BOOL "Build GLSL writer" FORCE) |
| 260 | set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE) |
| 261 | endif() |
| 262 | |
| 263 | if (${TINT_BUILD_REGEX_FUZZER}) |
| 264 | message(STATUS "TINT_BUILD_REGEX_FUZZER is ON - setting |
| 265 | TINT_BUILD_FUZZERS |
| 266 | TINT_BUILD_WGSL_READER |
| 267 | TINT_BUILD_WGSL_WRITER |
| 268 | TINT_BUILD_SPV_WRITER |
| 269 | TINT_BUILD_MSL_WRITER |
| 270 | TINT_BUILD_GLSL_WRITER |
| 271 | TINT_BUILD_HLSL_WRITER to ON") |
| 272 | set(TINT_BUILD_FUZZERS ON CACHE BOOL "Build tint fuzzers" FORCE) |
| 273 | set(TINT_BUILD_WGSL_READER ON CACHE BOOL "Build WGSL reader" FORCE) |
| 274 | set(TINT_BUILD_WGSL_WRITER ON CACHE BOOL "Build WGSL writer" FORCE) |
| 275 | set(TINT_BUILD_SPV_WRITER ON CACHE BOOL "Build SPIR-V writer" FORCE) |
| 276 | set(TINT_BUILD_MSL_WRITER ON CACHE BOOL "Build MSL writer" FORCE) |
| 277 | set(TINT_BUILD_GLSL_WRITER ON CACHE BOOL "Build GLSL writer" FORCE) |
| 278 | set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE) |
| 279 | endif() |
| 280 | |
Peng Huang | 5c2f167 | 2023-05-01 23:05:42 +0000 | [diff] [blame] | 281 | message(STATUS "Dawn build D3D11 backend: ${DAWN_ENABLE_D3D11}") |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 282 | message(STATUS "Dawn build D3D12 backend: ${DAWN_ENABLE_D3D12}") |
| 283 | message(STATUS "Dawn build Metal backend: ${DAWN_ENABLE_METAL}") |
| 284 | message(STATUS "Dawn build Vulkan backend: ${DAWN_ENABLE_VULKAN}") |
| 285 | message(STATUS "Dawn build OpenGL backend: ${DAWN_ENABLE_DESKTOP_GL}") |
| 286 | message(STATUS "Dawn build OpenGL ES backend: ${DAWN_ENABLE_OPENGLES}") |
| 287 | message(STATUS "Dawn build Null backend: ${DAWN_ENABLE_NULL}") |
| 288 | |
| 289 | message(STATUS "Dawn build with asserts in all configurations: ${DAWN_ALWAYS_ASSERT}") |
| 290 | message(STATUS "Dawn build Wayland support: ${DAWN_USE_WAYLAND}") |
| 291 | message(STATUS "Dawn build X11 support: ${DAWN_USE_X11}") |
Stephen Gutekanst | 5562370 | 2023-07-01 11:43:55 +0000 | [diff] [blame] | 292 | message(STATUS "Dawn build Windows UI support: ${DAWN_USE_WINDOWS_UI}") |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 293 | |
| 294 | message(STATUS "Dawn build samples: ${DAWN_BUILD_SAMPLES}") |
| 295 | message(STATUS "Dawn build Node bindings: ${DAWN_BUILD_NODE_BINDINGS}") |
| 296 | message(STATUS "Dawn build Swiftshader: ${DAWN_ENABLE_SWIFTSHADER}") |
Austin Eng | 6a7bba5 | 2023-04-17 18:11:51 +0000 | [diff] [blame] | 297 | message(STATUS "Dawn build benchmarks: ${DAWN_BUILD_BENCHMARKS}") |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 298 | |
| 299 | message(STATUS "Dawn build PIC: ${DAWN_ENABLE_PIC}") |
| 300 | |
| 301 | message(STATUS "Dawn build with ASAN: ${DAWN_ENABLE_ASAN}") |
Ben Clayton | d0ccb1a | 2022-08-19 21:33:01 +0000 | [diff] [blame] | 302 | message(STATUS "Dawn build with TSAN: ${DAWN_ENABLE_TSAN}") |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 303 | message(STATUS "Dawn build with MSAN: ${DAWN_ENABLE_MSAN}") |
| 304 | message(STATUS "Dawn build with UBSAN: ${DAWN_ENABLE_UBSAN}") |
| 305 | |
| 306 | message(STATUS "Tint build samples: ${TINT_BUILD_SAMPLES}") |
| 307 | message(STATUS "Tint build docs: ${TINT_BUILD_DOCS}") |
| 308 | message(STATUS "Tint build docs with warn as error: ${TINT_DOCS_WARN_AS_ERROR}") |
| 309 | message(STATUS "Tint build SPIR-V reader: ${TINT_BUILD_SPV_READER}") |
| 310 | message(STATUS "Tint build WGSL reader: ${TINT_BUILD_WGSL_READER}") |
| 311 | message(STATUS "Tint build GLSL writer: ${TINT_BUILD_GLSL_WRITER}") |
| 312 | message(STATUS "Tint build HLSL writer: ${TINT_BUILD_HLSL_WRITER}") |
| 313 | message(STATUS "Tint build MSL writer: ${TINT_BUILD_MSL_WRITER}") |
| 314 | message(STATUS "Tint build SPIR-V writer: ${TINT_BUILD_SPV_WRITER}") |
| 315 | message(STATUS "Tint build WGSL writer: ${TINT_BUILD_WGSL_WRITER}") |
dan sinclair | 0917fbb | 2023-03-07 18:28:38 +0000 | [diff] [blame] | 316 | message(STATUS "Tint build Syntax Tree writer: ${TINT_BUILD_SYNTAX_TREE_WRITER}") |
dan sinclair | 9261261 | 2022-11-01 18:15:50 +0000 | [diff] [blame] | 317 | message(STATUS "Tint build IR: ${TINT_BUILD_IR}") |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 318 | message(STATUS "Tint build fuzzers: ${TINT_BUILD_FUZZERS}") |
| 319 | message(STATUS "Tint build SPIRV-Tools fuzzer: ${TINT_BUILD_SPIRV_TOOLS_FUZZER}") |
| 320 | message(STATUS "Tint build AST fuzzer: ${TINT_BUILD_AST_FUZZER}") |
| 321 | message(STATUS "Tint build regex fuzzer: ${TINT_BUILD_REGEX_FUZZER}") |
| 322 | message(STATUS "Tint build benchmarks: ${TINT_BUILD_BENCHMARKS}") |
| 323 | message(STATUS "Tint build tests: ${TINT_BUILD_TESTS}") |
| 324 | message(STATUS "Tint build checking [chromium-style]: ${TINT_CHECK_CHROMIUM_STYLE}") |
| 325 | message(STATUS "Tint build remote-compile tool: ${TINT_BUILD_REMOTE_COMPILE}") |
Ben Clayton | 8fc9b86 | 2023-04-19 15:03:19 +0000 | [diff] [blame] | 326 | message(STATUS "Tint external benchmark corpus dir: ${TINT_EXTERNAL_BENCHMARK_CORPUS_DIR}") |
| 327 | |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 328 | |
| 329 | if (NOT ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS} STREQUAL "") |
| 330 | message(STATUS "Using provided LIB_FUZZING_ENGINE options: ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS}") |
| 331 | endif() |
| 332 | |
| 333 | message(STATUS "Using python3") |
| 334 | find_package(PythonInterp 3 REQUIRED) |
| 335 | |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 336 | ################################################################################ |
Ben Clayton | 96e245e | 2022-04-08 18:08:36 +0000 | [diff] [blame] | 337 | # common_compile_options - sets compiler and linker options common for dawn and |
| 338 | # tint on the given target |
| 339 | ################################################################################ |
| 340 | function(common_compile_options TARGET) |
| 341 | if (COMPILER_IS_LIKE_GNU) |
| 342 | target_compile_options(${TARGET} PRIVATE |
| 343 | -fno-exceptions |
| 344 | -fno-rtti |
dan sinclair | cf2456b | 2023-01-07 23:09:14 +0000 | [diff] [blame] | 345 | |
| 346 | -Wno-deprecated-builtins |
dan sinclair | 07c32cb | 2023-01-09 15:10:33 +0000 | [diff] [blame] | 347 | -Wno-unknown-warning-option |
Ben Clayton | 96e245e | 2022-04-08 18:08:36 +0000 | [diff] [blame] | 348 | ) |
| 349 | |
| 350 | if (${DAWN_ENABLE_MSAN}) |
Ben Clayton | d0ccb1a | 2022-08-19 21:33:01 +0000 | [diff] [blame] | 351 | target_compile_options(${TARGET} PUBLIC -fsanitize=memory) |
| 352 | target_link_options(${TARGET} PUBLIC -fsanitize=memory) |
Ben Clayton | 96e245e | 2022-04-08 18:08:36 +0000 | [diff] [blame] | 353 | elseif (${DAWN_ENABLE_ASAN}) |
Ben Clayton | d0ccb1a | 2022-08-19 21:33:01 +0000 | [diff] [blame] | 354 | target_compile_options(${TARGET} PUBLIC -fsanitize=address) |
| 355 | target_link_options(${TARGET} PUBLIC -fsanitize=address) |
| 356 | elseif (${DAWN_ENABLE_TSAN}) |
| 357 | target_compile_options(${TARGET} PUBLIC -fsanitize=thread) |
| 358 | target_link_options(${TARGET} PUBLIC -fsanitize=thread) |
Ben Clayton | 96e245e | 2022-04-08 18:08:36 +0000 | [diff] [blame] | 359 | elseif (${DAWN_ENABLE_UBSAN}) |
Antonio Maiorano | deb2ec9 | 2023-03-24 18:44:02 +0000 | [diff] [blame] | 360 | target_compile_options(${TARGET} PUBLIC -fsanitize=undefined -fsanitize=float-divide-by-zero) |
| 361 | target_link_options(${TARGET} PUBLIC -fsanitize=undefined -fsanitize=float-divide-by-zero) |
Ben Clayton | 96e245e | 2022-04-08 18:08:36 +0000 | [diff] [blame] | 362 | endif() |
| 363 | endif(COMPILER_IS_LIKE_GNU) |
Seto | c692720 | 2022-09-14 16:41:07 +0000 | [diff] [blame] | 364 | |
| 365 | if(MSVC) |
| 366 | target_compile_options(${TARGET} PUBLIC /utf-8) |
| 367 | endif() |
Ben Clayton | e38993f | 2022-12-10 00:15:57 +0000 | [diff] [blame] | 368 | |
| 369 | if (DAWN_EMIT_COVERAGE) |
Ben Clayton | 54264d3 | 2023-01-10 21:55:43 +0000 | [diff] [blame] | 370 | target_compile_definitions(${TARGET} PRIVATE "DAWN_EMIT_COVERAGE") |
Ben Clayton | e38993f | 2022-12-10 00:15:57 +0000 | [diff] [blame] | 371 | if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") |
| 372 | target_compile_options(${TARGET} PRIVATE "--coverage") |
| 373 | target_link_options(${TARGET} PRIVATE "gcov") |
Ben Clayton | 78e4530 | 2023-01-26 15:57:27 +0000 | [diff] [blame] | 374 | elseif(COMPILER_IS_CLANG OR COMPILER_IS_CLANG_CL) |
Ben Clayton | e38993f | 2022-12-10 00:15:57 +0000 | [diff] [blame] | 375 | target_compile_options(${TARGET} PRIVATE "-fprofile-instr-generate" "-fcoverage-mapping") |
| 376 | target_link_options(${TARGET} PRIVATE "-fprofile-instr-generate" "-fcoverage-mapping") |
| 377 | else() |
| 378 | message(FATAL_ERROR "Coverage generation not supported for the ${CMAKE_CXX_COMPILER_ID} toolchain") |
| 379 | endif() |
| 380 | endif(DAWN_EMIT_COVERAGE) |
Ben Clayton | 96e245e | 2022-04-08 18:08:36 +0000 | [diff] [blame] | 381 | endfunction() |
| 382 | |
Ben Clayton | d0ccb1a | 2022-08-19 21:33:01 +0000 | [diff] [blame] | 383 | if (${DAWN_ENABLE_TSAN}) |
| 384 | add_compile_options(-stdlib=libc++) |
| 385 | add_link_options(-stdlib=libc++) |
| 386 | endif() |
| 387 | |
Ben Clayton | 96e245e | 2022-04-08 18:08:36 +0000 | [diff] [blame] | 388 | ################################################################################ |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 389 | # Dawn's public and internal "configs" |
| 390 | ################################################################################ |
| 391 | |
Ben Clayton | 9418152 | 2022-11-09 20:55:33 +0000 | [diff] [blame] | 392 | set(IS_DEBUG_BUILD 0) |
| 393 | string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type) |
| 394 | if ((NOT ${build_type} STREQUAL "RELEASE") AND (NOT ${build_type} STREQUAL "RELWITHDEBINFO")) |
| 395 | set(IS_DEBUG_BUILD 1) |
| 396 | endif() |
| 397 | |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 398 | # The public config contains only the include paths for the Dawn headers. |
| 399 | add_library(dawn_public_config INTERFACE) |
| 400 | target_include_directories(dawn_public_config INTERFACE |
Ben Clayton | 9fb7a51 | 2022-02-04 18:18:18 +0000 | [diff] [blame] | 401 | "${DAWN_INCLUDE_DIR}" |
| 402 | "${DAWN_BUILD_GEN_DIR}/include" |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 403 | ) |
| 404 | |
| 405 | # The internal config conatins additional path but includes the dawn_public_config include paths |
| 406 | add_library(dawn_internal_config INTERFACE) |
| 407 | target_include_directories(dawn_internal_config INTERFACE |
| 408 | "${DAWN_SRC_DIR}" |
| 409 | "${DAWN_BUILD_GEN_DIR}/src" |
| 410 | ) |
| 411 | target_link_libraries(dawn_internal_config INTERFACE dawn_public_config) |
| 412 | |
| 413 | # Compile definitions for the internal config |
Ben Clayton | 9418152 | 2022-11-09 20:55:33 +0000 | [diff] [blame] | 414 | if (DAWN_ALWAYS_ASSERT OR IS_DEBUG_BUILD) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 415 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_ASSERTS") |
| 416 | endif() |
Peng Huang | 5c2f167 | 2023-05-01 23:05:42 +0000 | [diff] [blame] | 417 | if (DAWN_ENABLE_D3D11) |
| 418 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_D3D11") |
| 419 | endif() |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 420 | if (DAWN_ENABLE_D3D12) |
| 421 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_D3D12") |
| 422 | endif() |
| 423 | if (DAWN_ENABLE_METAL) |
| 424 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_METAL") |
| 425 | endif() |
| 426 | if (DAWN_ENABLE_NULL) |
| 427 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_NULL") |
| 428 | endif() |
Sergey Karchevsky | 3a75b1c | 2021-06-30 15:06:43 +0000 | [diff] [blame] | 429 | if (DAWN_ENABLE_DESKTOP_GL) |
| 430 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_DESKTOP_GL") |
| 431 | endif() |
| 432 | if (DAWN_ENABLE_OPENGLES) |
| 433 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_OPENGLES") |
| 434 | endif() |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 435 | if (DAWN_ENABLE_OPENGL) |
| 436 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_OPENGL") |
| 437 | endif() |
| 438 | if (DAWN_ENABLE_VULKAN) |
| 439 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_VULKAN") |
| 440 | endif() |
Corentin Wallez | 2e22d92 | 2022-06-01 09:30:50 +0000 | [diff] [blame] | 441 | if (DAWN_USE_WAYLAND) |
| 442 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_WAYLAND") |
| 443 | endif() |
Corentin Wallez | d353ca0 | 2020-02-18 02:12:35 +0000 | [diff] [blame] | 444 | if (DAWN_USE_X11) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 445 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_X11") |
| 446 | endif() |
Stephen Gutekanst | 5562370 | 2023-07-01 11:43:55 +0000 | [diff] [blame] | 447 | if (DAWN_USE_WINDOWS_UI) |
| 448 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_WINDOWS_UI") |
| 449 | endif() |
Corentin Wallez | 3346697 | 2020-02-24 13:27:28 +0000 | [diff] [blame] | 450 | if (WIN32) |
| 451 | target_compile_definitions(dawn_internal_config INTERFACE "NOMINMAX" "WIN32_LEAN_AND_MEAN") |
| 452 | endif() |
| 453 | |
Corentin Wallez | 7c8bc94 | 2022-01-05 09:26:46 +0000 | [diff] [blame] | 454 | set(CMAKE_CXX_STANDARD "17") |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 455 | |
| 456 | ################################################################################ |
Ryan Harrison | e87ac76 | 2022-04-06 15:37:27 -0400 | [diff] [blame] | 457 | # Tint |
| 458 | ################################################################################ |
| 459 | |
Alastair Donaldson | 6a1eb45 | 2021-09-02 23:49:25 +0000 | [diff] [blame] | 460 | set(TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS "" CACHE STRING "Used by OSS-Fuzz to control, via link options, which fuzzing engine should be used") |
| 461 | |
Ben Clayton | 54cfa0b | 2021-07-08 19:35:53 +0000 | [diff] [blame] | 462 | set(TINT_ROOT_SOURCE_DIR ${PROJECT_SOURCE_DIR}) |
| 463 | |
Antonio Maiorano | d600972 | 2021-03-17 13:32:54 +0000 | [diff] [blame] | 464 | # CMake < 3.15 sets /W3 in CMAKE_CXX_FLAGS. Remove it if it's there. |
| 465 | # See https://gitlab.kitware.com/cmake/cmake/-/issues/18317 |
| 466 | if (MSVC) |
Vasyl Teliman | 0b3611b | 2021-06-24 18:10:46 +0000 | [diff] [blame] | 467 | if (CMAKE_CXX_FLAGS MATCHES "/W3") |
| 468 | string(REPLACE "/W3" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") |
| 469 | endif() |
Antonio Maiorano | d600972 | 2021-03-17 13:32:54 +0000 | [diff] [blame] | 470 | endif() |
| 471 | |
Ryan Harrison | 563d3e9 | 2020-04-28 19:27:38 +0000 | [diff] [blame] | 472 | if (${TINT_CHECK_CHROMIUM_STYLE}) |
| 473 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -add-plugin -Xclang find-bad-constructs") |
| 474 | endif() |
| 475 | |
dan sinclair | 4b71b9e | 2020-03-18 14:08:48 +0000 | [diff] [blame] | 476 | if (${TINT_BUILD_SPV_READER}) |
Ryan Harrison | e87ac76 | 2022-04-06 15:37:27 -0400 | [diff] [blame] | 477 | include_directories("${DAWN_THIRD_PARTY_DIR}/vulkan-deps/spirv-tools/include") |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 478 | endif() |
| 479 | |
Antonio Maiorano | 88d3d2e | 2021-03-23 20:51:09 +0000 | [diff] [blame] | 480 | if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")) |
| 481 | set(COMPILER_IS_CLANG_CL TRUE) |
| 482 | endif() |
| 483 | |
Ben Clayton | 78e4530 | 2023-01-26 15:57:27 +0000 | [diff] [blame] | 484 | if((CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") OR |
Antonio Maiorano | 88d3d2e | 2021-03-23 20:51:09 +0000 | [diff] [blame] | 485 | ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND |
| 486 | (NOT COMPILER_IS_CLANG_CL))) |
Ben Clayton | 78e4530 | 2023-01-26 15:57:27 +0000 | [diff] [blame] | 487 | set(COMPILER_IS_CLANG TRUE) |
| 488 | endif() |
| 489 | |
| 490 | if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR COMPILER_IS_CLANG) |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 491 | set(COMPILER_IS_LIKE_GNU TRUE) |
| 492 | endif() |
| 493 | |
Antonio Maiorano | 88d3d2e | 2021-03-23 20:51:09 +0000 | [diff] [blame] | 494 | # Enable msbuild multiprocessor builds |
| 495 | if (MSVC AND NOT COMPILER_IS_CLANG_CL) |
| 496 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") |
| 497 | endif() |
| 498 | |
Ben Clayton | 7687ec1 | 2021-04-16 14:43:34 +0000 | [diff] [blame] | 499 | set(TINT_OS_CC_SUFFIX "other") |
| 500 | if (NOT TINT_BUILD_AS_OTHER_OS) |
| 501 | if(UNIX OR APPLE) |
| 502 | set(TINT_OS_CC_SUFFIX "posix") |
| 503 | set(TINT_OS_CC_SUFFIX "posix") |
| 504 | elseif(WIN32) |
| 505 | set(TINT_OS_CC_SUFFIX "windows") |
| 506 | set(TINT_OS_CC_SUFFIX "windows") |
| 507 | endif() |
| 508 | endif() |
| 509 | |
David Neto | 5b46d71 | 2020-06-26 22:29:27 +0000 | [diff] [blame] | 510 | if(${TINT_BUILD_DOCS}) |
| 511 | find_package(Doxygen) |
| 512 | if(DOXYGEN_FOUND) |
Antonio Maiorano | 6241f96 | 2021-06-25 14:00:36 +0000 | [diff] [blame] | 513 | set(DOXYGEN_WARN_AS_ERROR NO) |
| 514 | if(TINT_DOCS_WARN_AS_ERROR) |
| 515 | set(DOXYGEN_WARN_AS_ERROR YES) |
| 516 | endif() |
Antonio Maiorano | e25a8fc | 2021-06-25 14:53:06 +0000 | [diff] [blame] | 517 | |
| 518 | set(DOXYGEN_WARN_FORMAT "$file:$line: $text") |
| 519 | if (MSVC) |
| 520 | set(DOXYGEN_WARN_FORMAT "$file($line): $text") |
| 521 | endif() |
| 522 | |
David Neto | 5b46d71 | 2020-06-26 22:29:27 +0000 | [diff] [blame] | 523 | add_custom_target(tint-docs ALL |
Ben Clayton | 4ace822 | 2021-05-12 08:15:41 +0000 | [diff] [blame] | 524 | COMMAND ${CMAKE_COMMAND} |
Antonio Maiorano | 6241f96 | 2021-06-25 14:00:36 +0000 | [diff] [blame] | 525 | -E env |
| 526 | "DOXYGEN_OUTPUT_DIRECTORY=${CMAKE_BINARY_DIR}/docs" |
| 527 | "DOXYGEN_WARN_AS_ERROR=${DOXYGEN_WARN_AS_ERROR}" |
Antonio Maiorano | e25a8fc | 2021-06-25 14:53:06 +0000 | [diff] [blame] | 528 | "DOXYGEN_WARN_FORMAT=${DOXYGEN_WARN_FORMAT}" |
Ben Clayton | 4ace822 | 2021-05-12 08:15:41 +0000 | [diff] [blame] | 529 | ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile |
David Neto | 5b46d71 | 2020-06-26 22:29:27 +0000 | [diff] [blame] | 530 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} |
| 531 | COMMENT "Generating API documentation" |
| 532 | VERBATIM) |
| 533 | else() |
| 534 | message("Doxygen not found. Skipping documentation") |
| 535 | endif(DOXYGEN_FOUND) |
dan sinclair | b0391c6f | 2020-07-15 20:54:48 +0000 | [diff] [blame] | 536 | endif() |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 537 | |
Ben Clayton | be2362b | 2022-01-18 18:58:16 +0000 | [diff] [blame] | 538 | function(tint_core_compile_options TARGET) |
Ben Clayton | 54cfa0b | 2021-07-08 19:35:53 +0000 | [diff] [blame] | 539 | target_include_directories(${TARGET} PUBLIC "${TINT_ROOT_SOURCE_DIR}") |
| 540 | target_include_directories(${TARGET} PUBLIC "${TINT_ROOT_SOURCE_DIR}/include") |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 541 | |
dan sinclair | f6fdcb1 | 2020-10-23 17:04:10 +0000 | [diff] [blame] | 542 | if (${TINT_BUILD_SPV_READER} OR ${TINT_BUILD_SPV_WRITER}) |
| 543 | target_include_directories(${TARGET} PUBLIC |
Ryan Harrison | e87ac76 | 2022-04-06 15:37:27 -0400 | [diff] [blame] | 544 | "${DAWN_THIRD_PARTY_DIR}/spirv-headers/include") |
dan sinclair | f6fdcb1 | 2020-10-23 17:04:10 +0000 | [diff] [blame] | 545 | endif() |
| 546 | |
Ben Clayton | be2362b | 2022-01-18 18:58:16 +0000 | [diff] [blame] | 547 | target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_SPV_READER=$<BOOL:${TINT_BUILD_SPV_READER}>) |
| 548 | target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_WGSL_READER=$<BOOL:${TINT_BUILD_WGSL_READER}>) |
| 549 | target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_GLSL_WRITER=$<BOOL:${TINT_BUILD_GLSL_WRITER}>) |
| 550 | target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_HLSL_WRITER=$<BOOL:${TINT_BUILD_HLSL_WRITER}>) |
| 551 | target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_MSL_WRITER=$<BOOL:${TINT_BUILD_MSL_WRITER}>) |
| 552 | target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_SPV_WRITER=$<BOOL:${TINT_BUILD_SPV_WRITER}>) |
| 553 | target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_WGSL_WRITER=$<BOOL:${TINT_BUILD_WGSL_WRITER}>) |
dan sinclair | 0917fbb | 2023-03-07 18:28:38 +0000 | [diff] [blame] | 554 | target_compile_definitions(${TARGET} PUBLIC |
| 555 | -DTINT_BUILD_SYNTAX_TREE_WRITER=$<BOOL:${TINT_BUILD_SYNTAX_TREE_WRITER}>) |
dan sinclair | 9261261 | 2022-11-01 18:15:50 +0000 | [diff] [blame] | 556 | target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_IR=$<BOOL:${TINT_BUILD_IR}>) |
Ben Clayton | be2362b | 2022-01-18 18:58:16 +0000 | [diff] [blame] | 557 | |
Ben Clayton | 96e245e | 2022-04-08 18:08:36 +0000 | [diff] [blame] | 558 | common_compile_options(${TARGET}) |
Ben Clayton | be2362b | 2022-01-18 18:58:16 +0000 | [diff] [blame] | 559 | endfunction() |
| 560 | |
| 561 | function(tint_default_compile_options TARGET) |
| 562 | tint_core_compile_options(${TARGET}) |
dan sinclair | 37dbf99 | 2020-03-11 18:43:12 +0000 | [diff] [blame] | 563 | |
Antonio Maiorano | 5bdece5 | 2021-04-27 19:24:47 +0000 | [diff] [blame] | 564 | set(COMMON_GNU_OPTIONS |
| 565 | -Wall |
| 566 | -Werror |
| 567 | -Wextra |
| 568 | -Wno-documentation-unknown-command |
| 569 | -Wno-padded |
| 570 | -Wno-switch-enum |
| 571 | -Wno-unknown-pragmas |
| 572 | ) |
| 573 | |
| 574 | set(COMMON_CLANG_OPTIONS |
| 575 | -Wno-c++98-compat |
| 576 | -Wno-c++98-compat-pedantic |
| 577 | -Wno-format-pedantic |
James Price | 79f0599 | 2022-11-23 15:50:49 +0000 | [diff] [blame] | 578 | -Wno-poison-system-directories |
Antonio Maiorano | 5bdece5 | 2021-04-27 19:24:47 +0000 | [diff] [blame] | 579 | -Wno-return-std-move-in-c++11 |
| 580 | -Wno-unknown-warning-option |
| 581 | -Wno-undefined-var-template |
dan sinclair | cf2456b | 2023-01-07 23:09:14 +0000 | [diff] [blame] | 582 | -Wno-unsafe-buffer-usage |
Antonio Maiorano | 5bdece5 | 2021-04-27 19:24:47 +0000 | [diff] [blame] | 583 | -Wno-used-but-marked-unused |
| 584 | -Weverything |
| 585 | ) |
| 586 | |
Ben Clayton | be2362b | 2022-01-18 18:58:16 +0000 | [diff] [blame] | 587 | if (COMPILER_IS_LIKE_GNU) |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 588 | target_compile_options(${TARGET} PRIVATE |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 589 | -pedantic-errors |
Antonio Maiorano | 5bdece5 | 2021-04-27 19:24:47 +0000 | [diff] [blame] | 590 | ${COMMON_GNU_OPTIONS} |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 591 | ) |
| 592 | |
Ben Clayton | 78e4530 | 2023-01-26 15:57:27 +0000 | [diff] [blame] | 593 | if (COMPILER_IS_CLANG) |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 594 | target_compile_options(${TARGET} PRIVATE |
Antonio Maiorano | 5bdece5 | 2021-04-27 19:24:47 +0000 | [diff] [blame] | 595 | ${COMMON_CLANG_OPTIONS} |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 596 | ) |
| 597 | endif() |
Ben Clayton | be2362b | 2022-01-18 18:58:16 +0000 | [diff] [blame] | 598 | endif(COMPILER_IS_LIKE_GNU) |
Ben Clayton | adb10d6 | 2020-10-27 21:04:59 +0000 | [diff] [blame] | 599 | |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 600 | if (MSVC) |
| 601 | # Specify /EHs for exception handling. |
| 602 | target_compile_options(${TARGET} PRIVATE |
| 603 | /bigobj |
| 604 | /EHsc |
Antonio Maiorano | ac39fb4 | 2021-03-16 15:05:33 +0000 | [diff] [blame] | 605 | /W4 |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 606 | /WX |
Ben Clayton | a62b5c8 | 2023-06-14 13:40:00 +0000 | [diff] [blame] | 607 | /wd4068 # unknown pragma |
| 608 | /wd4127 # conditional expression is constant |
| 609 | /wd4244 # 'conversion' conversion from 'type1' to 'type2', possible loss of data |
| 610 | /wd4267 # 'var' : conversion from 'size_t' to 'type', possible loss of data |
| 611 | /wd4324 # 'struct_name' : structure was padded due to __declspec(align()) |
| 612 | /wd4459 # declaration of 'identifier' hides global declaration |
| 613 | /wd4458 # declaration of 'identifier' hides class member |
| 614 | /wd4514 # 'function' : unreferenced inline function has been removed |
| 615 | /wd4571 # catch(...) semantics changed since Visual C++ 7.1; structured exceptions (SEH) are no longer caught |
| 616 | /wd4625 # 'derived class' : copy constructor was implicitly defined as deleted because a base class copy constructor is inaccessible or deleted |
| 617 | /wd4626 # 'derived class' : assignment operator was implicitly defined as deleted because a base class assignment operator is inaccessible or deleted |
| 618 | /wd4710 # 'function' : function not inlined |
| 619 | /wd4774 # 'function' : format string 'string' requires an argument of type 'type', but variadic argument number has type 'type' |
| 620 | /wd4820 # 'bytes' bytes padding added after construct 'member_name' |
| 621 | /wd5026 # 'type': move constructor was implicitly defined as deleted |
| 622 | /wd5027 # 'type': move assignment operator was implicitly defined as deleted |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 623 | ) |
Antonio Maiorano | 5bdece5 | 2021-04-27 19:24:47 +0000 | [diff] [blame] | 624 | |
| 625 | # When building with clang-cl on Windows, try to match our clang build |
| 626 | # options as much as possible. |
| 627 | if (COMPILER_IS_CLANG_CL) |
| 628 | target_compile_options(${TARGET} PRIVATE |
| 629 | ${COMMON_GNU_OPTIONS} |
| 630 | ${COMMON_CLANG_OPTIONS} |
| 631 | # Disable warnings that are usually disabled in downstream deps for |
| 632 | # gcc/clang, but aren't for clang-cl. |
| 633 | -Wno-global-constructors |
| 634 | -Wno-zero-as-null-pointer-constant |
| 635 | -Wno-shorten-64-to-32 |
Antonio Maiorano | c5f2fe4 | 2021-12-20 21:39:35 +0000 | [diff] [blame] | 636 | -Wno-shadow-field-in-constructor |
| 637 | -Wno-reserved-id-macro |
Antonio Maiorano | b79f51e | 2022-02-04 23:24:43 +0000 | [diff] [blame] | 638 | -Wno-language-extension-token |
Antonio Maiorano | 5bdece5 | 2021-04-27 19:24:47 +0000 | [diff] [blame] | 639 | ) |
| 640 | endif() |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 641 | endif() |
Ben Clayton | f2b86aa | 2022-12-13 14:46:02 +0000 | [diff] [blame] | 642 | |
| 643 | if (TINT_RANDOMIZE_HASHES) |
| 644 | if(NOT DEFINED TINT_HASH_SEED) |
| 645 | string(RANDOM LENGTH 16 ALPHABET "0123456789abcdef" seed) |
| 646 | set(TINT_HASH_SEED "0x${seed}" CACHE STRING "Tint hash seed value") |
| 647 | message("Using TINT_HASH_SEED: ${TINT_HASH_SEED}") |
| 648 | endif() |
| 649 | target_compile_definitions(${TARGET} PUBLIC "-DTINT_HASH_SEED=${TINT_HASH_SEED}") |
| 650 | endif() |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 651 | endfunction() |
| 652 | |
Ryan Harrison | e87ac76 | 2022-04-06 15:37:27 -0400 | [diff] [blame] | 653 | ################################################################################ |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 654 | # Run on all subdirectories |
| 655 | ################################################################################ |
| 656 | |
| 657 | add_subdirectory(third_party) |
James Price | 8d9adb0 | 2022-05-22 00:41:53 +0000 | [diff] [blame] | 658 | |
| 659 | # TODO(crbug.com/tint/455): Tint does not currently build with CMake when |
| 660 | # BUILD_SHARED_LIBS=1, so always build it as static for now. |
| 661 | set(BUILD_SHARED_LIBS_SAVED ${BUILD_SHARED_LIBS}) |
| 662 | set(BUILD_SHARED_LIBS 0) |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 663 | add_subdirectory(src/tint) |
James Price | 8d9adb0 | 2022-05-22 00:41:53 +0000 | [diff] [blame] | 664 | set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_SAVED}) |
| 665 | |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 666 | add_subdirectory(generator) |
| 667 | add_subdirectory(src/dawn) |
Ben Clayton | 7b77855 | 2022-02-04 18:59:15 +0000 | [diff] [blame] | 668 | |
| 669 | ################################################################################ |
| 670 | # Samples |
| 671 | ################################################################################ |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 672 | |
Antonio Maiorano | 0eaee0c | 2021-08-31 18:43:36 +0000 | [diff] [blame] | 673 | if (TINT_BUILD_SAMPLES) |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 674 | add_subdirectory(src/tint/cmd) |
Antonio Maiorano | 0eaee0c | 2021-08-31 18:43:36 +0000 | [diff] [blame] | 675 | endif() |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 676 | |
Antonio Maiorano | 0eaee0c | 2021-08-31 18:43:36 +0000 | [diff] [blame] | 677 | if (TINT_BUILD_FUZZERS) |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 678 | add_subdirectory(src/tint/fuzzers) |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 679 | endif() |
| 680 | |
dan sinclair | b595052 | 2020-03-19 13:03:35 +0000 | [diff] [blame] | 681 | add_custom_target(tint-lint |
| 682 | COMMAND ./tools/lint |
Ben Clayton | 54cfa0b | 2021-07-08 19:35:53 +0000 | [diff] [blame] | 683 | WORKING_DIRECTORY ${TINT_ROOT_SOURCE_DIR} |
dan sinclair | b595052 | 2020-03-19 13:03:35 +0000 | [diff] [blame] | 684 | COMMENT "Running linter" |
| 685 | VERBATIM) |
| 686 | |
| 687 | add_custom_target(tint-format |
| 688 | COMMAND ./tools/format |
Ben Clayton | 54cfa0b | 2021-07-08 19:35:53 +0000 | [diff] [blame] | 689 | WORKING_DIRECTORY ${TINT_ROOT_SOURCE_DIR} |
dan sinclair | b595052 | 2020-03-19 13:03:35 +0000 | [diff] [blame] | 690 | COMMENT "Running formatter" |
| 691 | VERBATIM) |
Ben Clayton | adb10d6 | 2020-10-27 21:04:59 +0000 | [diff] [blame] | 692 | |
Ben Clayton | 78e4530 | 2023-01-26 15:57:27 +0000 | [diff] [blame] | 693 | if (DAWN_EMIT_COVERAGE) |
| 694 | add_subdirectory(tools/src/cmd/turbo-cov) |
Ben Clayton | adb10d6 | 2020-10-27 21:04:59 +0000 | [diff] [blame] | 695 | |
Ben Clayton | 78e4530 | 2023-01-26 15:57:27 +0000 | [diff] [blame] | 696 | # The tint-generate-coverage target generates a lcov.info file at the project |
| 697 | # root, holding the code coverage for all the tint_unitests. |
Ben Clayton | adb10d6 | 2020-10-27 21:04:59 +0000 | [diff] [blame] | 698 | # This can be used by tools such as VSCode's Coverage Gutters extension to |
| 699 | # visualize code coverage in the editor. |
| 700 | get_filename_component(CLANG_BIN_DIR ${CMAKE_C_COMPILER} DIRECTORY) |
| 701 | set(PATH_WITH_CLANG "${CLANG_BIN_DIR}:$ENV{PATH}") |
| 702 | add_custom_target(tint-generate-coverage |
| 703 | COMMAND ${CMAKE_COMMAND} -E env PATH=${PATH_WITH_CLANG} ./tools/tint-generate-coverage $<TARGET_FILE:tint_unittests> |
| 704 | DEPENDS tint_unittests |
Ben Clayton | 54cfa0b | 2021-07-08 19:35:53 +0000 | [diff] [blame] | 705 | WORKING_DIRECTORY ${TINT_ROOT_SOURCE_DIR} |
Ben Clayton | adb10d6 | 2020-10-27 21:04:59 +0000 | [diff] [blame] | 706 | COMMENT "Generating tint coverage data" |
| 707 | VERBATIM) |
| 708 | endif() |
Ben Clayton | 54cfa0b | 2021-07-08 19:35:53 +0000 | [diff] [blame] | 709 | |
Antonio Maiorano | 0eaee0c | 2021-08-31 18:43:36 +0000 | [diff] [blame] | 710 | if (TINT_BUILD_REMOTE_COMPILE) |
| 711 | add_subdirectory(tools/src/cmd/remote-compile) |
Ben Clayton | 54cfa0b | 2021-07-08 19:35:53 +0000 | [diff] [blame] | 712 | endif() |