mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-24 20:40:13 +00:00
Improve spirv-fuzz CMake code (#3781)
This change improves spirv-fuzz CMake code to be more compatible with other projects that might want to include spirv-fuzz as a sub-project. * Add a CMake option for building spirv-fuzz. * We now check if protobuf targets are already available. * We no longer specify `-DGOOGLE_PROTOBUF_NO_RTTI -DGOOGLE_PROTOBUF_USE_UNALIGNED=0`; a newer version of protobuf does not require this. Note that we probably should have specified this for protobuf targets as well, but this is no longer needed. * Updated protobuf version in Kokoro scripts and README.md.
This commit is contained in:
parent
a187dd58a0
commit
a715b1b405
@ -79,6 +79,8 @@ if(SPIRV_BUILD_COMPRESSION)
|
|||||||
"Please remove SPIRV_BUILD_COMPRESSION from your build options.")
|
"Please remove SPIRV_BUILD_COMPRESSION from your build options.")
|
||||||
endif(SPIRV_BUILD_COMPRESSION)
|
endif(SPIRV_BUILD_COMPRESSION)
|
||||||
|
|
||||||
|
option(SPIRV_BUILD_FUZZER "Build spirv-fuzz" OFF)
|
||||||
|
|
||||||
option(SPIRV_WERROR "Enable error on warning" ON)
|
option(SPIRV_WERROR "Enable error on warning" ON)
|
||||||
if(("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") AND (NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")))
|
if(("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR (("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") AND (NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")))
|
||||||
set(COMPILER_IS_LIKE_GNU TRUE)
|
set(COMPILER_IS_LIKE_GNU TRUE)
|
||||||
|
@ -349,10 +349,7 @@ option, like so:
|
|||||||
|
|
||||||
```sh
|
```sh
|
||||||
# In <spirv-dir> (the SPIRV-Tools repo root):
|
# In <spirv-dir> (the SPIRV-Tools repo root):
|
||||||
git clone https://github.com/protocolbuffers/protobuf external/protobuf
|
git clone --depth=1 --branch v3.13.0 https://github.com/protocolbuffers/protobuf external/protobuf
|
||||||
pushd external/protobuf
|
|
||||||
git checkout v3.7.1
|
|
||||||
popd
|
|
||||||
|
|
||||||
# In your build directory:
|
# In your build directory:
|
||||||
cmake [-G <platform-generator>] <spirv-dir> -DSPIRV_BUILD_FUZZER=ON
|
cmake [-G <platform-generator>] <spirv-dir> -DSPIRV_BUILD_FUZZER=ON
|
||||||
|
55
external/CMakeLists.txt
vendored
55
external/CMakeLists.txt
vendored
@ -74,11 +74,11 @@ if (NOT ${SPIRV_SKIP_TESTS})
|
|||||||
"Use shared (DLL) run-time lib even when Google Test is built as static lib."
|
"Use shared (DLL) run-time lib even when Google Test is built as static lib."
|
||||||
ON)
|
ON)
|
||||||
endif()
|
endif()
|
||||||
# gtest requires special defines for building as a shared
|
# gtest requires special defines for building as a shared
|
||||||
# library, simply always build as static.
|
# library, simply always build as static.
|
||||||
push_variable(BUILD_SHARED_LIBS 0)
|
push_variable(BUILD_SHARED_LIBS 0)
|
||||||
add_subdirectory(${GMOCK_DIR} EXCLUDE_FROM_ALL)
|
add_subdirectory(${GMOCK_DIR} EXCLUDE_FROM_ALL)
|
||||||
pop_variable(BUILD_SHARED_LIBS)
|
pop_variable(BUILD_SHARED_LIBS)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if (TARGET gmock)
|
if (TARGET gmock)
|
||||||
@ -137,16 +137,43 @@ if (NOT ${SPIRV_SKIP_TESTS})
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SPIRV_BUILD_FUZZER)
|
if(SPIRV_BUILD_FUZZER)
|
||||||
set(PROTOBUF_DIR ${CMAKE_CURRENT_SOURCE_DIR}/protobuf/cmake)
|
|
||||||
set(protobuf_BUILD_TESTS OFF CACHE BOOL "Disable protobuf tests")
|
function(backup_compile_options)
|
||||||
set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Do not build protobuf static runtime")
|
get_property(
|
||||||
if (IS_DIRECTORY ${PROTOBUF_DIR})
|
SPIRV_TOOLS_BACKUP_EXTERNAL_COMPILE_OPTIONS
|
||||||
if (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
|
DIRECTORY
|
||||||
add_definitions(-Wno-inconsistent-missing-override)
|
PROPERTY COMPILE_OPTIONS
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(restore_compile_options)
|
||||||
|
set_property(
|
||||||
|
DIRECTORY
|
||||||
|
PROPERTY COMPILE_OPTIONS
|
||||||
|
${SPIRV_TOOLS_BACKUP_EXTERNAL_COMPILE_OPTIONS}
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
if(NOT TARGET protobuf::libprotobuf OR NOT TARGET protobuf::protoc)
|
||||||
|
|
||||||
|
set(SPIRV_TOOLS_PROTOBUF_DIR ${CMAKE_CURRENT_SOURCE_DIR}/protobuf/cmake)
|
||||||
|
if (NOT IS_DIRECTORY ${SPIRV_TOOLS_PROTOBUF_DIR})
|
||||||
|
message(
|
||||||
|
FATAL_ERROR
|
||||||
|
"protobuf not found - please checkout a copy under external/.")
|
||||||
endif()
|
endif()
|
||||||
add_subdirectory(${PROTOBUF_DIR} EXCLUDE_FROM_ALL)
|
set(protobuf_BUILD_TESTS OFF CACHE BOOL "Disable protobuf tests")
|
||||||
else()
|
set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL "Do not build protobuf static runtime")
|
||||||
message(FATAL_ERROR
|
|
||||||
"protobuf not found - please checkout a copy under external/.")
|
backup_compile_options()
|
||||||
|
|
||||||
|
if (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
|
||||||
|
add_compile_options(-Wno-inconsistent-missing-override)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_subdirectory(${SPIRV_TOOLS_PROTOBUF_DIR} EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
|
restore_compile_options()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
endif(SPIRV_BUILD_FUZZER)
|
endif()
|
||||||
|
@ -71,11 +71,7 @@ git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv
|
|||||||
git clone --depth=1 https://github.com/google/googletest external/googletest
|
git clone --depth=1 https://github.com/google/googletest external/googletest
|
||||||
git clone --depth=1 https://github.com/google/effcee external/effcee
|
git clone --depth=1 https://github.com/google/effcee external/effcee
|
||||||
git clone --depth=1 https://github.com/google/re2 external/re2
|
git clone --depth=1 https://github.com/google/re2 external/re2
|
||||||
git clone --depth=1 https://github.com/protocolbuffers/protobuf external/protobuf
|
git clone --depth=1 --branch v3.13.0 https://github.com/protocolbuffers/protobuf external/protobuf
|
||||||
pushd external/protobuf
|
|
||||||
git fetch --all --tags --prune
|
|
||||||
git checkout v3.7.1
|
|
||||||
popd
|
|
||||||
|
|
||||||
mkdir build && cd $SRC/build
|
mkdir build && cd $SRC/build
|
||||||
|
|
||||||
|
@ -35,11 +35,7 @@ git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv
|
|||||||
git clone --depth=1 https://github.com/google/googletest external/googletest
|
git clone --depth=1 https://github.com/google/googletest external/googletest
|
||||||
git clone --depth=1 https://github.com/google/effcee external/effcee
|
git clone --depth=1 https://github.com/google/effcee external/effcee
|
||||||
git clone --depth=1 https://github.com/google/re2 external/re2
|
git clone --depth=1 https://github.com/google/re2 external/re2
|
||||||
git clone --depth=1 https://github.com/protocolbuffers/protobuf external/protobuf
|
git clone --depth=1 --branch v3.13.0 https://github.com/protocolbuffers/protobuf external/protobuf
|
||||||
pushd external/protobuf
|
|
||||||
git fetch --all --tags --prune
|
|
||||||
git checkout v3.7.1
|
|
||||||
popd
|
|
||||||
|
|
||||||
mkdir build && cd $SRC/build
|
mkdir build && cd $SRC/build
|
||||||
|
|
||||||
|
@ -29,11 +29,7 @@ git clone --depth=1 https://github.com/KhronosGroup/SPIRV-Headers external/spirv
|
|||||||
git clone --depth=1 https://github.com/google/googletest external/googletest
|
git clone --depth=1 https://github.com/google/googletest external/googletest
|
||||||
git clone --depth=1 https://github.com/google/effcee external/effcee
|
git clone --depth=1 https://github.com/google/effcee external/effcee
|
||||||
git clone --depth=1 https://github.com/google/re2 external/re2
|
git clone --depth=1 https://github.com/google/re2 external/re2
|
||||||
git clone --depth=1 https://github.com/protocolbuffers/protobuf external/protobuf
|
git clone --depth=1 --branch v3.13.0 https://github.com/protocolbuffers/protobuf external/protobuf
|
||||||
pushd external\protobuf
|
|
||||||
git fetch --all --tags --prune
|
|
||||||
git checkout v3.7.1
|
|
||||||
popd
|
|
||||||
|
|
||||||
:: #########################################
|
:: #########################################
|
||||||
:: set up msvc build env
|
:: set up msvc build env
|
||||||
|
@ -362,7 +362,6 @@ if(SPIRV_BUILD_FUZZER)
|
|||||||
add_library(SPIRV-Tools-fuzz ${SPIRV_TOOLS_FUZZ_SOURCES})
|
add_library(SPIRV-Tools-fuzz ${SPIRV_TOOLS_FUZZ_SOURCES})
|
||||||
|
|
||||||
spvtools_default_compile_options(SPIRV-Tools-fuzz)
|
spvtools_default_compile_options(SPIRV-Tools-fuzz)
|
||||||
target_compile_definitions(SPIRV-Tools-fuzz PUBLIC -DGOOGLE_PROTOBUF_NO_RTTI -DGOOGLE_PROTOBUF_USE_UNALIGNED=0)
|
|
||||||
|
|
||||||
# Compilation of the auto-generated protobuf source file will yield warnings,
|
# Compilation of the auto-generated protobuf source file will yield warnings,
|
||||||
# which we have no control over and thus wish to ignore.
|
# which we have no control over and thus wish to ignore.
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||||
|
#pragma clang diagnostic ignored "-Wshadow"
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wconversion"
|
#pragma GCC diagnostic ignored "-Wconversion"
|
||||||
|
Loading…
Reference in New Issue
Block a user