Skip to content

Commit 3a3cb36

Browse files
ben-claytonDawn LUCI CQ
authored andcommitted
[tint] Migrate CMake build over to generated files/deps
Add a `BUILD.cmake.tmpl` template file to emit CMake build files and target dependency information. Rename TINT_BUILD_SAMPLES to TINT_BUILD_CMD_TOOLS. The 'tint' executable is used more as a command-line interface than a sample. Update the root tint CMakeLists.txt file to use this. Change-Id: I35cf071af09fd401e87a9b0bd35dbf40e72b9995 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/146386 Reviewed-by: James Price <[email protected]> Commit-Queue: Ben Clayton <[email protected]> Kokoro: Kokoro <[email protected]> Auto-Submit: Ben Clayton <[email protected]>
1 parent fb0271f commit 3a3cb36

File tree

100 files changed

+6155
-1961
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+6155
-1961
lines changed

CMakeLists.txt

Lines changed: 5 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ else()
154154
set(TINT_DEFAULT_GLSL OFF)
155155
endif()
156156

157-
option_if_not_defined(TINT_BUILD_SAMPLES "Build samples" ${DAWN_BUILD_SAMPLES})
157+
option_if_not_defined(TINT_BUILD_CMD_TOOLS "Build the Tint command line tools" ON)
158158
option_if_not_defined(TINT_BUILD_DOCS "Build documentation" ON)
159159
option_if_not_defined(TINT_DOCS_WARN_AS_ERROR "When building documentation, treat warnings as errors" OFF)
160160

161-
if (NOT DAWN_USE_GLFW AND (TINT_BUILD_SAMPLES OR DAWN_BUILD_SAMPLES))
161+
if (NOT DAWN_USE_GLFW AND (TINT_BUILD_CMD_TOOLS OR DAWN_BUILD_SAMPLES))
162162
message(SEND_ERROR "Dawn samples require GLFW")
163163
endif()
164164

@@ -304,7 +304,7 @@ message(STATUS "Dawn build with TSAN: ${DAWN_ENABLE_TSAN}")
304304
message(STATUS "Dawn build with MSAN: ${DAWN_ENABLE_MSAN}")
305305
message(STATUS "Dawn build with UBSAN: ${DAWN_ENABLE_UBSAN}")
306306

307-
message(STATUS "Tint build samples: ${TINT_BUILD_SAMPLES}")
307+
message(STATUS "Tint build command line executable tools: ${TINT_BUILD_CMD_TOOLS}")
308308
message(STATUS "Tint build docs: ${TINT_BUILD_DOCS}")
309309
message(STATUS "Tint build docs with warn as error: ${TINT_DOCS_WARN_AS_ERROR}")
310310
message(STATUS "Tint build SPIR-V reader: ${TINT_BUILD_SPV_READER}")
@@ -461,6 +461,8 @@ set(CMAKE_CXX_STANDARD "17")
461461
set(TINT_LIB_FUZZING_ENGINE_LINK_OPTIONS "" CACHE STRING "Used by OSS-Fuzz to control, via link options, which fuzzing engine should be used")
462462

463463
set(TINT_ROOT_SOURCE_DIR ${PROJECT_SOURCE_DIR})
464+
set(TINT_SPIRV_HEADERS_DIR ${DAWN_SPIRV_HEADERS_DIR})
465+
set(TINT_SPIRV_TOOLS_DIR ${DAWN_SPIRV_TOOLS_DIR})
464466

465467
# CMake < 3.15 sets /W3 in CMAKE_CXX_FLAGS. Remove it if it's there.
466468
# See https://gitlab.kitware.com/cmake/cmake/-/issues/18317
@@ -474,10 +476,6 @@ if (${TINT_CHECK_CHROMIUM_STYLE})
474476
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -add-plugin -Xclang find-bad-constructs")
475477
endif()
476478

477-
if (${TINT_BUILD_SPV_READER})
478-
include_directories("${DAWN_THIRD_PARTY_DIR}/vulkan-deps/spirv-tools/include")
479-
endif()
480-
481479
if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))
482480
set(COMPILER_IS_CLANG_CL TRUE)
483481
endif()
@@ -497,17 +495,6 @@ if (MSVC AND NOT COMPILER_IS_CLANG_CL)
497495
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
498496
endif()
499497

