Override CMake cache for fuzzer options

Enabling particular fuzzers requires that certain other CMake options
are enabled. For example, enabling the SPIR-V Tools fuzzer requires
enabling the CMake option for building spirv-fuzz. This change uses the
FORCE parameter to force the CMake cache to be overridden in such cases.
The change also adds FORCE to other options where it seems appropriate,
and improves some doc strings associated with CMake options.

Fixes: tint:1024
Change-Id: Ia72ddc0b3af625bb21ff1cc1c7121185ec3908b6
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59204
Auto-Submit: Alastair Donaldson <afdx@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Vasyl Teliman <vasniktel@gmail.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Alastair Donaldson <afdx@google.com>
This commit is contained in:
Alastair Donaldson 2021-07-22 10:14:34 +00:00 committed by Tint LUCI CQ
parent fe3ba95e6a
commit 66b979d7fb
2 changed files with 24 additions and 24 deletions

View File

@ -89,18 +89,18 @@ if (${TINT_BUILD_SPIRV_TOOLS_FUZZER})
message(STATUS "TINT_BUILD_SPIRV_TOOLS_FUZZER is ON - setting message(STATUS "TINT_BUILD_SPIRV_TOOLS_FUZZER is ON - setting
TINT_BUILD_FUZZERS TINT_BUILD_FUZZERS
TINT_BUILD_SPV_READER TINT_BUILD_SPV_READER
TINT_BUILD_SPV_WRITER
TINT_BUILD_WGSL_READER TINT_BUILD_WGSL_READER
TINT_BUILD_WGSL_WRITER TINT_BUILD_WGSL_WRITER
TINT_BUILD_HLSL_WRITER TINT_BUILD_HLSL_WRITER
TINT_BUILD_MSL_WRITER TINT_BUILD_MSL_WRITER to ON")
TINT_BUILD_SPV_WRITER to ON") set(TINT_BUILD_FUZZERS ON CACHE BOOL "Build tint fuzzers" FORCE)
set(TINT_BUILD_FUZZERS ON) set(TINT_BUILD_SPV_READER ON CACHE BOOL "Build SPIR-V reader" FORCE)
set(TINT_BUILD_SPV_READER ON) set(TINT_BUILD_SPV_WRITER ON CACHE BOOL "Build SPIR-V writer" FORCE)
set(TINT_BUILD_WGSL_READER ON) set(TINT_BUILD_WGSL_READER ON CACHE BOOL "Build WGSL reader" FORCE)
set(TINT_BUILD_WGSL_WRITER ON) set(TINT_BUILD_WGSL_WRITER ON CACHE BOOL "Build WGSL writer" FORCE)
set(TINT_BUILD_HLSL_WRITER ON) set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE)
set(TINT_BUILD_MSL_WRITER ON) set(TINT_BUILD_MSL_WRITER ON CACHE BOOL "Build MSL writer" FORCE)
set(TINT_BUILD_SPV_WRITER ON)
endif() endif()
if (${TINT_BUILD_AST_FUZZER}) if (${TINT_BUILD_AST_FUZZER})
@ -111,12 +111,12 @@ if (${TINT_BUILD_AST_FUZZER})
TINT_BUILD_SPV_WRITER TINT_BUILD_SPV_WRITER
TINT_BUILD_MSL_WRITER TINT_BUILD_MSL_WRITER
TINT_BUILD_HLSL_WRITER to ON") TINT_BUILD_HLSL_WRITER to ON")
set(TINT_BUILD_FUZZERS ON) set(TINT_BUILD_FUZZERS ON CACHE BOOL "Build tint fuzzers" FORCE)
set(TINT_BUILD_WGSL_READER ON) set(TINT_BUILD_WGSL_READER ON CACHE BOOL "Build WGSL reader" FORCE)
set(TINT_BUILD_WGSL_WRITER ON) set(TINT_BUILD_WGSL_WRITER ON CACHE BOOL "Build WGSL writer" FORCE)
set(TINT_BUILD_SPV_WRITER ON) set(TINT_BUILD_SPV_WRITER ON CACHE BOOL "Build SPIR-V writer" FORCE)
set(TINT_BUILD_MSL_WRITER ON) set(TINT_BUILD_MSL_WRITER ON CACHE BOOL "Build MSL writer" FORCE)
set(TINT_BUILD_HLSL_WRITER ON) set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE)
endif() endif()
set(TINT_ROOT_SOURCE_DIR ${PROJECT_SOURCE_DIR}) set(TINT_ROOT_SOURCE_DIR ${PROJECT_SOURCE_DIR})

View File

@ -13,28 +13,28 @@
# limitations under the License. # limitations under the License.
if (${TINT_BUILD_TESTS} AND NOT TARGET gmock) if (${TINT_BUILD_TESTS} AND NOT TARGET gmock)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) 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) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/googletest EXCLUDE_FROM_ALL)
endif() endif()
if ((${TINT_BUILD_SPIRV_TOOLS_FUZZER} OR ${TINT_BUILD_AST_FUZZER}) AND if ((${TINT_BUILD_SPIRV_TOOLS_FUZZER} OR ${TINT_BUILD_AST_FUZZER}) AND
(NOT TARGET protobuf::libprotobuf OR NOT TARGET protobuf::protoc)) (NOT TARGET protobuf::libprotobuf OR NOT TARGET protobuf::protoc))
if (${TINT_BUILD_SPIRV_TOOLS_FUZZER}) set(protobuf_BUILD_TESTS OFF CACHE BOOL "Controls whether protobuf tests are built" FORCE)
set(SPIRV_BUILD_FUZZER ON CACHE BOOL "Build spirv-fuzz") set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Controls whether a protobuf static runtime is built" FORCE)
endif()
set(protobuf_BUILD_TESTS OFF CACHE BOOL "Disable protobuf tests")
set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Do not build protobuf static runtime")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/protobuf/cmake) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/protobuf/cmake)
endif() endif()
if(${TINT_BUILD_SPV_READER} OR ${TINT_BUILD_SPV_WRITER}) if(${TINT_BUILD_SPV_READER} OR ${TINT_BUILD_SPV_WRITER})
if (NOT IS_DIRECTORY "${SPIRV-Headers_SOURCE_DIR}") if (NOT IS_DIRECTORY "${SPIRV-Headers_SOURCE_DIR}")
set(SPIRV-Headers_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/spirv-headers CACHE STRING "") set(SPIRV-Headers_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/spirv-headers CACHE STRING "Source directory for SPIR-V headers")
endif() endif()
if (NOT TARGET SPIRV-Tools) if (NOT TARGET SPIRV-Tools)
set(SPIRV_SKIP_TESTS ON CACHE BOOL ON) set(SPIRV_SKIP_TESTS ON CACHE BOOL "Controls whether SPIR-V tests are run" FORCE)
set(SPIRV_WERROR OFF CACHE BOOL OFF) set(SPIRV_WERROR OFF CACHE BOOL OFF FORCE)
if (${TINT_BUILD_SPIRV_TOOLS_FUZZER})
set(SPIRV_BUILD_FUZZER ON CACHE BOOL "Controls whether spirv-fuzz is built" FORCE)
endif()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools EXCLUDE_FROM_ALL) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools EXCLUDE_FROM_ALL)
endif() endif()
endif() endif()