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 |
Jaswant Panchumarti | 5a26bdd | 2024-07-04 14:13:55 +0000 | [diff] [blame] | 35 | # DawnGenerator. We should also use the path utilities in dawn_install_target. |
Corentin Wallez | a3014cc | 2024-03-27 13:53:14 +0000 | [diff] [blame] | 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" |
Jaswant Panchumarti | 5a26bdd | 2024-07-04 14:13:55 +0000 | [diff] [blame] | 42 | VERSION 0.0.0 |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 43 | ) |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 44 | enable_testing() |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 45 | |
Jaswant Panchumarti | 72b712f | 2024-06-21 13:16:18 +0000 | [diff] [blame] | 46 | list(INSERT CMAKE_MODULE_PATH 0 "${Dawn_SOURCE_DIR}/src/cmake") |
| 47 | |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 48 | set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 49 | |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 50 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) |
| 51 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 52 | set(CMAKE_DEBUG_POSTFIX "") |
dan sinclair | 2df8091 | 2023-11-20 13:22:14 +0000 | [diff] [blame] | 53 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
Dan Sinclair | 6e58189 | 2020-03-02 15:47:43 -0500 | [diff] [blame] | 54 | |
Jaswant Panchumarti | 72b712f | 2024-06-21 13:16:18 +0000 | [diff] [blame] | 55 | include(DawnSetIfNotDefined) |
| 56 | |
Jaswant Panchumarti | e9cc8e4 | 2024-07-02 16:26:36 +0000 | [diff] [blame] | 57 | set(DAWN_BUILD_GEN_DIR "${Dawn_BINARY_DIR}/gen" CACHE PATH "Directory that contains generated source files") |
| 58 | set(DAWN_GENERATOR_DIR "${Dawn_SOURCE_DIR}/generator" CACHE PATH "Directory that contains scripts to generate sources and headers") |
| 59 | set(DAWN_SRC_DIR "${Dawn_SOURCE_DIR}/src" CACHE PATH "Directory that contains source files for dawn") |
| 60 | set(DAWN_INCLUDE_DIR "${Dawn_SOURCE_DIR}/include" CACHE PATH "Directory that contains public headers for dawn") |
| 61 | set(DAWN_TEMPLATE_DIR "${DAWN_GENERATOR_DIR}/templates" CACHE PATH "Directory that contains templates for generators") |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 62 | |
Jaswant Panchumarti | 72b712f | 2024-06-21 13:16:18 +0000 | [diff] [blame] | 63 | ################################################################################ |
| 64 | # Configuration options |
| 65 | ################################################################################ |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 66 | # Default values for the backend-enabling options |
Peng Huang | 925b776 | 2023-05-01 16:13:00 +0000 | [diff] [blame] | 67 | set(ENABLE_D3D11 OFF) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 68 | set(ENABLE_D3D12 OFF) |
| 69 | set(ENABLE_METAL OFF) |
Loko Kung | 90fdaa8 | 2024-07-24 00:59:58 +0000 | [diff] [blame] | 70 | set(ENABLE_NULL ON) |
Sergey Karchevsky | 3a75b1c | 2021-06-30 15:06:43 +0000 | [diff] [blame] | 71 | set(ENABLE_OPENGLES OFF) |
| 72 | set(ENABLE_DESKTOP_GL OFF) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 73 | set(ENABLE_VULKAN OFF) |
Loko Kung | 90fdaa8 | 2024-07-24 00:59:58 +0000 | [diff] [blame] | 74 | set(ENABLE_EMSCRIPTEN OFF) |
Jaswant Panchumarti | 5bdf876 | 2024-06-22 11:12:38 +0000 | [diff] [blame] | 75 | set(ENABLE_SPIRV_VALIDATION OFF) |
Corentin Wallez | 2e22d92 | 2022-06-01 09:30:50 +0000 | [diff] [blame] | 76 | set(USE_WAYLAND OFF) |
Corentin Wallez | d353ca0 | 2020-02-18 02:12:35 +0000 | [diff] [blame] | 77 | set(USE_X11 OFF) |
Stephen Gutekanst | 5562370 | 2023-07-01 11:43:55 +0000 | [diff] [blame] | 78 | set(USE_WINDOWS_UI OFF) |
Ben Clayton | a675075 | 2022-02-04 18:35:55 +0000 | [diff] [blame] | 79 | set(BUILD_SAMPLES OFF) |
Lokbondo Kung | 868a467 | 2024-10-25 20:17:03 +0000 | [diff] [blame] | 80 | set(BUILD_TESTS OFF) |
AlexVestin | 5c3645c | 2023-10-18 14:08:26 +0000 | [diff] [blame] | 81 | set(TARGET_MACOS OFF) |
Loko Kung | 90fdaa8 | 2024-07-24 00:59:58 +0000 | [diff] [blame] | 82 | if (CMAKE_SYSTEM_NAME MATCHES "Emscripten") |
| 83 | # Only the samples are supported for Emscripten at the moment. |
| 84 | # TODO(crbug.com/42240181): Make dawn_end2end_tests work too. |
| 85 | set(ENABLE_EMSCRIPTEN ON) |
| 86 | set(BUILD_SAMPLES ON) |
Lokbondo Kung | 868a467 | 2024-10-25 20:17:03 +0000 | [diff] [blame] | 87 | set(BUILD_TESTS ON) |
Loko Kung | 90fdaa8 | 2024-07-24 00:59:58 +0000 | [diff] [blame] | 88 | set(ENABLE_NULL OFF) |
| 89 | elseif (WIN32) |
| 90 | set(ENABLE_D3D11 ON) |
| 91 | set(USE_WINDOWS_UI ON) |
| 92 | set(ENABLE_D3D12 ON) |
Jaswant Panchumarti | 5bdf876 | 2024-06-22 11:12:38 +0000 | [diff] [blame] | 93 | if (NOT WINDOWS_STORE) |
| 94 | # Enable Vulkan in win32 compilation only |
| 95 | # since UWP only supports d3d |
| 96 | set(ENABLE_VULKAN ON) |
| 97 | set(ENABLE_SPIRV_VALIDATION ON) |
| 98 | endif() |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 99 | elseif(APPLE) |
Jaswant Panchumarti | 5bdf876 | 2024-06-22 11:12:38 +0000 | [diff] [blame] | 100 | set(ENABLE_METAL ON) |
| 101 | if(CMAKE_SYSTEM_NAME MATCHES "Darwin" OR CMAKE_SYSTEM_NAME MATCHES "MacOS") |
| 102 | set(TARGET_MACOS ON) |
| 103 | endif() |
Alexander Vestin | f2556ab | 2022-03-25 13:18:46 +0000 | [diff] [blame] | 104 | elseif(ANDROID) |
Jaswant Panchumarti | 5bdf876 | 2024-06-22 11:12:38 +0000 | [diff] [blame] | 105 | set(ENABLE_VULKAN ON) |
| 106 | set(ENABLE_OPENGLES ON) |
| 107 | # Disable SPIR-V validation on Android because it adds a significant amount |
| 108 | # to the binary size, and Tint's output should be well-formed. |
| 109 | set(ENABLE_SPIRV_VALIDATION OFF) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 110 | elseif(UNIX) |
Jaswant Panchumarti | 5bdf876 | 2024-06-22 11:12:38 +0000 | [diff] [blame] | 111 | set(ENABLE_OPENGLES ON) |
| 112 | set(ENABLE_DESKTOP_GL ON) |
| 113 | set(ENABLE_VULKAN ON) |
| 114 | set(ENABLE_SPIRV_VALIDATION ON) |
| 115 | set(USE_X11 ON) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 116 | endif() |
| 117 | |
陈俊嘉 | b2bc57a | 2021-06-24 07:00:16 +0000 | [diff] [blame] | 118 | # GLFW is not supported in UWP |
Albin Bernhardsson | b8a1b6d | 2023-07-13 08:51:17 +0000 | [diff] [blame] | 119 | set(DAWN_SUPPORTS_GLFW_FOR_WINDOWING OFF) |
Loko Kung | 90fdaa8 | 2024-07-24 00:59:58 +0000 | [diff] [blame] | 120 | if (NOT ENABLE_EMSCRIPTEN AND ((WIN32 AND NOT WINDOWS_STORE) OR (UNIX AND NOT ANDROID))) |
陈俊嘉 | b2bc57a | 2021-06-24 07:00:16 +0000 | [diff] [blame] | 121 | set(DAWN_SUPPORTS_GLFW_FOR_WINDOWING ON) |
| 122 | endif() |
| 123 | |
| 124 | # Current examples are depend on GLFW |
| 125 | if (DAWN_SUPPORTS_GLFW_FOR_WINDOWING) |
Ben Clayton | a675075 | 2022-02-04 18:35:55 +0000 | [diff] [blame] | 126 | set(BUILD_SAMPLES ON) |
陈俊嘉 | b2bc57a | 2021-06-24 07:00:16 +0000 | [diff] [blame] | 127 | endif() |
| 128 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 129 | option(DAWN_ENABLE_ASAN "Enable address sanitizer" OFF) |
| 130 | option(DAWN_ENABLE_INSTALL "Enable install step for Dawn libraries" OFF) |
| 131 | option(DAWN_ENABLE_TSAN "Enable thread sanitizer" OFF) |
| 132 | option(DAWN_ENABLE_MSAN "Enable memory sanitizer" OFF) |
| 133 | option(DAWN_ENABLE_UBSAN "Enable undefined behaviour sanitizer" OFF) |
Ben Clayton | 96e245e | 2022-04-08 18:08:36 +0000 | [diff] [blame] | 134 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 135 | option(DAWN_ENABLE_D3D11 "Enable compilation of the D3D11 backend" ${ENABLE_D3D11}) |
| 136 | option(DAWN_ENABLE_D3D12 "Enable compilation of the D3D12 backend" ${ENABLE_D3D12}) |
| 137 | option(DAWN_ENABLE_METAL "Enable compilation of the Metal backend" ${ENABLE_METAL}) |
Loko Kung | 90fdaa8 | 2024-07-24 00:59:58 +0000 | [diff] [blame] | 138 | option(DAWN_ENABLE_NULL "Enable compilation of the Null backend" ${ENABLE_NULL}) |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 139 | option(DAWN_ENABLE_DESKTOP_GL "Enable compilation of the OpenGL backend" ${ENABLE_DESKTOP_GL}) |
| 140 | option(DAWN_ENABLE_OPENGLES "Enable compilation of the OpenGL ES backend" ${ENABLE_OPENGLES}) |
| 141 | option(DAWN_ENABLE_VULKAN "Enable compilation of the Vulkan backend" ${ENABLE_VULKAN}) |
Jaswant Panchumarti | 5bdf876 | 2024-06-22 11:12:38 +0000 | [diff] [blame] | 142 | 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] | 143 | |
Loko Kung | 90fdaa8 | 2024-07-24 00:59:58 +0000 | [diff] [blame] | 144 | # Optional path to Emscripten toolchain to allow for building WASM. |
| 145 | option(DAWN_EMSCRIPTEN_TOOLCHAIN "Directory in which to find Emscripten toolchain" "") |
| 146 | set(DAWN_ENABLE_EMSCRIPTEN OFF) |
| 147 | if (NOT ${DAWN_EMSCRIPTEN_TOOLCHAIN} STREQUAL "" AND ENABLE_EMSCRIPTEN) |
| 148 | set(DAWN_ENABLE_EMSCRIPTEN ON) |
| 149 | endif() |
| 150 | |
dan sinclair | 6ddfddd | 2024-09-17 20:30:54 +0000 | [diff] [blame] | 151 | message(STATUS "Dawn build D3D11 backend: ${DAWN_ENABLE_D3D11}") |
| 152 | message(STATUS "Dawn build D3D12 backend: ${DAWN_ENABLE_D3D12}") |
| 153 | message(STATUS "Dawn build Metal backend: ${DAWN_ENABLE_METAL}") |
| 154 | message(STATUS "Dawn build Vulkan backend: ${DAWN_ENABLE_VULKAN}") |
| 155 | message(STATUS "Dawn build OpenGL backend: ${DAWN_ENABLE_DESKTOP_GL}") |
| 156 | message(STATUS "Dawn build OpenGL ES backend: ${DAWN_ENABLE_OPENGLES}") |
| 157 | message(STATUS "Dawn build Emscripten: ${DAWN_ENABLE_EMSCRIPTEN}") |
| 158 | message(STATUS "Dawn build Null backend: ${DAWN_ENABLE_NULL}") |
| 159 | message(STATUS "") |
| 160 | message(STATUS "Dawn enable SPIR-V validation: ${DAWN_ENABLE_SPIRV_VALIDATION}") |
| 161 | message(STATUS "") |
| 162 | message(STATUS "Dawn build with ASAN: ${DAWN_ENABLE_ASAN}") |
| 163 | message(STATUS "Dawn build with TSAN: ${DAWN_ENABLE_TSAN}") |
| 164 | message(STATUS "Dawn build with MSAN: ${DAWN_ENABLE_MSAN}") |
| 165 | message(STATUS "Dawn build with UBSAN: ${DAWN_ENABLE_UBSAN}") |
| 166 | message(STATUS "Dawn enable install: ${DAWN_ENABLE_INSTALL}") |
| 167 | message(STATUS "") |
| 168 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 169 | option(DAWN_ALWAYS_ASSERT "Enable assertions on all build types" OFF) |
| 170 | option(DAWN_USE_WAYLAND "Enable support for Wayland surface" ${USE_WAYLAND}) |
| 171 | option(DAWN_USE_X11 "Enable support for X11 surface" ${USE_X11}) |
| 172 | option(DAWN_USE_GLFW "Enable compilation of the GLFW windowing utils" ${DAWN_SUPPORTS_GLFW_FOR_WINDOWING}) |
| 173 | option(DAWN_USE_WINDOWS_UI "Enable support for Windows UI surface" ${USE_WINDOWS_UI}) |
| 174 | option(DAWN_USE_BUILT_DXC "Enable building and using DXC by the D3D12 backend" OFF) |
Antonio Maiorano | c5c7480 | 2024-08-08 14:45:08 +0000 | [diff] [blame] | 175 | option(DAWN_DXC_ENABLE_ASSERTS_IN_NDEBUG "Enable DXC asserts in non-debug builds" ON) |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 176 | option(DAWN_TARGET_MACOS "Manually link Apple core frameworks" ${TARGET_MACOS}) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 177 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 178 | option(DAWN_BUILD_SAMPLES "Enables building Dawn's samples" ${BUILD_SAMPLES}) |
Lokbondo Kung | 868a467 | 2024-10-25 20:17:03 +0000 | [diff] [blame] | 179 | option(DAWN_BUILD_TESTS "Enables building Dawn's tests" ${BUILD_TESTS}) |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 180 | option(DAWN_BUILD_NODE_BINDINGS "Enables building Dawn's NodeJS bindings" OFF) |
| 181 | option(DAWN_ENABLE_SWIFTSHADER "Enables building Swiftshader as part of the build and Vulkan adapter discovery" OFF) |
| 182 | option(DAWN_BUILD_BENCHMARKS "Build Dawn benchmarks" OFF) |
dan sinclair | 0c27cf2 | 2024-06-11 12:31:38 +0000 | [diff] [blame] | 183 | option(DAWN_BUILD_PROTOBUF "Build the protobuf dependencies" OFF) |
Ben Clayton | affb7a3 | 2021-09-28 11:14:42 +0000 | [diff] [blame] | 184 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 185 | option(DAWN_WERROR "Build with -Werror (or equivalent)" OFF) |
| 186 | option(DAWN_ENABLE_PIC "Build with Position-Independent-Code enabled" OFF) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 187 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 188 | option(DAWN_EMIT_COVERAGE "Emit code coverage information" OFF) |
Ben Clayton | f927bcb | 2022-12-12 21:21:54 +0000 | [diff] [blame] | 189 | 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] | 190 | |
dan sinclair | 6ddfddd | 2024-09-17 20:30:54 +0000 | [diff] [blame] | 191 | message(STATUS "Dawn build with asserts in all configurations: ${DAWN_ALWAYS_ASSERT}") |
| 192 | message(STATUS "Dawn build Wayland support: ${DAWN_USE_WAYLAND}") |
| 193 | message(STATUS "Dawn build X11 support: ${DAWN_USE_X11}") |
| 194 | message(STATUS "Dawn build GLFW support: ${DAWN_USE_GLFW}") |
| 195 | message(STATUS "Dawn build Windows UI support: ${DAWN_USE_WINDOWS_UI}") |
| 196 | message(STATUS "Dawn build and use DXC: ${DAWN_USE_BUILT_DXC}") |
| 197 | message(STATUS "Dawn enable DXC asserts in non-debug builds: ${DAWN_DXC_ENABLE_ASSERTS_IN_NDEBUG}") |
| 198 | message(STATUS "Dawn target MacOS: ${TARGET_MACOS}") |
| 199 | message(STATUS "") |
| 200 | message(STATUS "Dawn build samples: ${DAWN_BUILD_SAMPLES}") |
| 201 | message(STATUS "Dawn build Node bindings: ${DAWN_BUILD_NODE_BINDINGS}") |
| 202 | message(STATUS "Dawn build Swiftshader: ${DAWN_ENABLE_SWIFTSHADER}") |
| 203 | message(STATUS "Dawn build benchmarks: ${DAWN_BUILD_BENCHMARKS}") |
| 204 | message(STATUS "Dawn build protobuf: ${DAWN_BUILD_PROTOBUF}") |
| 205 | message(STATUS "") |
| 206 | message(STATUS "Dawn build PIC: ${DAWN_ENABLE_PIC}") |
| 207 | message(STATUS "DAWN Werror: ${DAWN_WERROR}") |
| 208 | message(STATUS "") |
| 209 | message(STATUS "Dawn emit coverage: ${DAWN_EMIT_COVERAGE}") |
| 210 | message(STATUS "LLVM Source dir: ${LLVM_SOURCE_DIR}") |
| 211 | message(STATUS "") |
| 212 | |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 213 | if (DAWN_ENABLE_OPENGLES OR DAWN_ENABLE_DESKTOP_GL) |
| 214 | set(TINT_DEFAULT_GLSL ON) |
| 215 | else() |
| 216 | set(TINT_DEFAULT_GLSL OFF) |
| 217 | endif() |
| 218 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 219 | option(TINT_ENABLE_INSTALL "Enable install step for Tint libraries" OFF) |
| 220 | option(TINT_BUILD_CMD_TOOLS "Build the Tint command line tools" ON) |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 221 | |
Loko Kung | 90fdaa8 | 2024-07-24 00:59:58 +0000 | [diff] [blame] | 222 | if (DAWN_BUILD_SAMPLES) |
| 223 | if (NOT DAWN_USE_GLFW AND NOT DAWN_ENABLE_EMSCRIPTEN) |
| 224 | message(SEND_ERROR "Dawn samples require GLFW or Emscripten") |
| 225 | endif() |
Erin Melucci | 38b58e4 | 2023-06-14 16:45:33 +0000 | [diff] [blame] | 226 | endif() |
| 227 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 228 | option(TINT_BUILD_SPV_READER "Build the SPIR-V input reader" ${DAWN_ENABLE_VULKAN}) |
| 229 | option(TINT_BUILD_WGSL_READER "Build the WGSL input reader" ON) |
| 230 | option(TINT_BUILD_GLSL_WRITER "Build the GLSL output writer" ${TINT_DEFAULT_GLSL}) |
| 231 | option(TINT_BUILD_GLSL_VALIDATOR "Build the GLSL output validator" ON) |
| 232 | option(TINT_BUILD_HLSL_WRITER "Build the HLSL output writer" ${DAWN_ENABLE_D3D12}) |
| 233 | option(TINT_BUILD_MSL_WRITER "Build the MSL output writer" ${DAWN_ENABLE_METAL}) |
| 234 | option(TINT_BUILD_SPV_WRITER "Build the SPIR-V output writer" ${DAWN_ENABLE_VULKAN}) |
| 235 | option(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON) |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 236 | option(TINT_BUILD_SYNTAX_TREE_WRITER "Build the syntax tree writer" OFF) |
dan sinclair | c22b8b9d | 2022-11-01 17:02:31 +0000 | [diff] [blame] | 237 | |
Ryan Harrison | 4578809 | 2024-06-19 02:26:57 +0000 | [diff] [blame] | 238 | if (DAWN_BUILD_PROTOBUF AND TARGET libprotobuf) |
| 239 | set(TINT_DEFAULT_BUILD_IR_BINARY ON) |
| 240 | else() |
| 241 | set(TINT_DEFAULT_BUILD_IR_BINARY OFF) |
| 242 | endif() |
Ryan Harrison | 724dd78 | 2024-05-16 16:27:48 +0000 | [diff] [blame] | 243 | |
Ryan Harrison | 4578809 | 2024-06-19 02:26:57 +0000 | [diff] [blame] | 244 | 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] | 245 | option(TINT_BUILD_FUZZERS "Build fuzzers" OFF) |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 246 | option(TINT_BUILD_IR_FUZZER "Build IR fuzzer" OFF) |
| 247 | option(TINT_BUILD_BENCHMARKS "Build Tint benchmarks" OFF) |
| 248 | option(TINT_BUILD_TESTS "Build tests" ON) |
| 249 | 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] | 250 | |
dan sinclair | 0ee0afa | 2024-10-22 22:58:25 +0000 | [diff] [blame] | 251 | if (DAWN_ENABLE_EMSCRIPTEN) |
| 252 | # Skip tint tests in emscripten build |
| 253 | set(TINT_BUILD_TESTS OFF) |
| 254 | # Skip GLSL validation in Emscripten |
| 255 | set(TINT_BUILD_GLSL_VALIDATOR OFF) |
| 256 | endif() |
| 257 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 258 | option(TINT_BUILD_TINTD "Build the WGSL language server" OFF) |
Ben Clayton | f9a5b71 | 2024-03-13 17:37:33 +0000 | [diff] [blame] | 259 | |
Jaswant Panchumarti | db4c402 | 2024-06-10 09:23:49 +0000 | [diff] [blame] | 260 | option(TINT_ENABLE_BREAK_IN_DEBUGGER "Enable tint::debugger::Break()" OFF) |
| 261 | option(TINT_CHECK_CHROMIUM_STYLE "Check for [chromium-style] issues during build" OFF) |
| 262 | 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] | 263 | |
dan sinclair | 6ddfddd | 2024-09-17 20:30:54 +0000 | [diff] [blame] | 264 | message(STATUS "Tint build SPIR-V reader: ${TINT_BUILD_SPV_READER}") |
| 265 | message(STATUS "Tint build WGSL reader: ${TINT_BUILD_WGSL_READER}") |
| 266 | message(STATUS "Tint build GLSL writer: ${TINT_BUILD_GLSL_WRITER}") |
| 267 | message(STATUS "Tint build GLSL validator: ${TINT_BUILD_GLSL_VALIDATOR}") |
| 268 | message(STATUS "Tint build HLSL writer: ${TINT_BUILD_HLSL_WRITER}") |
| 269 | message(STATUS "Tint build MSL writer: ${TINT_BUILD_MSL_WRITER}") |
| 270 | message(STATUS "Tint build SPIR-V writer: ${TINT_BUILD_SPV_WRITER}") |
| 271 | message(STATUS "Tint build WGSL writer: ${TINT_BUILD_WGSL_WRITER}") |
| 272 | message(STATUS "Tint build Syntax Tree writer: ${TINT_BUILD_SYNTAX_TREE_WRITER}") |
| 273 | message(STATUS "") |
| 274 | message(STATUS "Tint build command line executable tools: ${TINT_BUILD_CMD_TOOLS}") |
| 275 | message(STATUS "Tint install: ${TINT_ENABLE_INSTALL}") |
| 276 | message(STATUS "Tint build fuzzers: ${TINT_BUILD_FUZZERS}") |
| 277 | message(STATUS "Tint build IR binary: ${TINT_BUILD_IR_BINARY}") |
| 278 | message(STATUS "Tint build IR fuzzer: ${TINT_BUILD_IR_FUZZER}") |
| 279 | message(STATUS "Tint build benchmarks: ${TINT_BUILD_BENCHMARKS}") |
| 280 | message(STATUS "Tint build tests: ${TINT_BUILD_TESTS}") |
| 281 | message(STATUS "Tint build tintd: ${TINT_BUILD_TINTD}") |
| 282 | message(STATUS "") |
| 283 | message(STATUS "Tint enable break in debugger: ${TINT_ENABLE_BREAK_IN_DEBUGGER}") |
| 284 | message(STATUS "Tint build checking [chromium-style]: ${TINT_CHECK_CHROMIUM_STYLE}") |
| 285 | message(STATUS "Tint randomize hashes: ${TINT_RANDOMIZE_HASHES}") |
| 286 | message(STATUS "") |
dan sinclair | 6ddfddd | 2024-09-17 20:30:54 +0000 | [diff] [blame] | 287 | |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 288 | 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] | 289 | |
Ben Clayton | 30eeac7 | 2021-09-24 10:38:18 +0000 | [diff] [blame] | 290 | set_if_not_defined(DAWN_ABSEIL_DIR "${DAWN_THIRD_PARTY_DIR}/abseil-cpp" "Directory in which to find Abseil") |
| 291 | 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] | 292 | 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] | 293 | 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] | 294 | 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] | 295 | 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] | 296 | 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] | 297 | set_if_not_defined(DAWN_LPM_DIR "${DAWN_THIRD_PARTY_DIR}/libprotobuf-mutator/src" "Directory in which to find libprotobuf") |
Loko Kung | 90fdaa8 | 2024-07-24 00:59:58 +0000 | [diff] [blame] | 298 | set_if_not_defined(DAWN_EMDAWNWEBGPU_DIR "${DAWN_THIRD_PARTY_DIR}/emdawnwebgpu" "Directory in which to find Dawn specific Emscripten bindings") |
Lokbondo Kung | 868a467 | 2024-10-25 20:17:03 +0000 | [diff] [blame] | 299 | set_if_not_defined(DAWN_GOOGLETEST_DIR "${DAWN_THIRD_PARTY_DIR}/googletest" "Directory in which to find googletest") |
dan sinclair | c1f6dbd | 2023-04-11 15:45:18 +0000 | [diff] [blame] | 300 | |
Yuly Novikov | 143523a | 2024-05-23 15:59:58 +0000 | [diff] [blame] | 301 | set_if_not_defined(DAWN_SPIRV_TOOLS_DIR "${DAWN_THIRD_PARTY_DIR}/spirv-tools/src" "Directory in which to find SPIRV-Tools") |
| 302 | 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] | 303 | 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] | 304 | set_if_not_defined(DAWN_VULKAN_HEADERS_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-headers/src" "Directory in which to find Vulkan-Headers") |
| 305 | 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] | 306 | |
dan sinclair | 6ddfddd | 2024-09-17 20:30:54 +0000 | [diff] [blame] | 307 | message(STATUS "Dawn third_party dir: ${DAWN_THIRD_PARTY_DIR}") |
| 308 | message(STATUS "Dawn GLFW dir: ${DAWN_GLFW_DIR}") |
| 309 | message(STATUS "Dawn Jinja2 dir: ${DAWN_JINJA2_DIR}") |
| 310 | message(STATUS "Dawn MarkupSafe dir: ${DAWN_MARKUPSAFE_DIR}") |
| 311 | message(STATUS "Dawn Khronos dir: ${DAWN_KHRONOS_DIR}") |
| 312 | message(STATUS "Dawn Swiftshader dir: ${DAWN_SWIFTSHADER_DIR}") |
| 313 | message(STATUS "Dawn Protobuf dir: ${DAWN_PROTOBUF_DIR}") |
| 314 | message(STATUS "Dawn LPM dir: ${DAWN_LPM_DIR}") |
| 315 | message(STATUS "Dawn Emdawnwebgpu dir: ${DAWN_EMDAWNWEBGPU_DIR}") |
| 316 | message(STATUS "Dawn Spir-Tools dir: ${DAWN_SPIRV_TOOLS_DIR}") |
| 317 | message(STATUS "Dawn Spirv-Headers dir: ${DAWN_SPIRV_HEADERS_DIR}") |
| 318 | message(STATUS "Dawn Glslang dir: ${DAWN_GLSLANG_DIR}") |
| 319 | message(STATUS "Dawn Vulkan Headers dir: ${DAWN_VULKAN_HEADERS_DIR}") |
| 320 | message(STATUS "Dawn Vulkan Utility Libraries dir: ${DAWN_VULKAN_UTILITY_LIBRARIES_DIR}") |
| 321 | message(STATUS "") |
| 322 | |
Ben Clayton | affb7a3 | 2021-09-28 11:14:42 +0000 | [diff] [blame] | 323 | # Dependencies for DAWN_BUILD_NODE_BINDINGS |
| 324 | 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] | 325 | 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] | 326 | 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] | 327 | 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] | 328 | |
dan sinclair | 6ddfddd | 2024-09-17 20:30:54 +0000 | [diff] [blame] | 329 | message(STATUS "Node Addon API dir: ${NODE_ADDON_API_DIR}") |
| 330 | message(STATUS "Node API Headers dir: ${NODE_API_HEADERS_DIR}") |
| 331 | message(STATUS "Webgpu IDL path: ${WEBGPU_IDL_PATH}") |
| 332 | message(STATUS "Go exe: ${GO_EXECUTABLE}") |
| 333 | message(STATUS "") |
Elie Michel | 9ae8ed2 | 2023-05-12 20:19:41 +0000 | [diff] [blame] | 334 | |
dan sinclair | 6ddfddd | 2024-09-17 20:30:54 +0000 | [diff] [blame] | 335 | option(DAWN_FETCH_DEPENDENCIES "Use fetch_dawn_dependencies.py as an alternative to using depot_tools" OFF) |
Jaswant Panchumarti | 5a26bdd | 2024-07-04 14:13:55 +0000 | [diff] [blame] | 336 | option(DAWN_BUILD_MONOLITHIC_LIBRARY "Bundle all dawn components into a single shared library." ON) |
| 337 | |
dan sinclair | 6ddfddd | 2024-09-17 20:30:54 +0000 | [diff] [blame] | 338 | message(STATUS "Dawn fetch dependencies: ${DAWN_FETCH_DEPENDENCIES}") |
| 339 | message(STATUS "Dawn build monolithic library: ${DAWN_BUILD_MONOLITHIC_LIBRARY}") |
| 340 | message(STATUS "") |
| 341 | |
Loko Kung | 90fdaa8 | 2024-07-24 00:59:58 +0000 | [diff] [blame] | 342 | # Optional path to Emscripten toolchain to allow for building WASM. |
| 343 | set_if_not_defined(DAWN_EMSCRIPTEN_TOOLCHAIN "" "Directory in which to find Emscripten toolchain") |
| 344 | set(DAWN_ENABLE_EMSCRIPTEN OFF) |
| 345 | if (NOT ${DAWN_EMSCRIPTEN_TOOLCHAIN} STREQUAL "" AND ENABLE_EMSCRIPTEN) |
| 346 | set(DAWN_ENABLE_EMSCRIPTEN ON) |
| 347 | endif() |
| 348 | |
dan sinclair | 6ddfddd | 2024-09-17 20:30:54 +0000 | [diff] [blame] | 349 | message(STATUS "Dawn Emscripten toolchain: ${DAWN_EMSCRIPTEN_TOOLCHAIN}") |
| 350 | message(STATUS "") |
| 351 | |
Sergey Karchevsky | 3a75b1c | 2021-06-30 15:06:43 +0000 | [diff] [blame] | 352 | # Much of the backend code is shared among desktop OpenGL and OpenGL ES |
| 353 | if (${DAWN_ENABLE_DESKTOP_GL} OR ${DAWN_ENABLE_OPENGLES}) |
| 354 | set(DAWN_ENABLE_OPENGL ON) |
| 355 | endif() |
| 356 | |
Ben Clayton | affb7a3 | 2021-09-28 11:14:42 +0000 | [diff] [blame] | 357 | if(DAWN_ENABLE_PIC) |
| 358 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
| 359 | endif() |
| 360 | |
Jaswant Panchumarti | 5a26bdd | 2024-07-04 14:13:55 +0000 | [diff] [blame] | 361 | # Defines `CMAKE_INSTALL_*DIR` variables |
| 362 | include(GNUInstallDirs) |
Jaswant Panchumarti | 34cca84 | 2024-06-25 00:30:37 +0000 | [diff] [blame] | 363 | # The public config contains only the include paths for the Dawn headers. |
| 364 | add_library(dawn_public_config INTERFACE) |
| 365 | target_include_directories(dawn_public_config INTERFACE |
Jaswant Panchumarti | 5a26bdd | 2024-07-04 14:13:55 +0000 | [diff] [blame] | 366 | "$<BUILD_INTERFACE:${DAWN_INCLUDE_DIR}>" |
| 367 | "$<BUILD_INTERFACE:${DAWN_BUILD_GEN_DIR}/include>" |
| 368 | "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>" |
Jaswant Panchumarti | 34cca84 | 2024-06-25 00:30:37 +0000 | [diff] [blame] | 369 | ) |
| 370 | |
| 371 | # The internal config contains additional path but includes the dawn_public_config include paths |
| 372 | add_library(dawn_internal_config INTERFACE) |
| 373 | target_include_directories(dawn_internal_config INTERFACE |
dan sinclair | d90557b | 2024-08-28 16:15:03 +0000 | [diff] [blame] | 374 | "${PROJECT_SOURCE_DIR}" |
Jaswant Panchumarti | 34cca84 | 2024-06-25 00:30:37 +0000 | [diff] [blame] | 375 | "${DAWN_SRC_DIR}" |
| 376 | "${DAWN_BUILD_GEN_DIR}/src" |
| 377 | ) |
| 378 | target_link_libraries(dawn_internal_config INTERFACE dawn_public_config) |
| 379 | |
Jaswant Panchumarti | eb93d8c | 2024-06-22 10:51:37 +0000 | [diff] [blame] | 380 | ################################################################################ |
| 381 | # Include utility CMake modules |
| 382 | ################################################################################ |
Jaswant Panchumarti | 064f544 | 2024-06-22 11:19:03 +0000 | [diff] [blame] | 383 | include(DawnCompilerChecks) |
Jaswant Panchumarti | eb93d8c | 2024-06-22 10:51:37 +0000 | [diff] [blame] | 384 | include(DawnCompilerExtraFlags) |
Jaswant Panchumarti | 61f9bc0 | 2024-06-22 10:56:48 +0000 | [diff] [blame] | 385 | include(DawnCompilerPlatformFlags) |
Jaswant Panchumarti | 34cca84 | 2024-06-25 00:30:37 +0000 | [diff] [blame] | 386 | include(DawnCompilerWarningFlags) |
Jaswant Panchumarti | fa41649 | 2024-06-22 11:08:57 +0000 | [diff] [blame] | 387 | include(DawnInitializeBuildType) |
Jaswant Panchumarti | 85b7675 | 2024-06-25 04:24:49 +0000 | [diff] [blame] | 388 | include(DawnLibrary) |
Jaswant Panchumarti | eb93d8c | 2024-06-22 10:51:37 +0000 | [diff] [blame] | 389 | |
Ryan Harrison | 88e0d75 | 2024-06-14 02:02:10 +0000 | [diff] [blame] | 390 | set(IS_ASAN ${DAWN_ENABLE_ASAN}) |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 391 | |
| 392 | if (NOT ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS} STREQUAL "") |
| 393 | message(STATUS "Using provided LIB_FUZZING_ENGINE options: ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS}") |
| 394 | endif() |
| 395 | |
Corentin Wallez | 179e84a | 2024-03-27 20:20:15 +0000 | [diff] [blame] | 396 | find_package(Python3 REQUIRED) |
Corentin Wallez | 2f18c9a | 2024-04-02 08:51:45 +0000 | [diff] [blame] | 397 | message(STATUS "Dawn: using python at ${Python3_EXECUTABLE}") |
dan sinclair | 194c177 | 2022-06-21 17:54:03 +0000 | [diff] [blame] | 398 | |
Ben Clayton | 9418152 | 2022-11-09 20:55:33 +0000 | [diff] [blame] | 399 | set(IS_DEBUG_BUILD 0) |
| 400 | string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type) |
| 401 | if ((NOT ${build_type} STREQUAL "RELEASE") AND (NOT ${build_type} STREQUAL "RELWITHDEBINFO")) |
| 402 | set(IS_DEBUG_BUILD 1) |
| 403 | endif() |
| 404 | |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 405 | # Compile definitions for the internal config |
Ben Clayton | 9418152 | 2022-11-09 20:55:33 +0000 | [diff] [blame] | 406 | if (DAWN_ALWAYS_ASSERT OR IS_DEBUG_BUILD) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 407 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_ASSERTS") |
| 408 | endif() |
Peng Huang | 5c2f167 | 2023-05-01 23:05:42 +0000 | [diff] [blame] | 409 | if (DAWN_ENABLE_D3D11) |
| 410 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_D3D11") |
| 411 | endif() |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 412 | if (DAWN_ENABLE_D3D12) |
| 413 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_D3D12") |
| 414 | endif() |
| 415 | if (DAWN_ENABLE_METAL) |
| 416 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_METAL") |
| 417 | endif() |
| 418 | if (DAWN_ENABLE_NULL) |
| 419 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_NULL") |
| 420 | endif() |
Sergey Karchevsky | 3a75b1c | 2021-06-30 15:06:43 +0000 | [diff] [blame] | 421 | if (DAWN_ENABLE_DESKTOP_GL) |
| 422 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_DESKTOP_GL") |
| 423 | endif() |
| 424 | if (DAWN_ENABLE_OPENGLES) |
| 425 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_OPENGLES") |
| 426 | endif() |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 427 | if (DAWN_ENABLE_OPENGL) |
| 428 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_OPENGL") |
| 429 | endif() |
| 430 | if (DAWN_ENABLE_VULKAN) |
| 431 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_VULKAN") |
| 432 | endif() |
Corentin Wallez | 2e22d92 | 2022-06-01 09:30:50 +0000 | [diff] [blame] | 433 | if (DAWN_USE_WAYLAND) |
| 434 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_WAYLAND") |
| 435 | endif() |
Corentin Wallez | d353ca0 | 2020-02-18 02:12:35 +0000 | [diff] [blame] | 436 | if (DAWN_USE_X11) |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 437 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_X11") |
| 438 | endif() |
Stephen Gutekanst | 5562370 | 2023-07-01 11:43:55 +0000 | [diff] [blame] | 439 | if (DAWN_USE_WINDOWS_UI) |
| 440 | target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_WINDOWS_UI") |
| 441 | endif() |
Corentin Wallez | 3346697 | 2020-02-24 13:27:28 +0000 | [diff] [blame] | 442 | if (WIN32) |
| 443 | target_compile_definitions(dawn_internal_config INTERFACE "NOMINMAX" "WIN32_LEAN_AND_MEAN") |
| 444 | endif() |
| 445 | |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 446 | ################################################################################ |
Ryan Harrison | e87ac76 | 2022-04-06 15:37:27 -0400 | [diff] [blame] | 447 | # Tint |
| 448 | ################################################################################ |
| 449 | |
Alastair Donaldson | 6a1eb45 | 2021-09-02 23:49:25 +0000 | [diff] [blame] | 450 | set(TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS "" CACHE STRING "Used by OSS-Fuzz to control, via link options, which fuzzing engine should be used") |
| 451 | |
Ben Clayton | fb07fa9 | 2023-11-17 18:48:59 +0000 | [diff] [blame] | 452 | set(TINT_ROOT_SOURCE_DIR ${PROJECT_SOURCE_DIR}) |
Ben Clayton | 3a3cb36 | 2023-08-16 01:05:21 +0000 | [diff] [blame] | 453 | set(TINT_SPIRV_HEADERS_DIR ${DAWN_SPIRV_HEADERS_DIR}) |
| 454 | set(TINT_SPIRV_TOOLS_DIR ${DAWN_SPIRV_TOOLS_DIR}) |
Ben Clayton | 54cfa0b | 2021-07-08 19:35:53 +0000 | [diff] [blame] | 455 | |
Antonio Maiorano | 88d3d2e | 2021-03-23 20:51:09 +0000 | [diff] [blame] | 456 | |
Ryan Harrison | e87ac76 | 2022-04-06 15:37:27 -0400 | [diff] [blame] | 457 | ################################################################################ |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 458 | # Run on all subdirectories |
| 459 | ################################################################################ |
dan sinclair | 0c27cf2 | 2024-06-11 12:31:38 +0000 | [diff] [blame] | 460 | if (DAWN_BUILD_PROTOBUF AND EXISTS "${DAWN_PROTOBUF_DIR}/cmake") |
Ben Clayton | 01fa7c8 | 2024-01-31 21:07:17 +0000 | [diff] [blame] | 461 | if (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") AND WIN32) |
| 462 | set(protobuf_HAVE_BUILTIN_ATOMICS 1) |
| 463 | endif() |
| 464 | |
Ben Clayton | fb07fa9 | 2023-11-17 18:48:59 +0000 | [diff] [blame] | 465 | # Needs to come before SPIR-V Tools |
| 466 | include("third_party/protobuf.cmake") |
| 467 | endif() |
Corentin Wallez | 7fe6efb | 2020-02-05 17:16:05 +0000 | [diff] [blame] | 468 | |
| 469 | add_subdirectory(third_party) |
James Price | 8d9adb0 | 2022-05-22 00:41:53 +0000 | [diff] [blame] | 470 | |
| 471 | # TODO(crbug.com/tint/455): Tint does not currently build with CMake when |
| 472 | # BUILD_SHARED_LIBS=1, so always build it as static for now. |
| 473 | set(BUILD_SHARED_LIBS_SAVED ${BUILD_SHARED_LIBS}) |
| 474 | set(BUILD_SHARED_LIBS 0) |
dan sinclair | d90557b | 2024-08-28 16:15:03 +0000 | [diff] [blame] | 475 | |
| 476 | add_subdirectory(src/utils) |
dan sinclair | 0ee0afa | 2024-10-22 22:58:25 +0000 | [diff] [blame] | 477 | add_subdirectory(src/tint) |
dan sinclair | d90557b | 2024-08-28 16:15:03 +0000 | [diff] [blame] | 478 | |
James Price | 8d9adb0 | 2022-05-22 00:41:53 +0000 | [diff] [blame] | 479 | set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_SAVED}) |
dan sinclair | 12c428f | 2024-06-21 01:14:24 +0000 | [diff] [blame] | 480 | |
Loko Kung | 90fdaa8 | 2024-07-24 00:59:58 +0000 | [diff] [blame] | 481 | 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 OR DAWN_ENABLE_EMSCRIPTEN) |
dan sinclair | 12c428f | 2024-06-21 01:14:24 +0000 | [diff] [blame] | 482 | add_subdirectory(generator) |
Loko Kung | 90fdaa8 | 2024-07-24 00:59:58 +0000 | [diff] [blame] | 483 | # Note that we must add Emscripten directory first to ensure the correct |
| 484 | # headers will be exported upwards. |
| 485 | add_subdirectory(src/emdawnwebgpu) |
dan sinclair | 12c428f | 2024-06-21 01:14:24 +0000 | [diff] [blame] | 486 | add_subdirectory(src/dawn) |
| 487 | endif() |
Ben Clayton | 7b77855 | 2022-02-04 18:59:15 +0000 | [diff] [blame] | 488 | |
| 489 | ################################################################################ |
| 490 | # Samples |
| 491 | ################################################################################ |
dan sinclair | b595052 | 2020-03-19 13:03:35 +0000 | [diff] [blame] | 492 | add_custom_target(tint-lint |
| 493 | COMMAND ./tools/lint |
Ben Clayton | 54cfa0b | 2021-07-08 19:35:53 +0000 | [diff] [blame] | 494 | WORKING_DIRECTORY ${TINT_ROOT_SOURCE_DIR} |
dan sinclair | b595052 | 2020-03-19 13:03:35 +0000 | [diff] [blame] | 495 | COMMENT "Running linter" |
| 496 | VERBATIM) |
| 497 | |
| 498 | add_custom_target(tint-format |
| 499 | COMMAND ./tools/format |
Ben Clayton | 54cfa0b | 2021-07-08 19:35:53 +0000 | [diff] [blame] | 500 | WORKING_DIRECTORY ${TINT_ROOT_SOURCE_DIR} |
dan sinclair | b595052 | 2020-03-19 13:03:35 +0000 | [diff] [blame] | 501 | COMMENT "Running formatter" |
| 502 | VERBATIM) |
Ben Clayton | adb10d6 | 2020-10-27 21:04:59 +0000 | [diff] [blame] | 503 | |
Ben Clayton | 78e4530 | 2023-01-26 15:57:27 +0000 | [diff] [blame] | 504 | if (DAWN_EMIT_COVERAGE) |
| 505 | add_subdirectory(tools/src/cmd/turbo-cov) |
Ben Clayton | adb10d6 | 2020-10-27 21:04:59 +0000 | [diff] [blame] | 506 | |
Ben Clayton | 78e4530 | 2023-01-26 15:57:27 +0000 | [diff] [blame] | 507 | # The tint-generate-coverage target generates a lcov.info file at the project |
| 508 | # root, holding the code coverage for all the tint_unitests. |
Ben Clayton | adb10d6 | 2020-10-27 21:04:59 +0000 | [diff] [blame] | 509 | # This can be used by tools such as VSCode's Coverage Gutters extension to |
| 510 | # visualize code coverage in the editor. |
| 511 | get_filename_component(CLANG_BIN_DIR ${CMAKE_C_COMPILER} DIRECTORY) |
| 512 | set(PATH_WITH_CLANG "${CLANG_BIN_DIR}:$ENV{PATH}") |
| 513 | add_custom_target(tint-generate-coverage |
| 514 | COMMAND ${CMAKE_COMMAND} -E env PATH=${PATH_WITH_CLANG} ./tools/tint-generate-coverage $<TARGET_FILE:tint_unittests> |
| 515 | DEPENDS tint_unittests |
Ben Clayton | 54cfa0b | 2021-07-08 19:35:53 +0000 | [diff] [blame] | 516 | WORKING_DIRECTORY ${TINT_ROOT_SOURCE_DIR} |
Ben Clayton | adb10d6 | 2020-10-27 21:04:59 +0000 | [diff] [blame] | 517 | COMMENT "Generating tint coverage data" |
| 518 | VERBATIM) |
| 519 | endif() |
Jaswant Panchumarti | 5a26bdd | 2024-07-04 14:13:55 +0000 | [diff] [blame] | 520 | |
| 521 | if (DAWN_BUILD_MONOLITHIC_LIBRARY AND DAWN_ENABLE_INSTALL) |
| 522 | # This series of functions add the necessary information so that other CMake projects |
| 523 | # can use Dawn, be it from a build directory, a local install or when packaged. |
| 524 | install(EXPORT DawnTargets |
| 525 | FILE DawnTargets.cmake |
| 526 | NAMESPACE dawn:: |
| 527 | DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Dawn") |
| 528 | export(EXPORT DawnTargets |
| 529 | FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/DawnTargets.cmake" |
| 530 | NAMESPACE dawn:: |
| 531 | ) |
| 532 | # Create a ConfigVersion.cmake file: |
| 533 | include(CMakePackageConfigHelpers) |
| 534 | write_basic_package_version_file( |
| 535 | "${CMAKE_CURRENT_BINARY_DIR}/DawnConfigVersion.cmake" |
| 536 | COMPATIBILITY AnyNewerVersion) |
| 537 | # Configure config file |
| 538 | configure_package_config_file("${CMAKE_CURRENT_LIST_DIR}/src/cmake/DawnConfig.cmake.in" |
| 539 | "${CMAKE_CURRENT_BINARY_DIR}/DawnConfig.cmake" |
| 540 | INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Dawn" |
| 541 | ) |
| 542 | # Install the fully generated config and configVersion files |
| 543 | install(FILES |
| 544 | "${CMAKE_CURRENT_BINARY_DIR}/DawnConfig.cmake" |
| 545 | "${CMAKE_CURRENT_BINARY_DIR}/DawnConfigVersion.cmake" |
| 546 | DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Dawn" |
| 547 | ) |
| 548 | endif () |