2022-04-06 19:37:27 +00:00
|
|
|
# Copyright 2022 The Dawn & Tint Authors
|
2020-02-05 17:16:05 +00:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2020-03-02 20:47:43 +00:00
|
|
|
cmake_minimum_required(VERSION 3.10.2)
|
2020-02-05 17:16:05 +00:00
|
|
|
|
2022-04-19 22:25:45 +00:00
|
|
|
# When upgrading to CMake 3.11 we can remove DAWN_PLACEHOLDER_FILE because source-less add_library
|
2020-02-05 17:16:05 +00:00
|
|
|
# becomes available.
|
|
|
|
# When upgrading to CMake 3.12 we should add CONFIGURE_DEPENDS to DawnGenerator to rerun CMake in
|
2020-04-10 17:04:31 +00:00
|
|
|
# case any of the generator files changes. We should also remove the CACHE "" FORCE stuff to
|
2020-10-20 19:46:21 +00:00
|
|
|
# override options in third_party dependencies. We can also add the HOMEPAGE_URL
|
|
|
|
# entry to the project `HOMEPAGE_URL "https://dawn.googlesource.com/dawn"`
|
2020-02-05 17:16:05 +00:00
|
|
|
|
|
|
|
project(
|
|
|
|
Dawn
|
|
|
|
DESCRIPTION "Dawn, a WebGPU implementation"
|
|
|
|
LANGUAGES C CXX
|
|
|
|
)
|
2020-03-02 20:47:43 +00:00
|
|
|
enable_testing()
|
2020-02-05 17:16:05 +00:00
|
|
|
|
|
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|
|
|
|
2020-03-02 20:47:43 +00:00
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
2022-01-06 09:23:11 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2020-03-02 20:47:43 +00:00
|
|
|
set(CMAKE_DEBUG_POSTFIX "")
|
|
|
|
|
|
|
|
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
|
|
|
message(STATUS "No build type selected, default to Debug")
|
|
|
|
set(CMAKE_BUILD_TYPE "Debug")
|
2020-02-05 17:16:05 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(DAWN_BUILD_GEN_DIR "${Dawn_BINARY_DIR}/gen")
|
|
|
|
set(DAWN_GENERATOR_DIR "${Dawn_SOURCE_DIR}/generator")
|
|
|
|
set(DAWN_SRC_DIR "${Dawn_SOURCE_DIR}/src")
|
2022-02-04 18:18:18 +00:00
|
|
|
set(DAWN_INCLUDE_DIR "${Dawn_SOURCE_DIR}/include")
|
2020-02-05 17:16:05 +00:00
|
|
|
set(DAWN_TEMPLATE_DIR "${DAWN_GENERATOR_DIR}/templates")
|
|
|
|
|
2022-04-19 22:25:45 +00:00
|
|
|
set(DAWN_PLACEHOLDER_FILE "${DAWN_SRC_DIR}/Placeholder.cpp")
|
2020-02-05 17:16:05 +00:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Configuration options
|
|
|
|
################################################################################
|
|
|
|
|
2021-09-24 10:38:18 +00:00
|
|
|
# option_if_not_defined(name description default)
|
|
|
|
# Behaves like:
|
|
|
|
# option(name description default)
|
|
|
|
# If a variable is not already defined with the given name, otherwise the
|
|
|
|
# function does nothing.
|
|
|
|
# Simplifies customization by projects that use Dawn as a dependency.
|
|
|
|
function (option_if_not_defined name description default)
|
|
|
|
if(NOT DEFINED ${name})
|
|
|
|
option(${name} ${description} ${default})
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# set_if_not_defined(name value description)
|
|
|
|
# Behaves like:
|
|
|
|
# set(${name} ${value} CACHE STRING ${description})
|
|
|
|
# If a variable is not already defined with the given name, otherwise the
|
|
|
|
# function does nothing.
|
|
|
|
# Simplifies customization by projects that use Dawn as a dependency.
|
|
|
|
function (set_if_not_defined name value description)
|
|
|
|
if(NOT DEFINED ${name})
|
|
|
|
set(${name} ${value} CACHE STRING ${description})
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2020-02-05 17:16:05 +00:00
|
|
|
# Default values for the backend-enabling options
|
|
|
|
set(ENABLE_D3D12 OFF)
|
|
|
|
set(ENABLE_METAL OFF)
|
2021-06-30 15:06:43 +00:00
|
|
|
set(ENABLE_OPENGLES OFF)
|
|
|
|
set(ENABLE_DESKTOP_GL OFF)
|
2020-02-05 17:16:05 +00:00
|
|
|
set(ENABLE_VULKAN OFF)
|
2022-06-01 09:30:50 +00:00
|
|
|
set(USE_WAYLAND OFF)
|
2020-02-18 02:12:35 +00:00
|
|
|
set(USE_X11 OFF)
|
2022-02-04 18:35:55 +00:00
|
|
|
set(BUILD_SAMPLES OFF)
|
2020-02-05 17:16:05 +00:00
|
|
|
if (WIN32)
|
|
|
|
set(ENABLE_D3D12 ON)
|
2021-06-28 08:19:28 +00:00
|
|
|
if (NOT WINDOWS_STORE)
|
2021-06-24 07:00:16 +00:00
|
|
|
# Enable Vulkan in win32 compilation only
|
|
|
|
# since UWP only supports d3d
|
|
|
|
set(ENABLE_VULKAN ON)
|
|
|
|
endif()
|
2020-02-05 17:16:05 +00:00
|
|
|
elseif(APPLE)
|
|
|
|
set(ENABLE_METAL ON)
|
2022-03-25 13:18:46 +00:00
|
|
|
elseif(ANDROID)
|
|
|
|
set(ENABLE_VULKAN ON)
|
|
|
|
set(ENABLE_OPENGLES ON)
|
2020-02-05 17:16:05 +00:00
|
|
|
elseif(UNIX)
|
2021-06-30 15:06:43 +00:00
|
|
|
set(ENABLE_OPENGLES ON)
|
|
|
|
set(ENABLE_DESKTOP_GL ON)
|
2020-02-05 17:16:05 +00:00
|
|
|
set(ENABLE_VULKAN ON)
|
2020-02-18 02:12:35 +00:00
|
|
|
set(USE_X11 ON)
|
2020-02-05 17:16:05 +00:00
|
|
|
endif()
|
|
|
|
|
2021-06-24 07:00:16 +00:00
|
|
|
# GLFW is not supported in UWP
|
2022-04-06 19:37:27 +00:00
|
|
|
if ((WIN32 AND NOT WINDOWS_STORE) OR UNIX AND NOT ANDROID)
|
2021-06-24 07:00:16 +00:00
|
|
|
set(DAWN_SUPPORTS_GLFW_FOR_WINDOWING ON)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Current examples are depend on GLFW
|
|
|
|
if (DAWN_SUPPORTS_GLFW_FOR_WINDOWING)
|
2022-02-04 18:35:55 +00:00
|
|
|
set(BUILD_SAMPLES ON)
|
2021-06-24 07:00:16 +00:00
|
|
|
endif()
|
|
|
|
|
2022-04-08 18:08:36 +00:00
|
|
|
option_if_not_defined(DAWN_ENABLE_ASAN "Enable address sanitizer" OFF)
|
2022-08-19 21:33:01 +00:00
|
|
|
option_if_not_defined(DAWN_ENABLE_TSAN "Enable thread sanitizer" OFF)
|
|
|
|
option_if_not_defined(DAWN_ENABLE_MSAN "Enable memory sanitizer" OFF)
|
2022-04-08 18:08:36 +00:00
|
|
|
option_if_not_defined(DAWN_ENABLE_UBSAN "Enable undefined behaviour sanitizer" OFF)
|
|
|
|
|
2021-09-24 10:38:18 +00:00
|
|
|
option_if_not_defined(DAWN_ENABLE_D3D12 "Enable compilation of the D3D12 backend" ${ENABLE_D3D12})
|
|
|
|
option_if_not_defined(DAWN_ENABLE_METAL "Enable compilation of the Metal backend" ${ENABLE_METAL})
|
|
|
|
option_if_not_defined(DAWN_ENABLE_NULL "Enable compilation of the Null backend" ON)
|
|
|
|
option_if_not_defined(DAWN_ENABLE_DESKTOP_GL "Enable compilation of the OpenGL backend" ${ENABLE_DESKTOP_GL})
|
|
|
|
option_if_not_defined(DAWN_ENABLE_OPENGLES "Enable compilation of the OpenGL ES backend" ${ENABLE_OPENGLES})
|
|
|
|
option_if_not_defined(DAWN_ENABLE_VULKAN "Enable compilation of the Vulkan backend" ${ENABLE_VULKAN})
|
2022-06-21 17:54:03 +00:00
|
|
|
|
2021-09-24 10:38:18 +00:00
|
|
|
option_if_not_defined(DAWN_ALWAYS_ASSERT "Enable assertions on all build types" OFF)
|
2022-06-01 09:30:50 +00:00
|
|
|
option_if_not_defined(DAWN_USE_WAYLAND "Enable support for Wayland surface" ${USE_WAYLAND})
|
2021-09-24 10:38:18 +00:00
|
|
|
option_if_not_defined(DAWN_USE_X11 "Enable support for X11 surface" ${USE_X11})
|
2020-02-05 17:16:05 +00:00
|
|
|
|
2022-02-04 18:35:55 +00:00
|
|
|
option_if_not_defined(DAWN_BUILD_SAMPLES "Enables building Dawn's samples" ${BUILD_SAMPLES})
|
2021-09-28 11:14:42 +00:00
|
|
|
option_if_not_defined(DAWN_BUILD_NODE_BINDINGS "Enables building Dawn's NodeJS bindings" OFF)
|
2022-04-11 16:48:43 +00:00
|
|
|
option_if_not_defined(DAWN_ENABLE_SWIFTSHADER "Enables building Swiftshader as part of the build and Vulkan adapter discovery" OFF)
|
2021-09-28 11:14:42 +00:00
|
|
|
|
|
|
|
option_if_not_defined(DAWN_ENABLE_PIC "Build with Position-Independent-Code enabled" OFF)
|
2020-02-05 17:16:05 +00:00
|
|
|
|
2022-12-10 00:15:57 +00:00
|
|
|
option_if_not_defined(DAWN_EMIT_COVERAGE "Emit code coverage information" OFF)
|
2022-12-12 21:21:54 +00:00
|
|
|
set_if_not_defined(LLVM_SOURCE_DIR "${Dawn_LLVM_SOURCE_DIR}" "Directory to an LLVM source checkout. Required to build turbo-cov")
|
2022-12-10 00:15:57 +00:00
|
|
|
|
2022-06-21 17:54:03 +00:00
|
|
|
if (DAWN_ENABLE_OPENGLES OR DAWN_ENABLE_DESKTOP_GL)
|
|
|
|
set(TINT_DEFAULT_GLSL ON)
|
|
|
|
else()
|
|
|
|
set(TINT_DEFAULT_GLSL OFF)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
option_if_not_defined(TINT_BUILD_SAMPLES "Build samples" ${DAWN_BUILD_SAMPLES})
|
|
|
|
option_if_not_defined(TINT_BUILD_DOCS "Build documentation" ON)
|
|
|
|
option_if_not_defined(TINT_DOCS_WARN_AS_ERROR "When building documentation, treat warnings as errors" OFF)
|
|
|
|
|
|
|
|
option_if_not_defined(TINT_BUILD_SPV_READER "Build the SPIR-V input reader" ${DAWN_ENABLE_VULKAN})
|
|
|
|
option_if_not_defined(TINT_BUILD_WGSL_READER "Build the WGSL input reader" ON)
|
|
|
|
option_if_not_defined(TINT_BUILD_GLSL_WRITER "Build the GLSL output writer" ${TINT_DEFAULT_GLSL})
|
|
|
|
option_if_not_defined(TINT_BUILD_HLSL_WRITER "Build the HLSL output writer" ${DAWN_ENABLE_D3D12})
|
|
|
|
option_if_not_defined(TINT_BUILD_MSL_WRITER "Build the MSL output writer" ${DAWN_ENABLE_METAL})
|
|
|
|
option_if_not_defined(TINT_BUILD_SPV_WRITER "Build the SPIR-V output writer" ${DAWN_ENABLE_VULKAN})
|
|
|
|
option_if_not_defined(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON)
|
|
|
|
|
2023-03-07 18:28:38 +00:00
|
|
|
option_if_not_defined(TINT_BUILD_SYNTAX_TREE_WRITER "Build the syntax tree writer" OFF)
|
2022-11-01 18:15:50 +00:00
|
|
|
option_if_not_defined(TINT_BUILD_IR "Build the IR" ON)
|
2022-11-01 17:02:31 +00:00
|
|
|
|
2022-06-21 17:54:03 +00:00
|
|
|
option_if_not_defined(TINT_BUILD_FUZZERS "Build fuzzers" OFF)
|
|
|
|
option_if_not_defined(TINT_BUILD_SPIRV_TOOLS_FUZZER "Build SPIRV-Tools fuzzer" OFF)
|
|
|
|
option_if_not_defined(TINT_BUILD_AST_FUZZER "Build AST fuzzer" OFF)
|
|
|
|
option_if_not_defined(TINT_BUILD_REGEX_FUZZER "Build regex fuzzer" OFF)
|
|
|
|
option_if_not_defined(TINT_BUILD_BENCHMARKS "Build benchmarks" OFF)
|
|
|
|
option_if_not_defined(TINT_BUILD_TESTS "Build tests" ON)
|
|
|
|
option_if_not_defined(TINT_BUILD_AS_OTHER_OS "Override OS detection to force building of *_other.cc files" OFF)
|
|
|
|
option_if_not_defined(TINT_BUILD_REMOTE_COMPILE "Build the remote-compile tool for validating shaders on a remote machine" OFF)
|
|
|
|
|
|
|
|
option_if_not_defined(TINT_ENABLE_BREAK_IN_DEBUGGER "Enable tint::debugger::Break()" OFF)
|
|
|
|
option_if_not_defined(TINT_CHECK_CHROMIUM_STYLE "Check for [chromium-style] issues during build" OFF)
|
|
|
|
option_if_not_defined(TINT_SYMBOL_STORE_DEBUG_NAME "Enable storing of name in tint::ast::Symbol to help debugging the AST" OFF)
|
2022-12-13 14:46:02 +00:00
|
|
|
option_if_not_defined(TINT_RANDOMIZE_HASHES "Randomize the hash seed value to detect non-deterministic output" OFF)
|
2020-10-20 14:26:10 +00:00
|
|
|
|
2021-09-23 20:36:03 +00:00
|
|
|
# Recommended setting for compability with future abseil releases.
|
|
|
|
set(ABSL_PROPAGATE_CXX_STD ON)
|
2021-09-24 10:38:18 +00:00
|
|
|
|
2022-06-21 17:54:03 +00:00
|
|
|
set_if_not_defined(DAWN_THIRD_PARTY_DIR "${Dawn_SOURCE_DIR}/third_party" "Directory in which to find third-party dependencies.")
|
2021-09-24 10:38:18 +00:00
|
|
|
set_if_not_defined(DAWN_ABSEIL_DIR "${DAWN_THIRD_PARTY_DIR}/abseil-cpp" "Directory in which to find Abseil")
|
|
|
|
set_if_not_defined(DAWN_GLFW_DIR "${DAWN_THIRD_PARTY_DIR}/glfw" "Directory in which to find GLFW")
|
|
|
|
set_if_not_defined(DAWN_JINJA2_DIR "${DAWN_THIRD_PARTY_DIR}/jinja2" "Directory in which to find Jinja2")
|
2022-06-29 15:29:41 +00:00
|
|
|
set_if_not_defined(DAWN_KHRONOS_DIR "${DAWN_THIRD_PARTY_DIR}/khronos" "Directory in which to find Khronos GL headers")
|
2021-09-24 10:38:18 +00:00
|
|
|
set_if_not_defined(DAWN_SPIRV_HEADERS_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-deps/spirv-headers/src" "Directory in which to find SPIRV-Headers")
|
|
|
|
set_if_not_defined(DAWN_SPIRV_TOOLS_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-deps/spirv-tools/src" "Directory in which to find SPIRV-Tools")
|
2022-04-11 16:48:43 +00:00
|
|
|
set_if_not_defined(DAWN_SWIFTSHADER_DIR "${DAWN_THIRD_PARTY_DIR}/swiftshader" "Directory in which to find swiftshader")
|
2022-04-06 19:37:27 +00:00
|
|
|
set_if_not_defined(DAWN_TINT_DIR "${Dawn_SOURCE_DIR}" "Directory in which to find Tint")
|
2022-04-09 00:10:08 +00:00
|
|
|
set_if_not_defined(DAWN_VULKAN_DEPS_DIR "${DAWN_THIRD_PARTY_DIR}/vulkan-deps" "Directory in which to find vulkan-deps")
|
|
|
|
set_if_not_defined(DAWN_VULKAN_HEADERS_DIR "${DAWN_VULKAN_DEPS_DIR}/vulkan-headers/src" "Directory in which to find Vulkan-Headers")
|
2022-04-13 19:14:46 +00:00
|
|
|
set_if_not_defined(DAWN_VULKAN_TOOLS_DIR "${DAWN_VULKAN_DEPS_DIR}/vulkan-tools/src" "Directory in which to find Vulkan-Tools")
|
2020-02-05 17:16:05 +00:00
|
|
|
|
2021-09-28 11:14:42 +00:00
|
|
|
# Dependencies for DAWN_BUILD_NODE_BINDINGS
|
|
|
|
set_if_not_defined(NODE_ADDON_API_DIR "${DAWN_THIRD_PARTY_DIR}/node-addon-api" "Directory in which to find node-addon-api")
|
2021-09-30 18:04:01 +00:00
|
|
|
set_if_not_defined(NODE_API_HEADERS_DIR "${DAWN_THIRD_PARTY_DIR}/node-api-headers" "Directory in which to find node-api-headers")
|
2021-09-28 11:14:42 +00:00
|
|
|
set_if_not_defined(WEBGPU_IDL_PATH "${DAWN_THIRD_PARTY_DIR}/gpuweb/webgpu.idl" "Path to the webgpu.idl definition file")
|
2021-10-15 14:28:32 +00:00
|
|
|
set_if_not_defined(GO_EXECUTABLE "go" "Golang executable for running the IDL generator")
|
2021-09-28 11:14:42 +00:00
|
|
|
|
2021-06-30 15:06:43 +00:00
|
|
|
# Much of the backend code is shared among desktop OpenGL and OpenGL ES
|
|
|
|
if (${DAWN_ENABLE_DESKTOP_GL} OR ${DAWN_ENABLE_OPENGLES})
|
|
|
|
set(DAWN_ENABLE_OPENGL ON)
|
|
|
|
endif()
|
|
|
|
|
2021-09-28 11:14:42 +00:00
|
|
|
if(DAWN_ENABLE_PIC)
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
endif()
|
|
|
|
|
2022-06-21 17:54:03 +00:00
|
|
|
if (${TINT_BUILD_SPIRV_TOOLS_FUZZER})
|
|
|
|
message(STATUS "TINT_BUILD_SPIRV_TOOLS_FUZZER is ON - setting
|
|
|
|
TINT_BUILD_FUZZERS
|
|
|
|
TINT_BUILD_SPV_READER
|
|
|
|
TINT_BUILD_SPV_WRITER
|
|
|
|
TINT_BUILD_WGSL_READER
|
|
|
|
TINT_BUILD_WGSL_WRITER
|
|
|
|
TINT_BUILD_GLSL_WRITER
|
|
|
|
TINT_BUILD_HLSL_WRITER
|
|
|
|
TINT_BUILD_MSL_WRITER to ON")
|
|
|
|
set(TINT_BUILD_FUZZERS ON CACHE BOOL "Build tint fuzzers" FORCE)
|
|
|
|
set(TINT_BUILD_SPV_READER ON CACHE BOOL "Build SPIR-V reader" FORCE)
|
|
|
|
set(TINT_BUILD_SPV_WRITER ON CACHE BOOL "Build SPIR-V writer" FORCE)
|
|
|
|
set(TINT_BUILD_WGSL_READER ON CACHE BOOL "Build WGSL reader" FORCE)
|
|
|
|
set(TINT_BUILD_WGSL_WRITER ON CACHE BOOL "Build WGSL writer" FORCE)
|
|
|
|
set(TINT_BUILD_GLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE)
|
|
|
|
set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE)
|
|
|
|
set(TINT_BUILD_MSL_WRITER ON CACHE BOOL "Build MSL writer" FORCE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (${TINT_BUILD_AST_FUZZER})
|
|
|
|
message(STATUS "TINT_BUILD_AST_FUZZER is ON - setting
|
|
|
|
TINT_BUILD_FUZZERS
|
|
|
|
TINT_BUILD_WGSL_READER
|
|
|
|
TINT_BUILD_WGSL_WRITER
|
|
|
|
TINT_BUILD_SPV_WRITER
|
|
|
|
TINT_BUILD_MSL_WRITER
|
|
|
|
TINT_BUILD_GLSL_WRITER
|
|
|
|
TINT_BUILD_HLSL_WRITER to ON")
|
|
|
|
set(TINT_BUILD_FUZZERS ON CACHE BOOL "Build tint fuzzers" FORCE)
|
|
|
|
set(TINT_BUILD_WGSL_READER ON CACHE BOOL "Build WGSL reader" FORCE)
|
|
|
|
set(TINT_BUILD_WGSL_WRITER ON CACHE BOOL "Build WGSL writer" FORCE)
|
|
|
|
set(TINT_BUILD_SPV_WRITER ON CACHE BOOL "Build SPIR-V writer" FORCE)
|
|
|
|
set(TINT_BUILD_MSL_WRITER ON CACHE BOOL "Build MSL writer" FORCE)
|
|
|
|
set(TINT_BUILD_GLSL_WRITER ON CACHE BOOL "Build GLSL writer" FORCE)
|
|
|
|
set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (${TINT_BUILD_REGEX_FUZZER})
|
|
|
|
message(STATUS "TINT_BUILD_REGEX_FUZZER is ON - setting
|
|
|
|
TINT_BUILD_FUZZERS
|
|
|
|
TINT_BUILD_WGSL_READER
|
|
|
|
TINT_BUILD_WGSL_WRITER
|
|
|
|
TINT_BUILD_SPV_WRITER
|
|
|
|
TINT_BUILD_MSL_WRITER
|
|
|
|
TINT_BUILD_GLSL_WRITER
|
|
|
|
TINT_BUILD_HLSL_WRITER to ON")
|
|
|
|
set(TINT_BUILD_FUZZERS ON CACHE BOOL "Build tint fuzzers" FORCE)
|
|
|
|
set(TINT_BUILD_WGSL_READER ON CACHE BOOL "Build WGSL reader" FORCE)
|
|
|
|
set(TINT_BUILD_WGSL_WRITER ON CACHE BOOL "Build WGSL writer" FORCE)
|
|
|
|
set(TINT_BUILD_SPV_WRITER ON CACHE BOOL "Build SPIR-V writer" FORCE)
|
|
|
|
set(TINT_BUILD_MSL_WRITER ON CACHE BOOL "Build MSL writer" FORCE)
|
|
|
|
set(TINT_BUILD_GLSL_WRITER ON CACHE BOOL "Build GLSL writer" FORCE)
|
|
|
|
set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
message(STATUS "Dawn build D3D12 backend: ${DAWN_ENABLE_D3D12}")
|
|
|
|
message(STATUS "Dawn build Metal backend: ${DAWN_ENABLE_METAL}")
|
|
|
|
message(STATUS "Dawn build Vulkan backend: ${DAWN_ENABLE_VULKAN}")
|
|
|
|
message(STATUS "Dawn build OpenGL backend: ${DAWN_ENABLE_DESKTOP_GL}")
|
|
|
|
message(STATUS "Dawn build OpenGL ES backend: ${DAWN_ENABLE_OPENGLES}")
|
|
|
|
message(STATUS "Dawn build Null backend: ${DAWN_ENABLE_NULL}")
|
|
|
|
|
|
|
|
message(STATUS "Dawn build with asserts in all configurations: ${DAWN_ALWAYS_ASSERT}")
|
|
|
|
message(STATUS "Dawn build Wayland support: ${DAWN_USE_WAYLAND}")
|
|
|
|
message(STATUS "Dawn build X11 support: ${DAWN_USE_X11}")
|
|
|
|
|
|
|
|
message(STATUS "Dawn build samples: ${DAWN_BUILD_SAMPLES}")
|
|
|
|
message(STATUS "Dawn build Node bindings: ${DAWN_BUILD_NODE_BINDINGS}")
|
|
|
|
message(STATUS "Dawn build Swiftshader: ${DAWN_ENABLE_SWIFTSHADER}")
|
|
|
|
|
|
|
|
message(STATUS "Dawn build PIC: ${DAWN_ENABLE_PIC}")
|
|
|
|
|
|
|
|
message(STATUS "Dawn build with ASAN: ${DAWN_ENABLE_ASAN}")
|
2022-08-19 21:33:01 +00:00
|
|
|
message(STATUS "Dawn build with TSAN: ${DAWN_ENABLE_TSAN}")
|
2022-06-21 17:54:03 +00:00
|
|
|
message(STATUS "Dawn build with MSAN: ${DAWN_ENABLE_MSAN}")
|
|
|
|
message(STATUS "Dawn build with UBSAN: ${DAWN_ENABLE_UBSAN}")
|
|
|
|
|
|
|
|
message(STATUS "Tint build samples: ${TINT_BUILD_SAMPLES}")
|
|
|
|
message(STATUS "Tint build docs: ${TINT_BUILD_DOCS}")
|
|
|
|
message(STATUS "Tint build docs with warn as error: ${TINT_DOCS_WARN_AS_ERROR}")
|
|
|
|
message(STATUS "Tint build SPIR-V reader: ${TINT_BUILD_SPV_READER}")
|
|
|
|
message(STATUS "Tint build WGSL reader: ${TINT_BUILD_WGSL_READER}")
|
|
|
|
message(STATUS "Tint build GLSL writer: ${TINT_BUILD_GLSL_WRITER}")
|
|
|
|
message(STATUS "Tint build HLSL writer: ${TINT_BUILD_HLSL_WRITER}")
|
|
|
|
message(STATUS "Tint build MSL writer: ${TINT_BUILD_MSL_WRITER}")
|
|
|
|
message(STATUS "Tint build SPIR-V writer: ${TINT_BUILD_SPV_WRITER}")
|
|
|
|
message(STATUS "Tint build WGSL writer: ${TINT_BUILD_WGSL_WRITER}")
|
2023-03-07 18:28:38 +00:00
|
|
|
message(STATUS "Tint build Syntax Tree writer: ${TINT_BUILD_SYNTAX_TREE_WRITER}")
|
2022-11-01 18:15:50 +00:00
|
|
|
message(STATUS "Tint build IR: ${TINT_BUILD_IR}")
|
2022-06-21 17:54:03 +00:00
|
|
|
message(STATUS "Tint build fuzzers: ${TINT_BUILD_FUZZERS}")
|
|
|
|
message(STATUS "Tint build SPIRV-Tools fuzzer: ${TINT_BUILD_SPIRV_TOOLS_FUZZER}")
|
|
|
|
message(STATUS "Tint build AST fuzzer: ${TINT_BUILD_AST_FUZZER}")
|
|
|
|
message(STATUS "Tint build regex fuzzer: ${TINT_BUILD_REGEX_FUZZER}")
|
|
|
|
message(STATUS "Tint build benchmarks: ${TINT_BUILD_BENCHMARKS}")
|
|
|
|
message(STATUS "Tint build tests: ${TINT_BUILD_TESTS}")
|
|
|
|
message(STATUS "Tint build checking [chromium-style]: ${TINT_CHECK_CHROMIUM_STYLE}")
|
|
|
|
message(STATUS "Tint build remote-compile tool: ${TINT_BUILD_REMOTE_COMPILE}")
|
|
|
|
|
|
|
|
if (NOT ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS} STREQUAL "")
|
|
|
|
message(STATUS "Using provided LIB_FUZZING_ENGINE options: ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
message(STATUS "Using python3")
|
|
|
|
find_package(PythonInterp 3 REQUIRED)
|
|
|
|
|
2022-04-08 18:08:36 +00:00
|
|
|
################################################################################
|
|
|
|
# common_compile_options - sets compiler and linker options common for dawn and
|
|
|
|
# tint on the given target
|
|
|
|
################################################################################
|
|
|
|
function(common_compile_options TARGET)
|
|
|
|
if (COMPILER_IS_LIKE_GNU)
|
|
|
|
target_compile_options(${TARGET} PRIVATE
|
|
|
|
-fno-exceptions
|
|
|
|
-fno-rtti
|
2023-01-07 23:09:14 +00:00
|
|
|
|
|
|
|
-Wno-deprecated-builtins
|
2023-01-09 15:10:33 +00:00
|
|
|
-Wno-unknown-warning-option
|
2022-04-08 18:08:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
if (${DAWN_ENABLE_MSAN})
|
2022-08-19 21:33:01 +00:00
|
|
|
target_compile_options(${TARGET} PUBLIC -fsanitize=memory)
|
|
|
|
target_link_options(${TARGET} PUBLIC -fsanitize=memory)
|
2022-04-08 18:08:36 +00:00
|
|
|
elseif (${DAWN_ENABLE_ASAN})
|
2022-08-19 21:33:01 +00:00
|
|
|
target_compile_options(${TARGET} PUBLIC -fsanitize=address)
|
|
|
|
target_link_options(${TARGET} PUBLIC -fsanitize=address)
|
|
|
|
elseif (${DAWN_ENABLE_TSAN})
|
|
|
|
target_compile_options(${TARGET} PUBLIC -fsanitize=thread)
|
|
|
|
target_link_options(${TARGET} PUBLIC -fsanitize=thread)
|
2022-04-08 18:08:36 +00:00
|
|
|
elseif (${DAWN_ENABLE_UBSAN})
|
2023-03-24 18:44:02 +00:00
|
|
|
target_compile_options(${TARGET} PUBLIC -fsanitize=undefined -fsanitize=float-divide-by-zero)
|
|
|
|
target_link_options(${TARGET} PUBLIC -fsanitize=undefined -fsanitize=float-divide-by-zero)
|
2022-04-08 18:08:36 +00:00
|
|
|
endif()
|
|
|
|
endif(COMPILER_IS_LIKE_GNU)
|
2022-09-14 16:41:07 +00:00
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
target_compile_options(${TARGET} PUBLIC /utf-8)
|
|
|
|
endif()
|
2022-12-10 00:15:57 +00:00
|
|
|
|
|
|
|
if (DAWN_EMIT_COVERAGE)
|
2023-01-10 21:55:43 +00:00
|
|
|
target_compile_definitions(${TARGET} PRIVATE "DAWN_EMIT_COVERAGE")
|
2022-12-10 00:15:57 +00:00
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|
|
|
target_compile_options(${TARGET} PRIVATE "--coverage")
|
|
|
|
target_link_options(${TARGET} PRIVATE "gcov")
|
2023-01-26 15:57:27 +00:00
|
|
|
elseif(COMPILER_IS_CLANG OR COMPILER_IS_CLANG_CL)
|
2022-12-10 00:15:57 +00:00
|
|
|
target_compile_options(${TARGET} PRIVATE "-fprofile-instr-generate" "-fcoverage-mapping")
|
|
|
|
target_link_options(${TARGET} PRIVATE "-fprofile-instr-generate" "-fcoverage-mapping")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Coverage generation not supported for the ${CMAKE_CXX_COMPILER_ID} toolchain")
|
|
|
|
endif()
|
|
|
|
endif(DAWN_EMIT_COVERAGE)
|
2022-04-08 18:08:36 +00:00
|
|
|
endfunction()
|
|
|
|
|
2022-08-19 21:33:01 +00:00
|
|
|
if (${DAWN_ENABLE_TSAN})
|
|
|
|
add_compile_options(-stdlib=libc++)
|
|
|
|
add_link_options(-stdlib=libc++)
|
|
|
|
endif()
|
|
|
|
|
2020-02-05 17:16:05 +00:00
|
|
|
################################################################################
|
|
|
|
# Dawn's public and internal "configs"
|
|
|
|
################################################################################
|
|
|
|
|
2022-11-09 20:55:33 +00:00
|
|
|
set(IS_DEBUG_BUILD 0)
|
|
|
|
string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type)
|
|
|
|
if ((NOT ${build_type} STREQUAL "RELEASE") AND (NOT ${build_type} STREQUAL "RELWITHDEBINFO"))
|
|
|
|
set(IS_DEBUG_BUILD 1)
|
|
|
|
endif()
|
|
|
|
|
2020-02-05 17:16:05 +00:00
|
|
|
# The public config contains only the include paths for the Dawn headers.
|
|
|
|
add_library(dawn_public_config INTERFACE)
|
|
|
|
target_include_directories(dawn_public_config INTERFACE
|
2022-02-04 18:18:18 +00:00
|
|
|
"${DAWN_INCLUDE_DIR}"
|
|
|
|
"${DAWN_BUILD_GEN_DIR}/include"
|
2020-02-05 17:16:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# The internal config conatins additional path but includes the dawn_public_config include paths
|
|
|
|
add_library(dawn_internal_config INTERFACE)
|
|
|
|
target_include_directories(dawn_internal_config INTERFACE
|
|
|
|
"${DAWN_SRC_DIR}"
|
|
|
|
"${DAWN_BUILD_GEN_DIR}/src"
|
|
|
|
)
|
|
|
|
target_link_libraries(dawn_internal_config INTERFACE dawn_public_config)
|
|
|
|
|
|
|
|
# Compile definitions for the internal config
|
2022-11-09 20:55:33 +00:00
|
|
|
if (DAWN_ALWAYS_ASSERT OR IS_DEBUG_BUILD)
|
2020-02-05 17:16:05 +00:00
|
|
|
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_ASSERTS")
|
|
|
|
endif()
|
|
|
|
if (DAWN_ENABLE_D3D12)
|
|
|
|
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_D3D12")
|
|
|
|
endif()
|
|
|
|
if (DAWN_ENABLE_METAL)
|
|
|
|
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_METAL")
|
|
|
|
endif()
|
|
|
|
if (DAWN_ENABLE_NULL)
|
|
|
|
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_NULL")
|
|
|
|
endif()
|
2021-06-30 15:06:43 +00:00
|
|
|
if (DAWN_ENABLE_DESKTOP_GL)
|
|
|
|
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_DESKTOP_GL")
|
|
|
|
endif()
|
|
|
|
if (DAWN_ENABLE_OPENGLES)
|
|
|
|
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_OPENGLES")
|
|
|
|
endif()
|
2020-02-05 17:16:05 +00:00
|
|
|
if (DAWN_ENABLE_OPENGL)
|
|
|
|
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_OPENGL")
|
|
|
|
endif()
|
|
|
|
if (DAWN_ENABLE_VULKAN)
|
|
|
|
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_VULKAN")
|
|
|
|
endif()
|
2022-06-01 09:30:50 +00:00
|
|
|
if (DAWN_USE_WAYLAND)
|
|
|
|
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_WAYLAND")
|
|
|
|
endif()
|
2020-02-18 02:12:35 +00:00
|
|
|
if (DAWN_USE_X11)
|
2020-02-05 17:16:05 +00:00
|
|
|
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_X11")
|
|
|
|
endif()
|
2020-02-24 13:27:28 +00:00
|
|
|
if (WIN32)
|
|
|
|
target_compile_definitions(dawn_internal_config INTERFACE "NOMINMAX" "WIN32_LEAN_AND_MEAN")
|
|
|
|
endif()
|
|
|
|
|
2022-01-05 09:26:46 +00:00
|
|
|
set(CMAKE_CXX_STANDARD "17")
|
2020-02-05 17:16:05 +00:00
|
|
|
|
2022-04-06 19:37:27 +00:00
|
|
|
################################################################################
|
|
|
|
# Tint
|
|
|
|
################################################################################
|
|
|
|
|
2021-09-02 23:49:25 +00:00
|
|
|
set(TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS "" CACHE STRING "Used by OSS-Fuzz to control, via link options, which fuzzing engine should be used")
|
|
|
|
|
2021-07-08 19:35:53 +00:00
|
|
|
set(TINT_ROOT_SOURCE_DIR ${PROJECT_SOURCE_DIR})
|
|
|
|
|
2021-03-17 13:32:54 +00:00
|
|
|
# CMake < 3.15 sets /W3 in CMAKE_CXX_FLAGS. Remove it if it's there.
|
|
|
|
# See https://gitlab.kitware.com/cmake/cmake/-/issues/18317
|
|
|
|
if (MSVC)
|
2021-06-24 18:10:46 +00:00
|
|
|
if (CMAKE_CXX_FLAGS MATCHES "/W3")
|
|
|
|
string(REPLACE "/W3" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
|
|
endif()
|
2021-03-17 13:32:54 +00:00
|
|
|
endif()
|
|
|
|
|
2020-04-28 19:27:38 +00:00
|
|
|
if (${TINT_CHECK_CHROMIUM_STYLE})
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -add-plugin -Xclang find-bad-constructs")
|
|
|
|
endif()
|
|
|
|
|
2020-03-18 14:08:48 +00:00
|
|
|
if (${TINT_BUILD_SPV_READER})
|
2022-04-06 19:37:27 +00:00
|
|
|
include_directories("${DAWN_THIRD_PARTY_DIR}/vulkan-deps/spirv-tools/include")
|
2020-03-02 20:47:43 +00:00
|
|
|
endif()
|
|
|
|
|
2021-03-23 20:51:09 +00:00
|
|
|
if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))
|
|
|
|
set(COMPILER_IS_CLANG_CL TRUE)
|
|
|
|
endif()
|
|
|
|
|
2023-01-26 15:57:27 +00:00
|
|
|
if((CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") OR
|
2021-03-23 20:51:09 +00:00
|
|
|
((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND
|
|
|
|
(NOT COMPILER_IS_CLANG_CL)))
|
2023-01-26 15:57:27 +00:00
|
|
|
set(COMPILER_IS_CLANG TRUE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR COMPILER_IS_CLANG)
|
2020-03-02 20:47:43 +00:00
|
|
|
set(COMPILER_IS_LIKE_GNU TRUE)
|
|
|
|
endif()
|
|
|
|
|
2021-03-23 20:51:09 +00:00
|
|
|
# Enable msbuild multiprocessor builds
|
|
|
|
if (MSVC AND NOT COMPILER_IS_CLANG_CL)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
|
|
|
endif()
|
|
|
|
|
2021-04-16 14:43:34 +00:00
|
|
|
set(TINT_OS_CC_SUFFIX "other")
|
|
|
|
if (NOT TINT_BUILD_AS_OTHER_OS)
|
|
|
|
if(UNIX OR APPLE)
|
|
|
|
set(TINT_OS_CC_SUFFIX "posix")
|
|
|
|
set(TINT_OS_CC_SUFFIX "posix")
|
|
|
|
elseif(WIN32)
|
|
|
|
set(TINT_OS_CC_SUFFIX "windows")
|
|
|
|
set(TINT_OS_CC_SUFFIX "windows")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-06-26 22:29:27 +00:00
|
|
|
if(${TINT_BUILD_DOCS})
|
|
|
|
find_package(Doxygen)
|
|
|
|
if(DOXYGEN_FOUND)
|
2021-06-25 14:00:36 +00:00
|
|
|
set(DOXYGEN_WARN_AS_ERROR NO)
|
|
|
|
if(TINT_DOCS_WARN_AS_ERROR)
|
|
|
|
set(DOXYGEN_WARN_AS_ERROR YES)
|
|
|
|
endif()
|
2021-06-25 14:53:06 +00:00
|
|
|
|
|
|
|
set(DOXYGEN_WARN_FORMAT "$file:$line: $text")
|
|
|
|
if (MSVC)
|
|
|
|
set(DOXYGEN_WARN_FORMAT "$file($line): $text")
|
|
|
|
endif()
|
|
|
|
|
2020-06-26 22:29:27 +00:00
|
|
|
add_custom_target(tint-docs ALL
|
2021-05-12 08:15:41 +00:00
|
|
|
COMMAND ${CMAKE_COMMAND}
|
2021-06-25 14:00:36 +00:00
|
|
|
-E env
|
|
|
|
"DOXYGEN_OUTPUT_DIRECTORY=${CMAKE_BINARY_DIR}/docs"
|
|
|
|
"DOXYGEN_WARN_AS_ERROR=${DOXYGEN_WARN_AS_ERROR}"
|
2021-06-25 14:53:06 +00:00
|
|
|
"DOXYGEN_WARN_FORMAT=${DOXYGEN_WARN_FORMAT}"
|
2021-05-12 08:15:41 +00:00
|
|
|
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile
|
2020-06-26 22:29:27 +00:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
COMMENT "Generating API documentation"
|
|
|
|
VERBATIM)
|
|
|
|
else()
|
|
|
|
message("Doxygen not found. Skipping documentation")
|
|
|
|
endif(DOXYGEN_FOUND)
|
2020-07-15 20:54:48 +00:00
|
|
|
endif()
|
2020-03-02 20:47:43 +00:00
|
|
|
|
2022-01-18 18:58:16 +00:00
|
|
|
function(tint_core_compile_options TARGET)
|
2021-07-08 19:35:53 +00:00
|
|
|
target_include_directories(${TARGET} PUBLIC "${TINT_ROOT_SOURCE_DIR}")
|
|
|
|
target_include_directories(${TARGET} PUBLIC "${TINT_ROOT_SOURCE_DIR}/include")
|
2020-10-23 17:04:10 +00:00
|
|
|
|
|
|
|
if (${TINT_BUILD_SPV_READER} OR ${TINT_BUILD_SPV_WRITER})
|
|
|
|
target_include_directories(${TARGET} PUBLIC
|
2022-04-06 19:37:27 +00:00
|
|
|
"${DAWN_THIRD_PARTY_DIR}/spirv-headers/include")
|
2020-10-23 17:04:10 +00:00
|
|
|
endif()
|
2020-03-02 20:47:43 +00:00
|
|
|
|
2022-01-18 18:58:16 +00:00
|
|
|
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_SPV_READER=$<BOOL:${TINT_BUILD_SPV_READER}>)
|
|
|
|
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_WGSL_READER=$<BOOL:${TINT_BUILD_WGSL_READER}>)
|
|
|
|
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_GLSL_WRITER=$<BOOL:${TINT_BUILD_GLSL_WRITER}>)
|
|
|
|
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_HLSL_WRITER=$<BOOL:${TINT_BUILD_HLSL_WRITER}>)
|
|
|
|
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_MSL_WRITER=$<BOOL:${TINT_BUILD_MSL_WRITER}>)
|
|
|
|
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_SPV_WRITER=$<BOOL:${TINT_BUILD_SPV_WRITER}>)
|
|
|
|
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_WGSL_WRITER=$<BOOL:${TINT_BUILD_WGSL_WRITER}>)
|
2023-03-07 18:28:38 +00:00
|
|
|
target_compile_definitions(${TARGET} PUBLIC
|
|
|
|
-DTINT_BUILD_SYNTAX_TREE_WRITER=$<BOOL:${TINT_BUILD_SYNTAX_TREE_WRITER}>)
|
2022-11-01 18:15:50 +00:00
|
|
|
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_IR=$<BOOL:${TINT_BUILD_IR}>)
|
2022-01-18 18:58:16 +00:00
|
|
|
|
2022-04-08 18:08:36 +00:00
|
|
|
common_compile_options(${TARGET})
|
2022-01-18 18:58:16 +00:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(tint_default_compile_options TARGET)
|
|
|
|
tint_core_compile_options(${TARGET})
|
2020-03-11 18:43:12 +00:00
|
|
|
|
2021-04-27 19:24:47 +00:00
|
|
|
set(COMMON_GNU_OPTIONS
|
|
|
|
-Wall
|
|
|
|
-Werror
|
|
|
|
-Wextra
|
|
|
|
-Wno-documentation-unknown-command
|
|
|
|
-Wno-padded
|
|
|
|
-Wno-switch-enum
|
|
|
|
-Wno-unknown-pragmas
|
|
|
|
)
|
|
|
|
|
|
|
|
set(COMMON_CLANG_OPTIONS
|
|
|
|
-Wno-c++98-compat
|
|
|
|
-Wno-c++98-compat-pedantic
|
|
|
|
-Wno-format-pedantic
|
2022-11-23 15:50:49 +00:00
|
|
|
-Wno-poison-system-directories
|
2021-04-27 19:24:47 +00:00
|
|
|
-Wno-return-std-move-in-c++11
|
|
|
|
-Wno-unknown-warning-option
|
|
|
|
-Wno-undefined-var-template
|
2023-01-07 23:09:14 +00:00
|
|
|
-Wno-unsafe-buffer-usage
|
2021-04-27 19:24:47 +00:00
|
|
|
-Wno-used-but-marked-unused
|
|
|
|
-Weverything
|
|
|
|
)
|
|
|
|
|
2022-01-18 18:58:16 +00:00
|
|
|
if (COMPILER_IS_LIKE_GNU)
|
2020-03-02 20:47:43 +00:00
|
|
|
target_compile_options(${TARGET} PRIVATE
|
|
|
|
-pedantic-errors
|
2021-04-27 19:24:47 +00:00
|
|
|
${COMMON_GNU_OPTIONS}
|
2020-03-02 20:47:43 +00:00
|
|
|
)
|
|
|
|
|
2023-01-26 15:57:27 +00:00
|
|
|
if (COMPILER_IS_CLANG)
|
2020-03-02 20:47:43 +00:00
|
|
|
target_compile_options(${TARGET} PRIVATE
|
2021-04-27 19:24:47 +00:00
|
|
|
${COMMON_CLANG_OPTIONS}
|
2020-03-02 20:47:43 +00:00
|
|
|
)
|
|
|
|
endif()
|
2022-01-18 18:58:16 +00:00
|
|
|
endif(COMPILER_IS_LIKE_GNU)
|
2020-10-27 21:04:59 +00:00
|
|
|
|
2020-03-02 20:47:43 +00:00
|
|
|
if (MSVC)
|
|
|
|
# Specify /EHs for exception handling.
|
|
|
|
target_compile_options(${TARGET} PRIVATE
|
|
|
|
/bigobj
|
|
|
|
/EHsc
|
2021-03-16 15:05:33 +00:00
|
|
|
/W4
|
2020-03-02 20:47:43 +00:00
|
|
|
/WX
|
|
|
|
/wd4068
|
2021-03-17 13:32:54 +00:00
|
|
|
/wd4127
|
2020-05-04 18:58:24 +00:00
|
|
|
/wd4244
|
|
|
|
/wd4267
|
2021-03-23 14:03:58 +00:00
|
|
|
/wd4324
|
2021-03-17 13:32:54 +00:00
|
|
|
/wd4458
|
2020-03-02 20:47:43 +00:00
|
|
|
/wd4514
|
|
|
|
/wd4571
|
|
|
|
/wd4625
|
|
|
|
/wd4626
|
|
|
|
/wd4710
|
|
|
|
/wd4774
|
|
|
|
/wd4820
|
|
|
|
/wd5026
|
|
|
|
/wd5027
|
|
|
|
)
|
2021-04-27 19:24:47 +00:00
|
|
|
|
|
|
|
# When building with clang-cl on Windows, try to match our clang build
|
|
|
|
# options as much as possible.
|
|
|
|
if (COMPILER_IS_CLANG_CL)
|
|
|
|
target_compile_options(${TARGET} PRIVATE
|
|
|
|
${COMMON_GNU_OPTIONS}
|
|
|
|
${COMMON_CLANG_OPTIONS}
|
|
|
|
# Disable warnings that are usually disabled in downstream deps for
|
|
|
|
# gcc/clang, but aren't for clang-cl.
|
|
|
|
-Wno-global-constructors
|
|
|
|
-Wno-zero-as-null-pointer-constant
|
|
|
|
-Wno-shorten-64-to-32
|
2021-12-20 21:39:35 +00:00
|
|
|
-Wno-shadow-field-in-constructor
|
|
|
|
-Wno-reserved-id-macro
|
2022-02-04 23:24:43 +00:00
|
|
|
-Wno-language-extension-token
|
2021-04-27 19:24:47 +00:00
|
|
|
)
|
|
|
|
endif()
|
2020-03-02 20:47:43 +00:00
|
|
|
endif()
|
2022-12-13 14:46:02 +00:00
|
|
|
|
|
|
|
if (TINT_RANDOMIZE_HASHES)
|
|
|
|
if(NOT DEFINED TINT_HASH_SEED)
|
|
|
|
string(RANDOM LENGTH 16 ALPHABET "0123456789abcdef" seed)
|
|
|
|
set(TINT_HASH_SEED "0x${seed}" CACHE STRING "Tint hash seed value")
|
|
|
|
message("Using TINT_HASH_SEED: ${TINT_HASH_SEED}")
|
|
|
|
endif()
|
|
|
|
target_compile_definitions(${TARGET} PUBLIC "-DTINT_HASH_SEED=${TINT_HASH_SEED}")
|
|
|
|
endif()
|
2020-03-02 20:47:43 +00:00
|
|
|
endfunction()
|
|
|
|
|
2020-02-05 17:16:05 +00:00
|
|
|
################################################################################
|
|
|
|
# Run on all subdirectories
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
add_subdirectory(third_party)
|
2022-05-22 00:41:53 +00:00
|
|
|
|
|
|
|
# TODO(crbug.com/tint/455): Tint does not currently build with CMake when
|
|
|
|
# BUILD_SHARED_LIBS=1, so always build it as static for now.
|
|
|
|
set(BUILD_SHARED_LIBS_SAVED ${BUILD_SHARED_LIBS})
|
|
|
|
set(BUILD_SHARED_LIBS 0)
|
2022-02-21 15:19:07 +00:00
|
|
|
add_subdirectory(src/tint)
|
2022-05-22 00:41:53 +00:00
|
|
|
set(BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS_SAVED})
|
|
|
|
|
2020-02-05 17:16:05 +00:00
|
|
|
add_subdirectory(generator)
|
|
|
|
add_subdirectory(src/dawn)
|
2022-02-04 18:59:15 +00:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Samples
|
|
|
|
################################################################################
|
2020-02-05 17:16:05 +00:00
|
|
|
|
2021-08-31 18:43:36 +00:00
|
|
|
if (TINT_BUILD_SAMPLES)
|
2022-02-21 15:19:07 +00:00
|
|
|
add_subdirectory(src/tint/cmd)
|
2021-08-31 18:43:36 +00:00
|
|
|
endif()
|
2020-03-02 20:47:43 +00:00
|
|
|
|
2021-08-31 18:43:36 +00:00
|
|
|
if (TINT_BUILD_FUZZERS)
|
2022-02-21 15:19:07 +00:00
|
|
|
add_subdirectory(src/tint/fuzzers)
|
2020-03-02 20:47:43 +00:00
|
|
|
endif()
|
|
|
|
|
2020-03-19 13:03:35 +00:00
|
|
|
add_custom_target(tint-lint
|
|
|
|
COMMAND ./tools/lint
|
2021-07-08 19:35:53 +00:00
|
|
|
WORKING_DIRECTORY ${TINT_ROOT_SOURCE_DIR}
|
2020-03-19 13:03:35 +00:00
|
|
|
COMMENT "Running linter"
|
|
|
|
VERBATIM)
|
|
|
|
|
|
|
|
add_custom_target(tint-format
|
|
|
|
COMMAND ./tools/format
|
2021-07-08 19:35:53 +00:00
|
|
|
WORKING_DIRECTORY ${TINT_ROOT_SOURCE_DIR}
|
2020-03-19 13:03:35 +00:00
|
|
|
COMMENT "Running formatter"
|
|
|
|
VERBATIM)
|
2020-10-27 21:04:59 +00:00
|
|
|
|
2023-01-26 15:57:27 +00:00
|
|
|
if (DAWN_EMIT_COVERAGE)
|
|
|
|
add_subdirectory(tools/src/cmd/turbo-cov)
|
2020-10-27 21:04:59 +00:00
|
|
|
|
2023-01-26 15:57:27 +00:00
|
|
|
# The tint-generate-coverage target generates a lcov.info file at the project
|
|
|
|
# root, holding the code coverage for all the tint_unitests.
|
2020-10-27 21:04:59 +00:00
|
|
|
# This can be used by tools such as VSCode's Coverage Gutters extension to
|
|
|
|
# visualize code coverage in the editor.
|
|
|
|
get_filename_component(CLANG_BIN_DIR ${CMAKE_C_COMPILER} DIRECTORY)
|
|
|
|
set(PATH_WITH_CLANG "${CLANG_BIN_DIR}:$ENV{PATH}")
|
|
|
|
add_custom_target(tint-generate-coverage
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E env PATH=${PATH_WITH_CLANG} ./tools/tint-generate-coverage $<TARGET_FILE:tint_unittests>
|
|
|
|
DEPENDS tint_unittests
|
2021-07-08 19:35:53 +00:00
|
|
|
WORKING_DIRECTORY ${TINT_ROOT_SOURCE_DIR}
|
2020-10-27 21:04:59 +00:00
|
|
|
COMMENT "Generating tint coverage data"
|
|
|
|
VERBATIM)
|
|
|
|
endif()
|
2021-07-08 19:35:53 +00:00
|
|
|
|
2021-08-31 18:43:36 +00:00
|
|
|
if (TINT_BUILD_REMOTE_COMPILE)
|
|
|
|
add_subdirectory(tools/src/cmd/remote-compile)
|
2021-07-08 19:35:53 +00:00
|
|
|
endif()
|