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>
This commit is contained in:
Ben Clayton 2022-04-07 20:39:24 +00:00 committed by Dawn LUCI CQ
parent 9e9db88e32
commit bf8791bc9d
1 changed files with 8 additions and 7 deletions

View File

@ -29,6 +29,14 @@ if(${TINT_BUILD_GLSL_WRITER})
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 @@ if (${TINT_BUILD_TESTS} AND NOT TARGET gmock)
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()