[tint][ir] Cleanup CMake flags handling
- Adds a default for IR binary based on if protobuf is available.
- Add forwarding the IR fuzzer flag to be converted into a C++ macro.
- Reworks the conditional override of IR binary into a condition check
to catch manually misconfigured situations
- Adds condition check for IR binary if IR fuzzer enabled
Change-Id: I76598be9bb4d068887432cfd0133b38c4c594820
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/194302
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Auto-Submit: Ryan Harrison <rharrison@chromium.org>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4c695b8..327ffa9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -224,8 +224,13 @@
option(TINT_BUILD_SYNTAX_TREE_WRITER "Build the syntax tree writer" OFF)
-option(TINT_BUILD_IR_BINARY "Build IR binary format support" ON)
+if (DAWN_BUILD_PROTOBUF AND TARGET libprotobuf)
+ set(TINT_DEFAULT_BUILD_IR_BINARY ON)
+else()
+ set(TINT_DEFAULT_BUILD_IR_BINARY OFF)
+endif()
+option(TINT_BUILD_IR_BINARY "Build IR binary format support" ${TINT_DEFAULT_BUILD_IR_BINARY})
option(TINT_BUILD_FUZZERS "Build fuzzers" OFF)
option(TINT_BUILD_IR_FUZZER "Build IR fuzzer" OFF)
option(TINT_BUILD_BENCHMARKS "Build Tint benchmarks" OFF)
diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt
index ac4d4b0..15bf5ad 100644
--- a/src/tint/CMakeLists.txt
+++ b/src/tint/CMakeLists.txt
@@ -41,10 +41,16 @@
endif()
endif()
-if (DAWN_BUILD_PROTOBUF AND TARGET libprotobuf)
- set(TINT_BUILD_IR_BINARY 1)
-else()
- set(TINT_BUILD_IR_BINARY 0)
+################################################################################
+# Dependent flag checks
+################################################################################
+
+if (TINT_BUILD_IR_BINARY AND NOT (DAWN_BUILD_PROTOBUF AND TARGET libprotobuf))
+ message(FATAL_ERROR "Build IR binary format support is enabled, but libprotobuf is not available")
+endif()
+
+if (TINT_BUILD_IR_FUZZER AND NOT TINT_BUILD_IR_BINARY)
+ message(FATAL_ERROR "Build IR fuzzer is enabled, but build IR binary format support is not")
endif()
################################################################################
@@ -57,6 +63,7 @@
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_IR_BINARY=$<BOOL:${TINT_BUILD_IR_BINARY}>)
+ target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_IR_FUZZER=$<BOOL:${TINT_BUILD_IR_FUZZER}>)
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_IS_LINUX=$<BOOL:${TINT_BUILD_IS_LINUX}>)
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_IS_MAC=$<BOOL:${TINT_BUILD_IS_MAC}>)
target_compile_definitions(${TARGET} PUBLIC -DTINT_BUILD_IS_WIN=$<BOOL:${TINT_BUILD_IS_WIN}>)