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 | # |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 3 | # Redistribution and use in source and binary forms, with or without |
| 4 | # modification, are permitted provided that the following conditions are met: |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 5 | # |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 6 | # 1. Redistributions of source code must retain the above copyright notice, this |
| 7 | # list of conditions and the following disclaimer. |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 8 | # |
Austin Eng | cc2516a | 2023-10-17 20:57:54 +0000 | [diff] [blame] | 9 | # 2. Redistributions in binary form must reproduce the above copyright notice, |
| 10 | # this list of conditions and the following disclaimer in the documentation |
| 11 | # and/or other materials provided with the distribution. |
| 12 | # |
| 13 | # 3. Neither the name of the copyright holder nor the names of its |
| 14 | # contributors may be used to endorse or promote products derived from |
| 15 | # this software without specific prior written permission. |
| 16 | # |
| 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 18 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 19 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 20 | # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 21 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 22 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 23 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 24 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 25 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 27 | |
Erin Melucci | d1e92bb | 2024-03-27 15:43:05 +0000 | [diff] [blame] | 28 | # As per https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md |
| 29 | cmake_minimum_required(VERSION 3.13) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 30 | |
Erin Melucci | d1e92bb | 2024-03-27 15:43:05 +0000 | [diff] [blame] | 31 | # - Since we are past CMake 3.12 we can add CONFIGURE_DEPENDS to DawnGenerator to rerun CMake |
Corentin Wallez | a3014cc | 2024-03-27 13:53:14 +0000 | [diff] [blame] | 32 | # in case any of the generator files changes. We should also remove the CACHE "" FORCE stuff to |
Erin Melucci | d1e92bb | 2024-03-27 15:43:05 +0000 | [diff] [blame] | 33 | # override options in third_party dependencies. |
Corentin Wallez | a3014cc | 2024-03-27 13:53:14 +0000 | [diff] [blame] | 34 | # - When upgrading to CMake 3.20 we can take advantage of the GENERATED property being global in |
| 35 | # DawnGenerator. We should also use the path utilities in install_if_enabled. |
| 36 | |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 37 | project( |
| 38 | Dawn |
| 39 | DESCRIPTION "Dawn, a WebGPU implementation" |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 40 | LANGUAGES C CXX |
Erin Melucci | d1e92bb | 2024-03-27 15:43:05 +0000 | [diff] [blame] | 41 | HOMEPAGE_URL "https://dawn.googlesource.com/dawn" |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 42 | ) |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 43 | enable_testing() |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 44 | |
Jaswant Panchumarti | 72b712f | 2024-06-21 13:16:18 +0000 | [diff] [blame] | 45 | list(INSERT CMAKE_MODULE_PATH 0 "${Dawn_SOURCE_DIR}/src/cmake") |
| 46 | |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 47 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 48 | |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 49 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) |
| 50 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 51 | set(CMAKE_DEBUG_POSTFIX "") |
dan sinclair | 2df8091 | 2023-11-20 13:22:14 +0000 | [diff] [blame] | 52 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 53 | |
Jaswant Panchumarti | 72b712f | 2024-06-21 13:16:18 +0000 | [diff] [blame] | 54 | include(DawnSetIfNotDefined) |
| 55 | |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 56 | set(DAWN_BUILD_GEN_DIR "${Dawn_BINARY_DIR}/gen") |
| 57 | set(DAWN_GENERATOR_DIR "${Dawn_SOURCE_DIR}/generator") |
| 58 | set(DAWN_SRC_DIR "${Dawn_SOURCE_DIR}/src") |
Ben Clayton | 9fb7a51 | 2022-02-04 18:18:18 +0000 | [diff] [blame] | 59 | set(DAWN_INCLUDE_DIR "${Dawn_SOURCE_DIR}/include") |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 60 | set(DAWN_TEMPLATE_DIR "${DAWN_GENERATOR_DIR}/templates") |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 61 | |
munoza | c511ffb | 2023-09-25 14:01:03 +0000 | [diff] [blame] | 62 | function (install_if_enabled target) |
| 63 | if(NOT DAWN_ENABLE_INSTALL) |
| 64 | return() |
| 65 | endif() |
| 66 | |
| 67 | install(TARGETS ${target} |
| 68 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
| 69 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 70 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 71 | ) |
| 72 | |
| 73 | get_target_property(targetHeaders ${target} INTERFACE_SOURCES) |
| 74 | if (NOT targetHeaders) |
| 75 | return() |
| 76 | endif() |
| 77 | |
| 78 | foreach(headerFile ${targetHeaders}) |
| 79 | # Starting from CMake 3.20 there is the cmake_path command that could simplify this code. |
| 80 | # Compute the install subdirectory for the header by stripping out the path to |
| 81 | # the include / gen/include directory... |
| 82 | string(FIND "${headerFile}" "${DAWN_INCLUDE_DIR}" foundIndex) |
| 83 | if (foundIndex EQUAL 0) |
| 84 | string(LENGTH "${DAWN_INCLUDE_DIR}/" lengthToRemove) |
| 85 | endif() |
| 86 | string(FIND "${headerFile}" "${DAWN_BUILD_GEN_DIR}/include/" foundIndex) |
| 87 | if (foundIndex EQUAL 0) |
| 88 | string(LENGTH "${DAWN_BUILD_GEN_DIR}/include/" lengthToRemove) |
| 89 | endif() |
| 90 | string(SUBSTRING "${headerFile}" "${lengthToRemove}" -1 headerRelDir) |
| 91 | |
| 92 | # ... then remove everything after the last / |
| 93 | string(FIND "${headerRelDir}" "/" foundIndex REVERSE) |
| 94 | string(SUBSTRING "${headerRelDir}" 0 ${foundIndex} headerRelDir) |
| 95 | |
| 96 | install(FILES "${headerFile}" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${headerRelDir}) |
| 97 | endforeach() |
| 98 | endfunction() |
| 99 | |
Jaswant Panchumarti | 72b712f | 2024-06-21 13:16:18 +0000 | [diff] [blame] | 100 | ################################################################################ |
| 101 | # Configuration options |
| 102 | ################################################################################ |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 103 | # Default values for the backend-enabling options |
Peng Huang | 925b776 | 2023-05-01 16:13:00 +0000 | [diff] [blame] | 104 | set(ENABLE_D3D11 OFF) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 105 | set(ENABLE_D3D12 OFF) |
| 106 | set(ENABLE_METAL OFF) |
Sergey Karchevsky | 3a75b1c | 2021-06-30 15:06:43 +0000 | [diff] [blame] | 107 | set(ENABLE_OPENGLES OFF) |
| 108 | set(ENABLE_DESKTOP_GL OFF) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 109 | set(ENABLE_VULKAN OFF) |
Jaswant Panchumarti | 5bdf876 | 2024-06-22 11:12:38 +0000 | [diff] [blame] | 110 | set(ENABLE_SPIRV_VALIDATION OFF) |
Corentin Wallez | 2e22d92 | 2022-06-01 09:30:50 +0000 | [diff] [blame] | 111 | set(USE_WAYLAND OFF) |
Corentin Wallez | d353ca0 | 2020-02-18 02:12:35 +0000 | [diff] [blame] | 112 | set(USE_X11 OFF) |
Stephen Gutekanst | 5562370 | 2023-07-01 11:43:55 +0000 | [diff] [blame] | 113 | set(USE_WINDOWS_UI OFF) |
Ben Clayton | a675075 | 2022-02-04 18:35:55 +0000 | [diff] [blame] | 114 | set(BUILD_SAMPLES OFF) |
AlexVestin | 5c3645c | 2023-10-18 14:08:26 +0000 | [diff] [blame] | 115 | set(TARGET_MACOS OFF) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 116 | if (WIN32) |
Peng Huang | 925b776 | 2023-05-01 16:13:00 +0000 | [diff] [blame] | 117 | set(ENABLE_D3D11 ON) |
Stephen Gutekanst | 5562370 | 2023-07-01 11:43:55 +0000 | [diff] [blame] | 118 | set(USE_WINDOWS_UI ON) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 119 | set(ENABLE_D3D12 ON) |
Jaswant Panchumarti | 5bdf876 | 2024-06-22 11:12:38 +0000 | [diff] [blame] | 120 | if (NOT WINDOWS_STORE) |
| 121 | # Enable Vulkan in win32 compilation only |
| 122 | # since UWP only supports d3d |
| 123 | set(ENABLE_VULKAN ON) |
| 124 | set(ENABLE_SPIRV_VALIDATION ON) |
| 125 | endif() |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 126 | elseif(APPLE) |
Jaswant Panchumarti | 5bdf876 | 2024-06-22 11:12:38 +0000 | [diff] [blame] | 127 | set(ENABLE_METAL ON) |
| 128 | if(CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "MacOS") |
| 129 | set(TARGET_MACOS ON) |
| 130 | endif() |
Alexander Vestin | f2556ab | 2022-03-25 13:18:46 +0000 | [diff] [blame] | 131 | elseif(ANDROID) |
Jaswant Panchumarti | 5bdf876 | 2024-06-22 11:12:38 +0000 | [diff] [blame] | 132 | set(ENABLE_VULKAN ON) |
| 133 | set(ENABLE_OPENGLES ON) |
| 134 | # Disable SPIR-V validation on Android because it adds a significant amount |
| 135 | # to the binary size, and Tint's output should be well-formed. |
| 136 | set(ENABLE_SPIRV_VALIDATION OFF) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 137 | elseif(UNIX) |
Jaswant Panchumarti | 5bdf876 | 2024-06-22 11:12:38 +0000 | [diff] [blame] | 138 | set(ENABLE_OPENGLES ON) |
| 139 | set(ENABLE_DESKTOP_GL ON) |
| 140 | set(ENABLE_VULKAN ON) |
| 141 | set(ENABLE_SPIRV_VALIDATION ON) |
| 142 | set(USE_X11 ON) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 143 | endif() |
| 144 | |
陈俊嘉 | b2bc57a | 2021-06-24 07:00:16 +0000 | [diff] [blame] | 145 | # GLFW is not supported in UWP |
Albin Bernhardsson | b8a1b6d | 2023-07-13 08:51:17 +0000 | [diff] [blame] | 146 | set(DAWN_SUPPORTS_GLFW_FOR_WINDOWING OFF) |
Sonakshi Saxena | 1344611 | 2023-08-23 12:32:14 +0000 | [diff] [blame] | 147 | |
| 148 | if ((WIN32 AND NOT WINDOWS_STORE) OR (UNIX AND NOT ANDROID)) |
陈俊嘉 | b2bc57a | 2021-06-24 07:00:16 +0000 | [diff] [blame] | 149 | set(DAWN_SUPPORTS_GLFW_FOR_WINDOWING ON) |
| 150 | endif() |
| 151 | |
| 152 | # Current examples are depend on GLFW |
| 153 | if (DAWN_SUPPORTS_GLFW_FOR_WINDOWING) |
Ben Clayton | a675075 | 2022-02-04 18:35:55 +0000 | [diff] [blame] | 154 | set(BUILD_SAMPLES ON) |
陈俊嘉 | b2bc57a | 2021-06-24 07:00:16 +0000 | [diff] [blame] | 155 | endif() |
| 156 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 157 | option(DAWN_ENABLE_ASAN "Enable address sanitizer" OFF) |
| 158 | option(DAWN_ENABLE_INSTALL "Enable install step for Dawn libraries" OFF) |
| 159 | option(DAWN_ENABLE_TSAN "Enable thread sanitizer" OFF) |
| 160 | option(DAWN_ENABLE_MSAN "Enable memory sanitizer" OFF) |
| 161 | option(DAWN_ENABLE_UBSAN "Enable undefined behaviour sanitizer" OFF) |
Ben Clayton | 96e245e | 2022-04-08 18:08:36 +0000 | [diff] [blame] | 162 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 163 | option(DAWN_ENABLE_D3D11 "Enable compilation of the D3D11 backend" ${ENABLE_D3D11}) |
| 164 | option(DAWN_ENABLE_D3D12 "Enable compilation of the D3D12 backend" ${ENABLE_D3D12}) |
| 165 | option(DAWN_ENABLE_METAL "Enable compilation of the Metal backend" ${ENABLE_METAL}) |
| 166 | option(DAWN_ENABLE_NULL "Enable compilation of the Null backend" ON) |
| 167 | option(DAWN_ENABLE_DESKTOP_GL "Enable compilation of the OpenGL backend" ${ENABLE_DESKTOP_GL}) |
| 168 | option(DAWN_ENABLE_OPENGLES "Enable compilation of the OpenGL ES backend" ${ENABLE_OPENGLES}) |
| 169 | option(DAWN_ENABLE_VULKAN "Enable compilation of the Vulkan backend" ${ENABLE_VULKAN}) |
Jaswant Panchumarti | 5bdf876 | 2024-06-22 11:12:38 +0000 | [diff] [blame] | 170 | option(DAWN_ENABLE_SPIRV_VALIDATION "Enable validation of SPIR-V" ${ENABLE_SPIRV_VALIDATION}) |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 171 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 172 | option(DAWN_ALWAYS_ASSERT "Enable assertions on all build types" OFF) |
| 173 | option(DAWN_USE_WAYLAND "Enable support for Wayland surface" ${USE_WAYLAND}) |
| 174 | option(DAWN_USE_X11 "Enable support for X11 surface" ${USE_X11}) |
| 175 | option(DAWN_USE_GLFW "Enable compilation of the GLFW windowing utils" ${DAWN_SUPPORTS_GLFW_FOR_WINDOWING}) |
| 176 | option(DAWN_USE_WINDOWS_UI "Enable support for Windows UI surface" ${USE_WINDOWS_UI}) |
| 177 | option(DAWN_USE_BUILT_DXC "Enable building and using DXC by the D3D12 backend" OFF) |
| 178 | option(DAWN_DXC_DISABLE_ASSERTS_DEBUG "Disable asserts in DXC in debug builds" OFF) |
| 179 | option(DAWN_TARGET_MACOS "Manually link Apple core frameworks" ${TARGET_MACOS}) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 180 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 181 | option(DAWN_BUILD_SAMPLES "Enables building Dawn's samples" ${BUILD_SAMPLES}) |
| 182 | option(DAWN_BUILD_NODE_BINDINGS "Enables building Dawn's NodeJS bindings" OFF) |
| 183 | option(DAWN_ENABLE_SWIFTSHADER "Enables building Swiftshader as part of the build and Vulkan adapter discovery" OFF) |
| 184 | option(DAWN_BUILD_BENCHMARKS "Build Dawn benchmarks" OFF) |
dan sinclair | 0c27cf2 | 2024-06-11 12:31:38 +0000 | [diff] [blame] | 185 | option(DAWN_BUILD_PROTOBUF "Build the protobuf dependencies" OFF) |
Ben Clayton | affb7a3 | 2021-09-28 11:14:42 +0000 | [diff] [blame] | 186 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 187 | option(DAWN_WERROR "Build with -Werror (or equivalent)" OFF) |
| 188 | option(DAWN_ENABLE_PIC "Build with Position-Independent-Code enabled" OFF) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 189 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 190 | option(DAWN_EMIT_COVERAGE "Emit code coverage information" OFF) |
Ben Clayton | f927bcb | 2022-12-12 21:21:54 +0000 | [diff] [blame] | 191 | 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] | 192 | |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 193 | if (DAWN_ENABLE_OPENGLES OR DAWN_ENABLE_DESKTOP_GL) |
| 194 | set(TINT_DEFAULT_GLSL ON) |
| 195 | else() |
| 196 | set(TINT_DEFAULT_GLSL OFF) |
| 197 | endif() |
| 198 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 199 | option(TINT_ENABLE_INSTALL "Enable install step for Tint libraries" OFF) |
| 200 | option(TINT_BUILD_CMD_TOOLS "Build the Tint command line tools" ON) |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 201 | |
dan sinclair | 12c428f | 2024-06-21 01:14:24 +0000 | [diff] [blame] | 202 | if (NOT DAWN_USE_GLFW AND DAWN_BUILD_SAMPLES) |
Erin Melucci | 38b58e4 | 2023-06-14 16:45:33 +0000 | [diff] [blame] | 203 | message(SEND_ERROR "Dawn samples require GLFW") |
| 204 | endif() |
| 205 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 206 | option(TINT_BUILD_SPV_READER "Build the SPIR-V input reader" ${DAWN_ENABLE_VULKAN}) |
| 207 | option(TINT_BUILD_WGSL_READER "Build the WGSL input reader" ON) |
| 208 | option(TINT_BUILD_GLSL_WRITER "Build the GLSL output writer" ${TINT_DEFAULT_GLSL}) |
| 209 | option(TINT_BUILD_GLSL_VALIDATOR "Build the GLSL output validator" ON) |
| 210 | option(TINT_BUILD_HLSL_WRITER "Build the HLSL output writer" ${DAWN_ENABLE_D3D12}) |
| 211 | option(TINT_BUILD_MSL_WRITER "Build the MSL output writer" ${DAWN_ENABLE_METAL}) |
| 212 | option(TINT_BUILD_SPV_WRITER "Build the SPIR-V output writer" ${DAWN_ENABLE_VULKAN}) |
| 213 | option(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON) |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 214 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 215 | option(TINT_BUILD_SYNTAX_TREE_WRITER "Build the syntax tree writer" OFF) |
dan sinclair | c22b8b9d | 2022-11-01 17:02:31 +0000 | [diff] [blame] | 216 | |
Ryan Harrison | 4578809 | 2024-06-19 02:26:57 +0000 | [diff] [blame] | 217 | if (DAWN_BUILD_PROTOBUF AND TARGET libprotobuf) |
| 218 | set(TINT_DEFAULT_BUILD_IR_BINARY ON) |
| 219 | else() |
| 220 | set(TINT_DEFAULT_BUILD_IR_BINARY OFF) |
| 221 | endif() |
Ryan Harrison | 724dd78 | 2024-05-16 16:27:48 +0000 | [diff] [blame] | 222 | |
Ryan Harrison | 4578809 | 2024-06-19 02:26:57 +0000 | [diff] [blame] | 223 | option(TINT_BUILD_IR_BINARY "Build IR binary format support" ${TINT_DEFAULT_BUILD_IR_BINARY}) |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 224 | option(TINT_BUILD_FUZZERS "Build fuzzers" OFF) |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 225 | option(TINT_BUILD_IR_FUZZER "Build IR fuzzer" OFF) |
| 226 | option(TINT_BUILD_BENCHMARKS "Build Tint benchmarks" OFF) |
| 227 | option(TINT_BUILD_TESTS "Build tests" ON) |
| 228 | option(TINT_BUILD_AS_OTHER_OS "Override OS detection to force building of *_other.cc files" OFF) |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 229 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 230 | option(TINT_BUILD_TINTD "Build the WGSL language server" OFF) |
Ben Clayton | f9a5b71 | 2024-03-13 17:37:33 +0000 | [diff] [blame] | 231 | |
Ben Clayton | 8fc9b86 | 2023-04-19 15:03:19 +0000 | [diff] [blame] | 232 | set_if_not_defined(TINT_EXTERNAL_BENCHMARK_CORPUS_DIR "" "Directory that holds a corpus of external shaders to benchmark.") |
| 233 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 234 | option(TINT_ENABLE_BREAK_IN_DEBUGGER "Enable tint::debugger::Break()" OFF) |
| 235 | option(TINT_CHECK_CHROMIUM_STYLE "Check for [chromium-style] issues during build" OFF) |
| 236 | option(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] | 237 | |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 238 | 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] | 239 | |
Ben Clayton | 30eeac7 | 2021-09-24 10:38:18 +0000 | [diff] [blame] | 240 | set_if_not_defined(DAWN_ABSEIL_DIR "${DAWN_THIRD_PARTY_DIR}/abseil-cpp" "Directory in which to find Abseil") |
| 241 | 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] | 242 | set_if_not_defined(DAWN_JINJA2_DIR "${DAWN_THIRD_PARTY_DIR}/jinja2" "Directory in which to find Jinja2") |
Arthur Sonzogni | c5f72f7 | 2023-11-29 15:27:40 +0000 | [diff] [blame] | 243 | set_if_not_defined(DAWN_MARKUPSAFE_DIR "${DAWN_THIRD_PARTY_DIR}/markupsafe" "Directory in which to find MarkupSafe") |
Arthur Sonzogni | 58f8ed2 | 2023-11-30 09:30:52 +0000 | [diff] [blame] | 244 | 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] | 245 | set_if_not_defined(DAWN_SWIFTSHADER_DIR "${DAWN_THIRD_PARTY_DIR}/swiftshader" "Directory in which to find swiftshader") |
Ben Clayton | fb07fa9 | 2023-11-17 18:48:59 +0000 | [diff] [blame] | 246 | set_if_not_defined(DAWN_PROTOBUF_DIR "${DAWN_THIRD_PARTY_DIR}/protobuf" "Directory in which to find protobuf") |
Ryan Harrison | 25e23b3 | 2024-05-27 23:21:05 +0000 | [diff] [blame] | 247 | set_if_not_defined(DAWN_LPM_DIR "${DAWN_THIRD_PARTY_DIR}/libprotobuf-mutator/src" "Directory in which to find libprotobuf") |
dan sinclair | c1f6dbd | 2023-04-11 15:45:18 +0000 | [diff] [blame] | 248 | |
Yuly Novikov | 143523a | 2024-05-23 15:59:58 +0000 | [diff] [blame] | 249 | set_if_not_defined(DAWN_SPIRV_TOOLS_DIR "${DAWN_THIRD_PARTY_DIR}/spirv-tools/src" "Directory in which to find SPIRV-Tools") |
| 250 | set_if_not_defined(DAWN_SPIRV_HEADERS_DIR "${DAWN_THIRD_PARTY_DIR}/spirv-headers/src" "Directory in which to find SPIRV-Headers") |
dan sinclair | 12c428f | 2024-06-21 01:14:24 +0000 | [diff] [blame] | 251 | set_if_not_defined(DAWN_GLSLANG_DIR "${DAWN_THIRD_PARTY_DIR}/glslang/src" "Directory in which to find GLSLang") |
Yuly Novikov | 143523a | 2024-05-23 15:59:58 +0000 | [diff] [blame] | 252 | set_if_not_defined(DAWN_VULKAN_HEADERS_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-headers/src" "Directory in which to find Vulkan-Headers") |
| 253 | set_if_not_defined(DAWN_VULKAN_UTILITY_LIBRARIES_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-utility-libraries/src" "Directory in which to find Vulkan-Utility-Libraries") |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 254 | |
Ben Clayton | affb7a3 | 2021-09-28 11:14:42 +0000 | [diff] [blame] | 255 | # Dependencies for DAWN_BUILD_NODE_BINDINGS |
| 256 | 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] | 257 | 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] | 258 | 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] | 259 | 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] | 260 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 261 | option(DAWN_FETCH_DEPENDENCIES "Use fetch_dawn_dependencies.py as an alternative to using depot_tools" OFF) |
Elie Michel | 9ae8ed2 | 2023-05-12 20:19:41 +0000 | [diff] [blame] | 262 | |
Sergey Karchevsky | 3a75b1c | 2021-06-30 15:06:43 +0000 | [diff] [blame] | 263 | # Much of the backend code is shared among desktop OpenGL and OpenGL ES |
| 264 | if (${DAWN_ENABLE_DESKTOP_GL} OR ${DAWN_ENABLE_OPENGLES}) |
| 265 | set(DAWN_ENABLE_OPENGL ON) |
| 266 | endif() |
| 267 | |
Ben Clayton | affb7a3 | 2021-09-28 11:14:42 +0000 | [diff] [blame] | 268 | if(DAWN_ENABLE_PIC) |
| 269 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
| 270 | endif() |
| 271 | |
Jaswant Panchumarti | 34cca84 | 2024-06-25 00:30:37 +0000 | [diff] [blame] | 272 | # The public config contains only the include paths for the Dawn headers. |
| 273 | add_library(dawn_public_config INTERFACE) |
| 274 | target_include_directories(dawn_public_config INTERFACE |
| 275 | "${DAWN_INCLUDE_DIR}" |
| 276 | "${DAWN_BUILD_GEN_DIR}/include" |
| 277 | ) |
| 278 | |
| 279 | # The internal config contains additional path but includes the dawn_public_config include paths |
| 280 | add_library(dawn_internal_config INTERFACE) |
| 281 | target_include_directories(dawn_internal_config INTERFACE |
| 282 | "${DAWN_SRC_DIR}" |
| 283 | "${DAWN_BUILD_GEN_DIR}/src" |
| 284 | ) |
| 285 | target_link_libraries(dawn_internal_config INTERFACE dawn_public_config) |
| 286 | |
Jaswant Panchumarti | eb93d8c | 2024-06-22 10:51:37 +0000 | [diff] [blame] | 287 | ################################################################################ |
| 288 | # Include utility CMake modules |
| 289 | ################################################################################ |
Jaswant Panchumarti | 064f544 | 2024-06-22 11:19:03 +0000 | [diff] [blame] | 290 | include(DawnCompilerChecks) |
Jaswant Panchumarti | eb93d8c | 2024-06-22 10:51:37 +0000 | [diff] [blame] | 291 | include(DawnCompilerExtraFlags) |
Jaswant Panchumarti | 61f9bc0 | 2024-06-22 10:56:48 +0000 | [diff] [blame] | 292 | include(DawnCompilerPlatformFlags) |
Jaswant Panchumarti | 34cca84 | 2024-06-25 00:30:37 +0000 | [diff] [blame] | 293 | include(DawnCompilerWarningFlags) |
Jaswant Panchumarti | fa41649 | 2024-06-22 11:08:57 +0000 | [diff] [blame] | 294 | include(DawnInitializeBuildType) |
Jaswant Panchumarti | 85b7675 | 2024-06-25 04:24:49 +0000 | [diff] [blame] | 295 | include(DawnLibrary) |
Jaswant Panchumarti | eb93d8c | 2024-06-22 10:51:37 +0000 | [diff] [blame] | 296 | |
Peng Huang | 5c2f167 | 2023-05-01 23:05:42 +0000 | [diff] [blame] | 297 | message(STATUS "Dawn build D3D11 backend: ${DAWN_ENABLE_D3D11}") |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 298 | message(STATUS "Dawn build D3D12 backend: ${DAWN_ENABLE_D3D12}") |
| 299 | message(STATUS "Dawn build Metal backend: ${DAWN_ENABLE_METAL}") |
| 300 | message(STATUS "Dawn build Vulkan backend: ${DAWN_ENABLE_VULKAN}") |
| 301 | message(STATUS "Dawn build OpenGL backend: ${DAWN_ENABLE_DESKTOP_GL}") |
| 302 | message(STATUS "Dawn build OpenGL ES backend: ${DAWN_ENABLE_OPENGLES}") |
| 303 | message(STATUS "Dawn build Null backend: ${DAWN_ENABLE_NULL}") |
| 304 | |
Jaswant Panchumarti | 5bdf876 | 2024-06-22 11:12:38 +0000 | [diff] [blame] | 305 | message(STATUS "Dawn enable SPIR-V validation: ${DAWN_ENABLE_SPIRV_VALIDATION}") |
| 306 | |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 307 | message(STATUS "Dawn build with asserts in all configurations: ${DAWN_ALWAYS_ASSERT}") |
| 308 | message(STATUS "Dawn build Wayland support: ${DAWN_USE_WAYLAND}") |
| 309 | message(STATUS "Dawn build X11 support: ${DAWN_USE_X11}") |
AlexVestin | 5c3645c | 2023-10-18 14:08:26 +0000 | [diff] [blame] | 310 | message(STATUS "Dawn build GLFW support: ${DAWN_USE_GLFW}") |
Stephen Gutekanst | 5562370 | 2023-07-01 11:43:55 +0000 | [diff] [blame] | 311 | message(STATUS "Dawn build Windows UI support: ${DAWN_USE_WINDOWS_UI}") |
Antonio Maiorano | c69356e | 2023-11-23 18:04:51 +0000 | [diff] [blame] | 312 | message(STATUS "Dawn build and use DXC: ${DAWN_USE_BUILT_DXC}") |
Antonio Maiorano | b4d05de | 2024-04-16 19:36:58 +0000 | [diff] [blame] | 313 | message(STATUS "Dawn disable DXC asserts in debug builds: ${DAWN_DXC_DISABLE_ASSERTS_DEBUG}") |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 314 | |
| 315 | message(STATUS "Dawn build samples: ${DAWN_BUILD_SAMPLES}") |
| 316 | message(STATUS "Dawn build Node bindings: ${DAWN_BUILD_NODE_BINDINGS}") |
| 317 | message(STATUS "Dawn build Swiftshader: ${DAWN_ENABLE_SWIFTSHADER}") |
Austin Eng | 6a7bba5 | 2023-04-17 18:11:51 +0000 | [diff] [blame] | 318 | message(STATUS "Dawn build benchmarks: ${DAWN_BUILD_BENCHMARKS}") |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 319 | |
| 320 | message(STATUS "Dawn build PIC: ${DAWN_ENABLE_PIC}") |
| 321 | |
| 322 | message(STATUS "Dawn build with ASAN: ${DAWN_ENABLE_ASAN}") |
Ben Clayton | d0ccb1a | 2022-08-19 21:33:01 +0000 | [diff] [blame] | 323 | message(STATUS "Dawn build with TSAN: ${DAWN_ENABLE_TSAN}") |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 324 | message(STATUS "Dawn build with MSAN: ${DAWN_ENABLE_MSAN}") |
| 325 | message(STATUS "Dawn build with UBSAN: ${DAWN_ENABLE_UBSAN}") |
| 326 | |
Ben Clayton | 3a3cb36 | 2023-08-16 01:05:21 +0000 | [diff] [blame] | 327 | message(STATUS "Tint build command line executable tools: ${TINT_BUILD_CMD_TOOLS}") |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 328 | message(STATUS "Tint build SPIR-V reader: ${TINT_BUILD_SPV_READER}") |
| 329 | message(STATUS "Tint build WGSL reader: ${TINT_BUILD_WGSL_READER}") |
| 330 | message(STATUS "Tint build GLSL writer: ${TINT_BUILD_GLSL_WRITER}") |
Ben Clayton | f1b8a01 | 2023-10-11 17:15:52 +0000 | [diff] [blame] | 331 | message(STATUS "Tint build GLSL validator: ${TINT_BUILD_GLSL_VALIDATOR}") |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 332 | message(STATUS "Tint build HLSL writer: ${TINT_BUILD_HLSL_WRITER}") |
| 333 | message(STATUS "Tint build MSL writer: ${TINT_BUILD_MSL_WRITER}") |
| 334 | message(STATUS "Tint build SPIR-V writer: ${TINT_BUILD_SPV_WRITER}") |
| 335 | message(STATUS "Tint build WGSL writer: ${TINT_BUILD_WGSL_WRITER}") |
dan sinclair | 0917fbb | 2023-03-07 18:28:38 +0000 | [diff] [blame] | 336 | message(STATUS "Tint build Syntax Tree writer: ${TINT_BUILD_SYNTAX_TREE_WRITER}") |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 337 | message(STATUS "Tint build fuzzers: ${TINT_BUILD_FUZZERS}") |
dan sinclair | 12c428f | 2024-06-21 01:14:24 +0000 | [diff] [blame] | 338 | message(STATUS "Tint build IR binary: ${TINT_BUILD_IR_BINARY}") |
Antonio Maiorano | 9fb4dc2 | 2024-06-18 15:49:36 +0000 | [diff] [blame] | 339 | message(STATUS "Tint build IR fuzzer: ${TINT_BUILD_IR_FUZZER}") |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 340 | message(STATUS "Tint build benchmarks: ${TINT_BUILD_BENCHMARKS}") |
| 341 | message(STATUS "Tint build tests: ${TINT_BUILD_TESTS}") |
| 342 | message(STATUS "Tint build checking [chromium-style]: ${TINT_CHECK_CHROMIUM_STYLE}") |
Ben Clayton | 8fc9b86 | 2023-04-19 15:03:19 +0000 | [diff] [blame] | 343 | message(STATUS "Tint external benchmark corpus dir: ${TINT_EXTERNAL_BENCHMARK_CORPUS_DIR}") |
| 344 | |
Ryan Harrison | 88e0d75 | 2024-06-14 02:02:10 +0000 | [diff] [blame] | 345 | set(IS_ASAN ${DAWN_ENABLE_ASAN}) |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 346 | |
| 347 | if (NOT ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS} STREQUAL "") |
| 348 | message(STATUS "Using provided LIB_FUZZING_ENGINE options: ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS}") |
| 349 | endif() |
| 350 | |
Corentin Wallez | 179e84a | 2024-03-27 20:20:15 +0000 | [diff] [blame] | 351 | find_package(Python3 REQUIRED) |
Corentin Wallez | 2f18c9a | 2024-04-02 08:51:45 +0000 | [diff] [blame] | 352 | message(STATUS "Dawn: using python at ${Python3_EXECUTABLE}") |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 353 | |
Ben Clayton | 9418152 | 2022-11-09 20:55:33 +0000 | [diff] [blame] | 354 | set(IS_DEBUG_BUILD 0) |
| 355 | string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type) |
| 356 | if ((NOT ${build_type} STREQUAL "RELEASE") AND (NOT ${build_type} STREQUAL "RELWITHDEBINFO")) |
| 357 | set(IS_DEBUG_BUILD 1) |
| 358 | endif() |
| 359 | |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 360 | # Compile definitions for the internal config |
Ben Clayton | 9418152 | 2022-11-09 20:55:33 +0000 | [diff] [blame] | 361 | if (DAWN_ALWAYS_ASSERT OR IS_DEBUG_BUILD) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 362 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_ASSERTS") |
| 363 | endif() |
Peng Huang | 5c2f167 | 2023-05-01 23:05:42 +0000 | [diff] [blame] | 364 | if (DAWN_ENABLE_D3D11) |
| 365 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_D3D11") |
| 366 | endif() |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 367 | if (DAWN_ENABLE_D3D12) |
| 368 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_D3D12") |
| 369 | endif() |
| 370 | if (DAWN_ENABLE_METAL) |
| 371 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_METAL") |
| 372 | endif() |
| 373 | if (DAWN_ENABLE_NULL) |
| 374 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_NULL") |
| 375 | endif() |
Sergey Karchevsky | 3a75b1c | 2021-06-30 15:06:43 +0000 | [diff] [blame] | 376 | if (DAWN_ENABLE_DESKTOP_GL) |
| 377 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_DESKTOP_GL") |
| 378 | endif() |
| 379 | if (DAWN_ENABLE_OPENGLES) |
| 380 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_OPENGLES") |
| 381 | endif() |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 382 | if (DAWN_ENABLE_OPENGL) |
| 383 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_OPENGL") |
| 384 | endif() |
| 385 | if (DAWN_ENABLE_VULKAN) |
| 386 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_VULKAN") |
| 387 | endif() |
Corentin Wallez | 2e22d92 | 2022-06-01 09:30:50 +0000 | [diff] [blame] | 388 | if (DAWN_USE_WAYLAND) |
| 389 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_WAYLAND") |
| 390 | endif() |
Corentin Wallez | d353ca0 | 2020-02-18 02:12:35 +0000 | [diff] [blame] | 391 | if (DAWN_USE_X11) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 392 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_X11") |
| 393 | endif() |
Stephen Gutekanst | 5562370 | 2023-07-01 11:43:55 +0000 | [diff] [blame] | 394 | if (DAWN_USE_WINDOWS_UI) |
| 395 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_WINDOWS_UI") |
| 396 | endif() |
Corentin Wallez | 3346697 | 2020-02-24 13:27:28 +0000 | [diff] [blame] | 397 | if (WIN32) |
| 398 | target_compile_definitions(dawn_internal_config INTERFACE "NOMINMAX" "WIN32_LEAN_AND_MEAN") |
| 399 | endif() |
| 400 | |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 401 | ################################################################################ |
Ryan Harrison | e87ac76 | 2022-04-06 15:37:27 -0400 | [diff] [blame] | 402 | # Tint |
| 403 | ################################################################################ |
| 404 | |
Alastair Donaldson | 6a1eb45 | 2021-09-02 23:49:25 +0000 | [diff] [blame] | 405 | set(TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS "" CACHE STRING "Used by OSS-Fuzz to control, via link options, which fuzzing engine should be used") |
| 406 | |
Ben Clayton | fb07fa9 | 2023-11-17 18:48:59 +0000 | [diff] [blame] | 407 | set(TINT_ROOT_SOURCE_DIR ${PROJECT_SOURCE_DIR}) |
Ben Clayton | 3a3cb36 | 2023-08-16 01:05:21 +0000 | [diff] [blame] | 408 | set(TINT_SPIRV_HEADERS_DIR ${DAWN_SPIRV_HEADERS_DIR}) |
| 409 | set(TINT_SPIRV_TOOLS_DIR ${DAWN_SPIRV_TOOLS_DIR}) |
Ben Clayton | 54cfa0b | 2021-07-08 19:35:53 +0000 | [diff] [blame] | 410 | |
Antonio Maiorano | 88d3d2e | 2021-03-23 20:51:09 +0000 | [diff] [blame] | 411 | |
Ryan Harrison | e87ac76 | 2022-04-06 15:37:27 -0400 | [diff] [blame] | 412 | ################################################################################ |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 413 | # Run on all subdirectories |
| 414 | ################################################################################ |
dan sinclair | 0c27cf2 | 2024-06-11 12:31:38 +0000 | [diff] [blame] | 415 | if (DAWN_BUILD_PROTOBUF AND EXISTS "${DAWN_PROTOBUF_DIR}/cmake") |
Ben Clayton | 01fa7c8 | 2024-01-31 21:07:17 +0000 | [diff] [blame] | 416 | if (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") AND WIN32) |
| 417 | set(protobuf_HAVE_BUILTIN_ATOMICS 1) |
| 418 | endif() |
| 419 | |
Ben Clayton | fb07fa9 | 2023-11-17 18:48:59 +0000 | [diff] [blame] | 420 | # Needs to come before SPIR-V Tools |
| 421 | include("third_party/protobuf.cmake") |
| 422 | endif() |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 423 | |
| 424 | add_subdirectory(third_party) |
James Price | 8d9adb0 | 2022-05-22 00:41:53 +0000 | [diff] [blame] | 425 | |
| 426 | # TODO(crbug.com/tint/455): Tint does not currently build with CMake when |
| 427 | # BUILD_SHARED_LIBS=1, so always build it as static for now. |
| 428 | set(BUILD_SHARED_LIBS_SAVED ${BUILD_SHARED_LIBS}) |
| 429 | set(BUILD_SHARED_LIBS 0) |
Ryan Harrison | dbc13af | 2022-02-21 15:19:07 +0000 | [diff] [blame] | 430 | add_subdirectory(src/tint) |
James Price | 8d9adb0 | 2022-05-22 00:41:53 +0000 | [diff] [blame] | 431 | set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_SAVED}) |
dan sinclair | 12c428f | 2024-06-21 01:14:24 +0000 | [diff] [blame] | 432 | |
| 433 | if (DAWN_ENABLE_D3D11 OR DAWN_ENABLE_D3D12 OR DAWN_ENABLE_METAL OR DAWN_ENABLE_NULL OR DAWN_ENABLE_DESKTOP_GL OR DAWN_ENABLE_OPENGLES OR DAWN_ENABLE_VULKAN) |
| 434 | add_subdirectory(generator) |
| 435 | add_subdirectory(src/dawn) |
| 436 | endif() |
Ben Clayton | 7b77855 | 2022-02-04 18:59:15 +0000 | [diff] [blame] | 437 | |
| 438 | ################################################################################ |
| 439 | # Samples |
| 440 | ################################################################################ |
dan sinclair | b595052 | 2020-03-19 13:03:35 +0000 | [diff] [blame] | 441 | add_custom_target(tint-lint |
| 442 | COMMAND ./tools/lint |
Ben Clayton | 54cfa0b | 2021-07-08 19:35:53 +0000 | [diff] [blame] | 443 | WORKING_DIRECTORY ${TINT_ROOT_SOURCE_DIR} |
dan sinclair | b595052 | 2020-03-19 13:03:35 +0000 | [diff] [blame] | 444 | COMMENT "Running linter" |
| 445 | VERBATIM) |
| 446 | |
| 447 | add_custom_target(tint-format |
| 448 | COMMAND ./tools/format |
Ben Clayton | 54cfa0b | 2021-07-08 19:35:53 +0000 | [diff] [blame] | 449 | WORKING_DIRECTORY ${TINT_ROOT_SOURCE_DIR} |
dan sinclair | b595052 | 2020-03-19 13:03:35 +0000 | [diff] [blame] | 450 | COMMENT "Running formatter" |
| 451 | VERBATIM) |
Ben Clayton | adb10d6 | 2020-10-27 21:04:59 +0000 | [diff] [blame] | 452 | |
Ben Clayton | 78e4530 | 2023-01-26 15:57:27 +0000 | [diff] [blame] | 453 | if (DAWN_EMIT_COVERAGE) |
| 454 | add_subdirectory(tools/src/cmd/turbo-cov) |
Ben Clayton | adb10d6 | 2020-10-27 21:04:59 +0000 | [diff] [blame] | 455 | |
Ben Clayton | 78e4530 | 2023-01-26 15:57:27 +0000 | [diff] [blame] | 456 | # The tint-generate-coverage target generates a lcov.info file at the project |
| 457 | # root, holding the code coverage for all the tint_unitests. |
Ben Clayton | adb10d6 | 2020-10-27 21:04:59 +0000 | [diff] [blame] | 458 | # This can be used by tools such as VSCode's Coverage Gutters extension to |
| 459 | # visualize code coverage in the editor. |
| 460 | get_filename_component(CLANG_BIN_DIR ${CMAKE_C_COMPILER} DIRECTORY) |
| 461 | set(PATH_WITH_CLANG "${CLANG_BIN_DIR}:$ENV{PATH}") |
| 462 | add_custom_target(tint-generate-coverage |
| 463 | COMMAND ${CMAKE_COMMAND} -E env PATH=${PATH_WITH_CLANG} ./tools/tint-generate-coverage $<TARGET_FILE:tint_unittests> |
| 464 | DEPENDS tint_unittests |
Ben Clayton | 54cfa0b | 2021-07-08 19:35:53 +0000 | [diff] [blame] | 465 | WORKING_DIRECTORY ${TINT_ROOT_SOURCE_DIR} |
Ben Clayton | adb10d6 | 2020-10-27 21:04:59 +0000 | [diff] [blame] | 466 | COMMENT "Generating tint coverage data" |
| 467 | VERBATIM) |
| 468 | endif() |