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.

Fix #2350.
  • Loading branch information
wantehchang committed Aug 1, 2024
1 parent 9caff7a commit 3198490
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 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,11 @@ 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: The SYSTEM argument for add_subdirectory() is new in CMake
# version 3.25. There are compiler warnings in FuzzTest headers. Add
# the ext/fuzztest subdirectory with the SYSTEM directory property so
# that warnings in its headers are suppressed.
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 3198490

Please sign in to comment.