CMake: Fix building of tint with fuzzers enabled
There's an implict dependency between including protobug and SPIR-V tools, as SPIR-V tools needs to know where protobuf lives.
Bug: dawn:1339
Change-Id: I22a95e44af5ae1cc39a9c3400bd319d86e434967
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86070
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index 7933b90..bc75898 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -29,6 +29,14 @@
endif()
endif()
+# Needs to come before SPIR-V Tools
+if ((${TINT_BUILD_SPIRV_TOOLS_FUZZER} OR ${TINT_BUILD_AST_FUZZER}) AND
+ (NOT TARGET protobuf::libprotobuf OR NOT TARGET protobuf::protoc))
+ set(protobuf_BUILD_TESTS OFF CACHE BOOL "Controls whether protobuf tests are built" FORCE)
+ set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Controls whether a protobuf static runtime is built" FORCE)
+ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/protobuf/cmake)
+endif()
+
if(${TINT_BUILD_SPV_READER} OR ${TINT_BUILD_SPV_WRITER})
if (NOT IS_DIRECTORY "${SPIRV-Headers_SOURCE_DIR}")
set(SPIRV-Headers_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/spirv-headers CACHE STRING "Source directory for SPIR-V headers")
@@ -97,10 +105,3 @@
set(gtest_force_shared_crt ON CACHE BOOL "Controls whether a shared run-time library should be used even when Google Test is built as static library" FORCE)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/googletest EXCLUDE_FROM_ALL)
endif()
-
-if ((${TINT_BUILD_SPIRV_TOOLS_FUZZER} OR ${TINT_BUILD_AST_FUZZER}) AND
- (NOT TARGET protobuf::libprotobuf OR NOT TARGET protobuf::protoc))
- set(protobuf_BUILD_TESTS OFF CACHE BOOL "Controls whether protobuf tests are built" FORCE)
- set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Controls whether a protobuf static runtime is built" FORCE)
- add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/protobuf/cmake)
-endif()