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