From 66b979d7fb7539acd7007b1782c5e52d7b7e090a Mon Sep 17 00:00:00 2001 From: Alastair Donaldson Date: Thu, 22 Jul 2021 10:14:34 +0000 Subject: [PATCH] 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 Reviewed-by: Ben Clayton Reviewed-by: Vasyl Teliman Reviewed-by: Ryan Harrison Kokoro: Kokoro Commit-Queue: Alastair Donaldson --- CMakeLists.txt | 30 +++++++++++++++--------------- third_party/CMakeLists.txt | 18 +++++++++--------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3985a5fca3..ca7501de0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,18 +89,18 @@ if (${TINT_BUILD_SPIRV_TOOLS_FUZZER}) message(STATUS "TINT_BUILD_SPIRV_TOOLS_FUZZER is ON - setting TINT_BUILD_FUZZERS TINT_BUILD_SPV_READER + TINT_BUILD_SPV_WRITER TINT_BUILD_WGSL_READER TINT_BUILD_WGSL_WRITER TINT_BUILD_HLSL_WRITER - TINT_BUILD_MSL_WRITER - TINT_BUILD_SPV_WRITER to ON") - set(TINT_BUILD_FUZZERS ON) - set(TINT_BUILD_SPV_READER ON) - set(TINT_BUILD_WGSL_READER ON) - set(TINT_BUILD_WGSL_WRITER ON) - set(TINT_BUILD_HLSL_WRITER ON) - set(TINT_BUILD_MSL_WRITER ON) - set(TINT_BUILD_SPV_WRITER ON) + TINT_BUILD_MSL_WRITER to ON") + set(TINT_BUILD_FUZZERS ON CACHE BOOL "Build tint fuzzers" FORCE) + set(TINT_BUILD_SPV_READER ON CACHE BOOL "Build SPIR-V reader" FORCE) + set(TINT_BUILD_SPV_WRITER ON CACHE BOOL "Build SPIR-V writer" FORCE) + set(TINT_BUILD_WGSL_READER ON CACHE BOOL "Build WGSL reader" FORCE) + set(TINT_BUILD_WGSL_WRITER ON CACHE BOOL "Build WGSL writer" FORCE) + set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE) + set(TINT_BUILD_MSL_WRITER ON CACHE BOOL "Build MSL writer" FORCE) endif() if (${TINT_BUILD_AST_FUZZER}) @@ -111,12 +111,12 @@ if (${TINT_BUILD_AST_FUZZER}) TINT_BUILD_SPV_WRITER TINT_BUILD_MSL_WRITER TINT_BUILD_HLSL_WRITER to ON") - set(TINT_BUILD_FUZZERS ON) - set(TINT_BUILD_WGSL_READER ON) - set(TINT_BUILD_WGSL_WRITER ON) - set(TINT_BUILD_SPV_WRITER ON) - set(TINT_BUILD_MSL_WRITER ON) - set(TINT_BUILD_HLSL_WRITER ON) + set(TINT_BUILD_FUZZERS ON CACHE BOOL "Build tint fuzzers" FORCE) + set(TINT_BUILD_WGSL_READER ON CACHE BOOL "Build WGSL reader" FORCE) + set(TINT_BUILD_WGSL_WRITER ON CACHE BOOL "Build WGSL writer" FORCE) + set(TINT_BUILD_SPV_WRITER ON CACHE BOOL "Build SPIR-V writer" FORCE) + set(TINT_BUILD_MSL_WRITER ON CACHE BOOL "Build MSL writer" FORCE) + set(TINT_BUILD_HLSL_WRITER ON CACHE BOOL "Build HLSL writer" FORCE) endif() set(TINT_ROOT_SOURCE_DIR ${PROJECT_SOURCE_DIR}) diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index fcf025d9c2..b7e94aac68 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -13,28 +13,28 @@ # limitations under the License. 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) endif() if ((${TINT_BUILD_SPIRV_TOOLS_FUZZER} OR ${TINT_BUILD_AST_FUZZER}) AND (NOT TARGET protobuf::libprotobuf OR NOT TARGET protobuf::protoc)) - if (${TINT_BUILD_SPIRV_TOOLS_FUZZER}) - set(SPIRV_BUILD_FUZZER ON CACHE BOOL "Build spirv-fuzz") - 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") + 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 "") + set(SPIRV-Headers_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/spirv-headers CACHE STRING "Source directory for SPIR-V headers") endif() if (NOT TARGET SPIRV-Tools) - set(SPIRV_SKIP_TESTS ON CACHE BOOL ON) - set(SPIRV_WERROR OFF CACHE BOOL OFF) + set(SPIRV_SKIP_TESTS ON CACHE BOOL "Controls whether SPIR-V tests are run" FORCE) + 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) endif() endif()