500-
set(TINT_OS_CC_SUFFIX "other")
501-
if (NOT TINT_BUILD_AS_OTHER_OS)
502-
if(UNIX OR APPLE)
503-
set(TINT_OS_CC_SUFFIX "posix")
504-
set(TINT_OS_CC_SUFFIX "posix")
505-
elseif(WIN32)
506-
set(TINT_OS_CC_SUFFIX "windows")
507-
set(TINT_OS_CC_SUFFIX "windows")
508-
endif()
509-
endif()
510-
511498
if(${TINT_BUILD_DOCS})
512499
find_package(Doxygen)
513500
if(DOXYGEN_FOUND)
@@ -536,121 +523,6 @@ if(${TINT_BUILD_DOCS})
536523
endif(DOXYGEN_FOUND)
537524
endif()
538525

539-
function(tint_core_compile_options TARGET)
540-
target_include_directories(${TARGET} PUBLIC "${TINT_ROOT_SOURCE_DIR}")
541-
target_include_directories(${TARGET} PUBLIC "${TINT_ROOT_SOURCE_DIR}/include")
542-
543-
if (${TINT_BUILD_SPV_READER} OR ${TINT_BUILD_SPV_WRITER})
544-
target_include_directories(${TARGET} PUBLIC
545-
"${DAWN_THIRD_PARTY_DIR}/spirv-headers/include")
546-
endif()
547-
548-
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_SPV_READER=$<BOOL:${TINT_BUILD_SPV_READER}>)
549-
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_WGSL_READER=$<BOOL:${TINT_BUILD_WGSL_READER}>)
550-
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_GLSL_WRITER=$<BOOL:${TINT_BUILD_GLSL_WRITER}>)
551-
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_HLSL_WRITER=$<BOOL:${TINT_BUILD_HLSL_WRITER}>)
552-
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_MSL_WRITER=$<BOOL:${TINT_BUILD_MSL_WRITER}>)
553-
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_SPV_WRITER=$<BOOL:${TINT_BUILD_SPV_WRITER}>)
554-
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_WGSL_WRITER=$<BOOL:${TINT_BUILD_WGSL_WRITER}>)
555-
target_compile_definitions(${TARGET} PUBLIC
556-
-DTINT_BUILD_SYNTAX_TREE_WRITER=$<BOOL:${TINT_BUILD_SYNTAX_TREE_WRITER}>)
557-
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_IR=$<BOOL:${TINT_BUILD_IR}>)
558-
559-
common_compile_options(${TARGET})
560-
endfunction()
561-
562-
function(tint_default_compile_options TARGET)
563-
tint_core_compile_options(${TARGET})
564-
565-
set(COMMON_GNU_OPTIONS
566-
-Wall
567-
-Werror
568-
-Wextra
569-
-Wno-documentation-unknown-command
570-
-Wno-padded
571-
-Wno-switch-enum
572-
-Wno-unknown-pragmas
573-
)
574-
575-
set(COMMON_CLANG_OPTIONS
576-
-Wno-c++98-compat
577-
-Wno-c++98-compat-pedantic
578-
-Wno-format-pedantic
579-
-Wno-poison-system-directories
580-
-Wno-return-std-move-in-c++11
581-
-Wno-unknown-warning-option
582-
-Wno-undefined-var-template
583-
-Wno-unsafe-buffer-usage
584-
-Wno-used-but-marked-unused
585-
-Weverything
586-
)
587-
588-
if (COMPILER_IS_LIKE_GNU)
589-
target_compile_options(${TARGET} PRIVATE
590-
-pedantic-errors
591-
${COMMON_GNU_OPTIONS}
592-
)
593-
594-
if (COMPILER_IS_CLANG)
595-
target_compile_options(${TARGET} PRIVATE
596-
${COMMON_CLANG_OPTIONS}
597-
)
598-
endif()
599-
endif(COMPILER_IS_LIKE_GNU)
600-
601-
if (MSVC)
602-
# Specify /EHs for exception handling.
603-
target_compile_options(${TARGET} PRIVATE
604-
/bigobj
605-
/EHsc
606-
/W4
607-
/WX
608-
/wd4068 # unknown pragma
609-
/wd4127 # conditional expression is constant
610-
/wd4244 # 'conversion' conversion from 'type1' to 'type2', possible loss of data
611-
/wd4267 # 'var' : conversion from 'size_t' to 'type', possible loss of data
612-
/wd4324 # 'struct_name' : structure was padded due to __declspec(align())
613-
/wd4459 # declaration of 'identifier' hides global declaration
614-
/wd4458 # declaration of 'identifier' hides class member
615-
/wd4514 # 'function' : unreferenced inline function has been removed
616-
/wd4571 # catch(...) semantics changed since Visual C++ 7.1; structured exceptions (SEH) are no longer caught
617-
/wd4625 # 'derived class' : copy constructor was implicitly defined as deleted because a base class copy constructor is inaccessible or deleted
618-
/wd4626 # 'derived class' : assignment operator was implicitly defined as deleted because a base class assignment operator is inaccessible or deleted
619-
/wd4710 # 'function' : function not inlined
620-
/wd4774 # 'function' : format string 'string' requires an argument of type 'type', but variadic argument number has type 'type'
621-
/wd4820 # 'bytes' bytes padding added after construct 'member_name'
622-
/wd5026 # 'type': move constructor was implicitly defined as deleted
623-
/wd5027 # 'type': move assignment operator was implicitly defined as deleted
624-
)
625-
626-
# When building with clang-cl on Windows, try to match our clang build
627-
# options as much as possible.
628-
if (COMPILER_IS_CLANG_CL)
629-
target_compile_options(${TARGET} PRIVATE
630-
${COMMON_GNU_OPTIONS}
631-
${COMMON_CLANG_OPTIONS}
632-
# Disable warnings that are usually disabled in downstream deps for
633-
# gcc/clang, but aren't for clang-cl.
634-
-Wno-global-constructors
635-
-Wno-zero-as-null-pointer-constant
636-
-Wno-shorten-64-to-32
637-
-Wno-shadow-field-in-constructor
638-
-Wno-reserved-id-macro
639-
-Wno-language-extension-token
640-
)
641-
endif()
642-
endif()
643-
644-
if (TINT_RANDOMIZE_HASHES)
645-
if(NOT DEFINED TINT_HASH_SEED)
646-
string(RANDOM LENGTH 16 ALPHABET "0123456789abcdef" seed)
647-
set(TINT_HASH_SEED "0x${seed}" CACHE STRING "Tint hash seed value")
648-
message("Using TINT_HASH_SEED: ${TINT_HASH_SEED}")
649-
endif()
650-
target_compile_definitions(${TARGET} PUBLIC "-DTINT_HASH_SEED=${TINT_HASH_SEED}")
651-
endif()
652-
endfunction()
653-
654526
################################################################################
655527
# Run on all subdirectories
656528
################################################################################
@@ -670,15 +542,6 @@ add_subdirectory(src/dawn)
670542
################################################################################
671543
# Samples
672544
################################################################################
673-
674-
if (TINT_BUILD_SAMPLES)
675-
add_subdirectory(src/tint/cmd)
676-
endif()
677-
678-
if (TINT_BUILD_FUZZERS)
679-
add_subdirectory(src/tint/fuzzers)
680-
endif()
681-
682545
add_custom_target(tint-lint
683546
COMMAND ./tools/lint
684547
WORKING_DIRECTORY ${TINT_ROOT_SOURCE_DIR}

src/tint/BUILD.cmake

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2023 The Tint Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
################################################################################
16+
# File generated by tools/src/cmd/gen
17+
# using the template:
18+
# tools/src/cmd/gen/build/BUILD.cmake.tmpl
19+
#
20+
# Do not modify this file directly
21+
################################################################################
22+
23+
include(api/BUILD.cmake)
24+
include(cmd/BUILD.cmake)
25+
include(lang/BUILD.cmake)
26+
include(utils/BUILD.cmake)

0 commit comments

Comments
 (0)