2020-03-02 20:47:43 +00:00
|
|
|
# Copyright 2020 The Tint Authors.
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
cmake_minimum_required(VERSION 3.10.2)
|
|
|
|
|
|
|
|
project(tint)
|
|
|
|
enable_testing()
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
set(CMAKE_CXX_STANDARD 14)
|
|
|
|
set(CMAKE_DEBUG_POSTFIX "")
|
|
|
|
|
|
|
|
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
|
|
|
|
message(STATUS "No build type selected, default to Debug")
|
|
|
|
set(CMAKE_BUILD_TYPE "Debug")
|
|
|
|
endif()
|
|
|
|
|
2021-03-09 13:55:37 +00:00
|
|
|
# TINT_IS_SUBPROJECT is 1 if added via add_subdirectory() from another project.
|
|
|
|
get_directory_property(TINT_IS_SUBPROJECT PARENT_DIRECTORY)
|
|
|
|
if(TINT_IS_SUBPROJECT)
|
|
|
|
set(TINT_IS_SUBPROJECT 1)
|
|
|
|
|
|
|
|
# If tint is used as a subproject, default to disabling the building of
|
|
|
|
# documentation and tests. These are unlikely to be desirable, but can be
|
|
|
|
# enabled.
|
|
|
|
set(TINT_BUILD_DOCS_DEFAULT OFF)
|
|
|
|
set(TINT_BUILD_TESTS_DEFAULT OFF)
|
|
|
|
else()
|
|
|
|
set(TINT_BUILD_DOCS_DEFAULT ON)
|
|
|
|
set(TINT_BUILD_TESTS_DEFAULT ON)
|
|
|
|
endif()
|
|
|
|
|
2021-09-20 19:47:05 +00:00
|
|
|
function (set_if_not_defined name value description)
|
|
|
|
if(NOT DEFINED ${name})
|
|
|
|
set(${name} ${value} PARENT_SCOPE)
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
set_if_not_defined(TINT_THIRD_PARTY_DIR "${tint_SOURCE_DIR}/third_party" "Directory in which to find third-party dependencies.")
|
|
|
|
|
2021-08-31 18:43:36 +00:00
|
|
|
option(TINT_BUILD_SAMPLES "Build samples" ON)
|
2021-03-09 13:55:37 +00:00
|
|
|
option(TINT_BUILD_DOCS "Build documentation" ${TINT_BUILD_DOCS_DEFAULT})
|
2021-06-25 14:00:36 +00:00
|
|
|
option(TINT_DOCS_WARN_AS_ERROR "When building documentation, treat warnings as errors" OFF)
|
2020-03-18 14:08:48 +00:00
|
|
|
option(TINT_BUILD_SPV_READER "Build the SPIR-V input reader" ON)
|
2020-12-01 18:04:17 +00:00
|
|
|
option(TINT_BUILD_WGSL_READER "Build the WGSL input reader" ON)
|
Implement GLSL writer backend.
This is a modified version of the HLSL writer.
Basic types, arrays, entry points, reserved keywords, uniforms,
builtin uniforms, structs, some builtin functions, zero initialization
are implemented. Textures, SSBOs and storage textures in particular are
unimplemented. All the unit tests "pass", but the output is not correct
in many cases.
triangle.wgsl outputs correct vertex and fragment shaders that pass
GLSL validation via glslang. compute_boids.wgsl outputs a valid but not
correct compute shader.
Change-Id: I96c7aaf60cf2d4237e45d732e5f51b345aea0552
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57780
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-10-06 18:55:10 +00:00
|
|
|
option(TINT_BUILD_GLSL_WRITER "Build the GLSL output writer" ON)
|
2020-07-20 22:13:37 +00:00
|
|
|
option(TINT_BUILD_HLSL_WRITER "Build the HLSL output writer" ON)
|
2020-06-23 17:48:40 +00:00
|
|
|
option(TINT_BUILD_MSL_WRITER "Build the MSL output writer" ON)
|
2020-03-18 14:08:48 +00:00
|
|
|
option(TINT_BUILD_SPV_WRITER "Build the SPIR-V output writer" ON)
|
|
|
|
option(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON)
|
|
|
|
option(TINT_BUILD_FUZZERS "Build fuzzers" OFF)
|
2021-06-24 18:10:46 +00:00
|
|
|
option(TINT_BUILD_SPIRV_TOOLS_FUZZER "Build SPIRV-Tools fuzzer" OFF)
|
2021-07-13 12:01:25 +00:00
|
|
|
option(TINT_BUILD_AST_FUZZER "Build AST fuzzer" OFF)
|
2021-07-28 11:11:26 +00:00
|
|
|
option(TINT_BUILD_REGEX_FUZZER "Build regex fuzzer" OFF)
|
2021-03-09 13:55:37 +00:00
|
|
|
option(TINT_BUILD_TESTS "Build tests" ${TINT_BUILD_TESTS_DEFAULT})
|
2021-04-16 14:43:34 +00:00
|
|
|
option(TINT_BUILD_AS_OTHER_OS "Override OS detection to force building of *_other.cc files" OFF)
|
2021-07-08 19:35:53 +00:00
|
|
|
option(TINT_BUILD_REMOTE_COMPILE "Build the remote-compile tool for validating shaders on a remote machine" OFF)
|
2020-04-28 19:27:38 +00:00
|
|
|
|
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")
|
|
|
|
|
2020-03-02 20:47:43 +00:00
|
|
|
option(TINT_ENABLE_MSAN "Enable memory sanitizer" OFF)
|
|
|
|
option(TINT_ENABLE_ASAN "Enable address sanitizer" OFF)
|
|
|
|
option(TINT_ENABLE_UBSAN "Enable undefined behaviour sanitizer" OFF)
|
|
|
|
|
2020-10-27 21:04:59 +00:00
|
|
|
option(TINT_EMIT_COVERAGE "Emit code coverage information" OFF)
|
|
|
|
|
2020-04-28 19:27:38 +00:00
|
|
|
option(TINT_CHECK_CHROMIUM_STYLE "Check for [chromium-style] issues during build" OFF)
|
|
|
|
|
2021-08-31 18:43:36 +00:00
|
|
|
message(STATUS "Tint build samples: ${TINT_BUILD_SAMPLES}")
|
2020-03-02 20:47:43 +00:00
|
|
|
message(STATUS "Tint build docs: ${TINT_BUILD_DOCS}")
|
2021-06-25 14:00:36 +00:00
|
|
|
message(STATUS "Tint build docs with warn as error: ${TINT_DOCS_WARN_AS_ERROR}")
|
2020-03-18 14:08:48 +00:00
|
|
|
message(STATUS "Tint build SPIR-V reader: ${TINT_BUILD_SPV_READER}")
|
|
|
|
message(STATUS "Tint build WGSL reader: ${TINT_BUILD_WGSL_READER}")
|
Implement GLSL writer backend.
This is a modified version of the HLSL writer.
Basic types, arrays, entry points, reserved keywords, uniforms,
builtin uniforms, structs, some builtin functions, zero initialization
are implemented. Textures, SSBOs and storage textures in particular are
unimplemented. All the unit tests "pass", but the output is not correct
in many cases.
triangle.wgsl outputs correct vertex and fragment shaders that pass
GLSL validation via glslang. compute_boids.wgsl outputs a valid but not
correct compute shader.
Change-Id: I96c7aaf60cf2d4237e45d732e5f51b345aea0552
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57780
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-10-06 18:55:10 +00:00
|
|
|
message(STATUS "Tint build GLSL writer: ${TINT_BUILD_GLSL_WRITER}")
|
2020-07-20 22:13:37 +00:00
|
|
|
message(STATUS "Tint build HLSL writer: ${TINT_BUILD_HLSL_WRITER}")
|
2020-06-23 17:48:40 +00:00
|
|
|
message(STATUS "Tint build MSL writer: ${TINT_BUILD_MSL_WRITER}")
|
2020-03-18 14:08:48 +00:00
|
|
|
message(STATUS "Tint build SPIR-V writer: ${TINT_BUILD_SPV_WRITER}")
|
|
|
|
message(STATUS "Tint build WGSL writer: ${TINT_BUILD_WGSL_WRITER}")
|
2020-03-02 20:47:43 +00:00
|
|
|
message(STATUS "Tint build fuzzers: ${TINT_BUILD_FUZZERS}")
|
2021-06-24 18:10:46 +00:00
|
|
|
message(STATUS "Tint build SPIRV-Tools fuzzer: ${TINT_BUILD_SPIRV_TOOLS_FUZZER}")
|
2021-07-13 12:01:25 +00:00
|
|
|
message(STATUS "Tint build AST fuzzer: ${TINT_BUILD_AST_FUZZER}")
|
2021-07-28 11:11:26 +00:00
|
|
|
message(STATUS "Tint build regex fuzzer: ${TINT_BUILD_REGEX_FUZZER}")
|
2020-12-09 14:47:30 +00:00
|
|
|
message(STATUS "Tint build tests: ${TINT_BUILD_TESTS}")
|
2020-03-02 20:47:43 +00:00
|
|
|
message(STATUS "Tint build with ASAN: ${TINT_ENABLE_ASAN}")
|
|
|
|
message(STATUS "Tint build with MSAN: ${TINT_ENABLE_MSAN}")
|
|
|
|
message(STATUS "Tint build with UBSAN: ${TINT_ENABLE_UBSAN}")
|
2020-04-28 19:27:38 +00:00
|
|
|
message(STATUS "Tint build checking [chromium-style]: ${TINT_CHECK_CHROMIUM_STYLE}")
|
2021-07-08 19:35:53 +00:00
|
|
|
message(STATUS "Tint build remote-compile tool: ${TINT_BUILD_REMOTE_COMPILE}")
|
2020-03-02 20:47:43 +00:00
|
|
|
|
2021-09-02 23:49:25 +00:00
|
|
|
if (NOT ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS} STREQUAL "")
|
|
|
|
message(STATUS "Using provided LIB_FUZZING_ENGINE options: ${TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS}")
|
|
|
|
endif()
|
|
|
|
|
2020-03-02 20:47:43 +00:00
|
|
|
message(STATUS "Using python3")
|
|
|
|
find_package(PythonInterp 3 REQUIRED)
|
|
|
|
|
2021-06-24 18:10:46 +00:00
|
|
|
if (${TINT_BUILD_SPIRV_TOOLS_FUZZER})
|
|
|
|
message(STATUS "TINT_BUILD_SPIRV_TOOLS_FUZZER is ON - setting
|
2021-07-13 12:01:25 +00:00
|
|
|
TINT_BUILD_FUZZERS
|
|
|
|
TINT_BUILD_SPV_READER
|
2021-07-22 10:14:34 +00:00
|
|
|
TINT_BUILD_SPV_WRITER
|
2021-07-13 12:01:25 +00:00
|
|
|
TINT_BUILD_WGSL_READER
|
|
|
|
TINT_BUILD_WGSL_WRITER
|
Implement GLSL writer backend.
This is a modified version of the HLSL writer.
Basic types, arrays, entry points, reserved keywords, uniforms,
builtin uniforms, structs, some builtin functions, zero initialization
are implemented. Textures, SSBOs and storage textures in particular are
unimplemented. All the unit tests "pass", but the output is not correct
in many cases.
triangle.wgsl outputs correct vertex and fragment shaders that pass
GLSL validation via glslang. compute_boids.wgsl outputs a valid but not
correct compute shader.
Change-Id: I96c7aaf60cf2d4237e45d732e5f51b345aea0552
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57780
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-10-06 18:55:10 +00:00
|
|
|
TINT_BUILD_GLSL_WRITER
|
2021-07-13 12:01:25 +00:00
|
|
|
TINT_BUILD_HLSL_WRITER
|
2021-07-22 10:14:34 +00:00
|
|
|
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)
|
Implement GLSL writer backend.
This is a modified version of the HLSL writer.
Basic types, arrays, entry points, reserved keywords, uniforms,
builtin uniforms, structs, some builtin functions, zero initialization
are implemented. Textures, SSBOs and storage textures in particular are
unimplemented. All the unit tests "pass", but the output is not correct
in many cases.
triangle.wgsl outputs correct vertex and fragment shaders that pass
GLSL validation via glslang. compute_boids.wgsl outputs a valid but not
correct compute shader.
Change-Id: I96c7aaf60cf2d4237e45d732e5f51b345aea0552
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57780
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-10-06 18:55:10 +00:00
|
|
|
set(TINT_BUILD_GLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE)
|
2021-07-22 10:14:34 +00:00
|
|
|
set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE)
|
|
|
|
set(TINT_BUILD_MSL_WRITER ON CACHE BOOL "Build MSL writer" FORCE)
|
2021-06-24 18:10:46 +00:00
|
|
|
endif()
|
|
|
|
|
2021-07-13 12:01:25 +00:00
|
|
|
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
|
Implement GLSL writer backend.
This is a modified version of the HLSL writer.
Basic types, arrays, entry points, reserved keywords, uniforms,
builtin uniforms, structs, some builtin functions, zero initialization
are implemented. Textures, SSBOs and storage textures in particular are
unimplemented. All the unit tests "pass", but the output is not correct
in many cases.
triangle.wgsl outputs correct vertex and fragment shaders that pass
GLSL validation via glslang. compute_boids.wgsl outputs a valid but not
correct compute shader.
Change-Id: I96c7aaf60cf2d4237e45d732e5f51b345aea0552
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57780
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-10-06 18:55:10 +00:00
|
|
|
TINT_BUILD_GLSL_WRITER
|
2021-07-13 12:01:25 +00:00
|
|
|
TINT_BUILD_HLSL_WRITER to ON")
|
2021-07-22 10:14:34 +00:00
|
|
|
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)
|
Implement GLSL writer backend.
This is a modified version of the HLSL writer.
Basic types, arrays, entry points, reserved keywords, uniforms,
builtin uniforms, structs, some builtin functions, zero initialization
are implemented. Textures, SSBOs and storage textures in particular are
unimplemented. All the unit tests "pass", but the output is not correct
in many cases.
triangle.wgsl outputs correct vertex and fragment shaders that pass
GLSL validation via glslang. compute_boids.wgsl outputs a valid but not
correct compute shader.
Change-Id: I96c7aaf60cf2d4237e45d732e5f51b345aea0552
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57780
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-10-06 18:55:10 +00:00
|
|
|
set(TINT_BUILD_GLSL_WRITER ON CACHE BOOL "Build GLSL writer" FORCE)
|
2021-07-22 10:14:34 +00:00
|
|
|
set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE)
|
2021-07-13 12:01:25 +00:00
|
|
|
endif()
|
|
|
|
|
2021-07-28 11:11:26 +00:00
|
|
|
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
|
Implement GLSL writer backend.
This is a modified version of the HLSL writer.
Basic types, arrays, entry points, reserved keywords, uniforms,
builtin uniforms, structs, some builtin functions, zero initialization
are implemented. Textures, SSBOs and storage textures in particular are
unimplemented. All the unit tests "pass", but the output is not correct
in many cases.
triangle.wgsl outputs correct vertex and fragment shaders that pass
GLSL validation via glslang. compute_boids.wgsl outputs a valid but not
correct compute shader.
Change-Id: I96c7aaf60cf2d4237e45d732e5f51b345aea0552
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57780
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-10-06 18:55:10 +00:00
|
|
|
TINT_BUILD_GLSL_WRITER
|
2021-07-28 11:11:26 +00:00
|
|
|
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)
|
Implement GLSL writer backend.
This is a modified version of the HLSL writer.
Basic types, arrays, entry points, reserved keywords, uniforms,
builtin uniforms, structs, some builtin functions, zero initialization
are implemented. Textures, SSBOs and storage textures in particular are
unimplemented. All the unit tests "pass", but the output is not correct
in many cases.
triangle.wgsl outputs correct vertex and fragment shaders that pass
GLSL validation via glslang. compute_boids.wgsl outputs a valid but not
correct compute shader.
Change-Id: I96c7aaf60cf2d4237e45d732e5f51b345aea0552
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57780
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-10-06 18:55:10 +00:00
|
|
|
set(TINT_BUILD_GLSL_WRITER ON CACHE BOOL "Build GLSL writer" FORCE)
|
2021-07-28 11:11:26 +00:00
|
|
|
set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE)
|
|
|
|
endif()
|
|
|
|
|
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})
|
2021-07-08 19:35:53 +00:00
|
|
|
include_directories("${TINT_ROOT_SOURCE_DIR}/third_party/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()
|
|
|
|
|
|
|
|
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR
|
|
|
|
(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") OR
|
|
|
|
((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND
|
|
|
|
(NOT COMPILER_IS_CLANG_CL)))
|
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
|
|
|
|
|
|
|
function(tint_default_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
|
2021-07-08 19:35:53 +00:00
|
|
|
"${TINT_ROOT_SOURCE_DIR}/third_party/spirv-headers/include")
|
2020-10-23 17:04:10 +00:00
|
|
|
endif()
|
2020-03-02 20:47:43 +00:00
|
|
|
|
2020-10-23 17:04:10 +00:00
|
|
|
target_compile_definitions(${TARGET} PUBLIC
|
2020-03-18 14:08:48 +00:00
|
|
|
-DTINT_BUILD_SPV_READER=$<BOOL:${TINT_BUILD_SPV_READER}>)
|
2020-10-23 17:04:10 +00:00
|
|
|
target_compile_definitions(${TARGET} PUBLIC
|
2020-03-18 14:08:48 +00:00
|
|
|
-DTINT_BUILD_WGSL_READER=$<BOOL:${TINT_BUILD_WGSL_READER}>)
|
Implement GLSL writer backend.
This is a modified version of the HLSL writer.
Basic types, arrays, entry points, reserved keywords, uniforms,
builtin uniforms, structs, some builtin functions, zero initialization
are implemented. Textures, SSBOs and storage textures in particular are
unimplemented. All the unit tests "pass", but the output is not correct
in many cases.
triangle.wgsl outputs correct vertex and fragment shaders that pass
GLSL validation via glslang. compute_boids.wgsl outputs a valid but not
correct compute shader.
Change-Id: I96c7aaf60cf2d4237e45d732e5f51b345aea0552
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/57780
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
2021-10-06 18:55:10 +00:00
|
|
|
target_compile_definitions(${TARGET} PUBLIC
|
|
|
|
-DTINT_BUILD_GLSL_WRITER=$<BOOL:${TINT_BUILD_GLSL_WRITER}>)
|
2020-10-23 17:04:10 +00:00
|
|
|
target_compile_definitions(${TARGET} PUBLIC
|
2020-07-20 22:13:37 +00:00
|
|
|
-DTINT_BUILD_HLSL_WRITER=$<BOOL:${TINT_BUILD_HLSL_WRITER}>)
|
2020-10-23 17:04:10 +00:00
|
|
|
target_compile_definitions(${TARGET} PUBLIC
|
2021-07-08 19:35:53 +00:00
|
|
|
-DTINT_BUILD_MSL_WRITER=$<BOOL:${TINT_BUILD_MSL_WRITER}>)
|
2020-10-23 17:04:10 +00:00
|
|
|
target_compile_definitions(${TARGET} PUBLIC
|
2020-03-18 14:08:48 +00:00
|
|
|
-DTINT_BUILD_SPV_WRITER=$<BOOL:${TINT_BUILD_SPV_WRITER}>)
|
2020-10-23 17:04:10 +00:00
|
|
|
target_compile_definitions(${TARGET} PUBLIC
|
2020-03-18 14:08:48 +00:00
|
|
|
-DTINT_BUILD_WGSL_WRITER=$<BOOL:${TINT_BUILD_WGSL_WRITER}>)
|
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
|
|
|
|
-Wno-return-std-move-in-c++11
|
|
|
|
-Wno-unknown-warning-option
|
|
|
|
-Wno-undefined-var-template
|
|
|
|
-Wno-used-but-marked-unused
|
|
|
|
-Weverything
|
|
|
|
)
|
|
|
|
|
2020-03-02 20:47:43 +00:00
|
|
|
if (${COMPILER_IS_LIKE_GNU})
|
|
|
|
target_compile_options(${TARGET} PRIVATE
|
|
|
|
-std=c++14
|
|
|
|
-fno-exceptions
|
|
|
|
-fno-rtti
|
|
|
|
-pedantic-errors
|
2021-04-27 19:24:47 +00:00
|
|
|
${COMMON_GNU_OPTIONS}
|
2020-03-02 20:47:43 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
if (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR
|
|
|
|
("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang"))
|
|
|
|
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()
|
|
|
|
|
|
|
|
if (${TINT_ENABLE_MSAN})
|
|
|
|
target_compile_options(${TARGET} PRIVATE -fsanitize=memory)
|
|
|
|
target_link_options(${TARGET} PRIVATE -fsanitize=memory)
|
|
|
|
elseif (${TINT_ENABLE_ASAN})
|
|
|
|
target_compile_options(${TARGET} PRIVATE -fsanitize=address)
|
|
|
|
target_link_options(${TARGET} PRIVATE -fsanitize=address)
|
|
|
|
elseif (${TINT_ENABLE_UBSAN})
|
|
|
|
target_compile_options(${TARGET} PRIVATE -fsanitize=undefined)
|
|
|
|
target_link_options(${TARGET} PRIVATE -fsanitize=undefined)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-10-27 21:04:59 +00:00
|
|
|
if (${TINT_EMIT_COVERAGE})
|
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|
|
|
target_compile_options(${TARGET} PRIVATE "--coverage")
|
|
|
|
target_link_options(${TARGET} PRIVATE "gcov")
|
|
|
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
|
|
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()
|
|
|
|
|
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
|
|
|
|
)
|
|
|
|
endif()
|
2020-03-02 20:47:43 +00:00
|
|
|
endif()
|
2020-05-04 18:58:24 +00:00
|
|
|
|
2020-03-02 20:47:43 +00:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
add_subdirectory(third_party)
|
|
|
|
add_subdirectory(src)
|
2021-08-31 18:43:36 +00:00
|
|
|
if (TINT_BUILD_SAMPLES)
|
|
|
|
add_subdirectory(samples)
|
|
|
|
endif()
|
2020-03-02 20:47:43 +00:00
|
|
|
|
2021-08-31 18:43:36 +00:00
|
|
|
if (TINT_BUILD_FUZZERS)
|
2020-04-23 13:51:39 +00:00
|
|
|
add_subdirectory(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
|
|
|
|
|
|
|
|
2021-08-31 18:43:36 +00:00
|
|
|
if (TINT_EMIT_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
2020-10-27 21:04:59 +00:00
|
|
|
# Generates a lcov.info file at the project root.
|
|
|
|
# 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()
|