Skip to content

Commit

Permalink
Enable compiler warnings in fuzztest targets
Browse files Browse the repository at this point in the history
Pass the SYSTEM argument to add_subdirectory(ext/fuzztest) to treat
FuzzTest headers as system headers. This suppresses compiler warnings in
FuzzTest headers.

Require cmake 3.25 for AVIF_LOCAL_FUZZTEST.

Fix AOMediaCodec#2350.
  • Loading branch information
wantehchang authored Aug 1, 2024
1 parent f3c8441 commit 622ec93
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,10 @@ option(AVIF_ENABLE_GTEST
option(AVIF_ENABLE_FUZZTEST "Build avif fuzztest targets. Requires Google FuzzTest. Has no effect unless AVIF_BUILD_TESTS is ON."
OFF
)
option(AVIF_LOCAL_FUZZTEST
"Build the Google FuzzTest framework by providing your own copy of the repo in ext/fuzztest (see Local Builds in README)"
OFF
option(
AVIF_LOCAL_FUZZTEST
"Build the Google FuzzTest framework by providing your own copy of the repo in ext/fuzztest (see Local Builds in README). CMake must be at least 3.25."
OFF
)

# Whether the libavif library uses c++ indirectly (e.g. through linking to libyuv).
Expand Down
13 changes: 8 additions & 5 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,7 @@ if(AVIF_ENABLE_FUZZTEST)
macro(add_avif_fuzztest TEST_NAME)
add_executable(${TEST_NAME} gtest/${TEST_NAME}.cc gtest/avif_fuzztest_helpers.cc ${ARGN})
# FuzzTest bundles GoogleTest so no need to link to gtest librairies.
# NOTE: FuzzTest and Abseil headers have compiler warnings (mostly
# -Wsign-compare and some -Wunused-parameter and -Wshorten-64-to-32),
# so we don't enable compiler warnings on the fuzztest targets.
target_link_libraries(${TEST_NAME} PRIVATE aviftest_helpers_internal)
target_link_libraries(${TEST_NAME} PRIVATE aviftest_helpers_internal avif_enable_warnings)
link_fuzztest(${TEST_NAME})
add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME})
set_property(TEST ${TEST_NAME} PROPERTY ENVIRONMENT "TEST_DATA_DIRS=${CMAKE_CURRENT_SOURCE_DIR}/data/")
Expand All @@ -201,7 +198,13 @@ if(AVIF_ENABLE_FUZZTEST)
# FUZZTEST_REPLAY=/path/to/repro_file.test
# and running one of the targets below.
# See https://github.com/google/fuzztest/blob/main/doc/quickstart-cmake.md
add_subdirectory(${AVIF_SOURCE_DIR}/ext/fuzztest ${AVIF_SOURCE_DIR}/ext/fuzztest/build.libavif EXCLUDE_FROM_ALL)
# Note: There are compiler warnings in the FuzzTest headers. Add the
# ext/fuzztest subdirectory with the SYSTEM directory property set to
# true so that warnings in its headers are suppressed.
if(CMAKE_VERSION VERSION_LESS 3.25.0)
message(FATAL_ERROR "CMake must be at least 3.25 to pass the SYSTEM argument to add_subdirectory(), bailing out")
endif()
add_subdirectory(${AVIF_SOURCE_DIR}/ext/fuzztest ${AVIF_SOURCE_DIR}/ext/fuzztest/build.libavif EXCLUDE_FROM_ALL SYSTEM)
else()
message(
FATAL_ERROR
Expand Down

0 comments on commit 622ec93

Please sign in to comment.