From: Nathan Moinvaziri Date: Mon, 28 Mar 2022 23:52:02 +0000 (-0700) Subject: Use standalone fuzzing runner only when fuzzing engine is not found. X-Git-Tag: 2.1.0-beta1~293 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98d4908aa67437e199544493fa63d84c16070c54;p=thirdparty%2Fzlib-ng.git Use standalone fuzzing runner only when fuzzing engine is not found. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bc748a8..8241d32e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1252,12 +1252,30 @@ if(ZLIB_ENABLE_TESTS) -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/run-and-compare.cmake) if(WITH_FUZZERS) + if(CMAKE_C_COMPILER_ID MATCHES "Clang") + enable_language(CXX) + + if(DEFINED ENV{LIB_FUZZING_ENGINE}) + set(FUZZING_ENGINE $ENV{LIB_FUZZING_ENGINE}) + set(FUZZING_ENGINE_FOUND ON) + else() + find_library(FUZZING_ENGINE "FuzzingEngine") + endif() + endif() + set(FUZZERS checksum compress example_small example_large example_flush example_dict minigzip) file(GLOB ALL_SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*") foreach(FUZZER ${FUZZERS}) - add_executable(fuzzer_${FUZZER} test/fuzz/fuzzer_${FUZZER}.c test/fuzz/standalone_fuzz_target_runner.c) + set(FUZZER_SRCS test/fuzz/fuzzer_${FUZZER}.c) + if(NOT FUZZING_ENGINE_FOUND) + list(APPEND FUZZER_SRCS test/fuzz/standalone_fuzz_target_runner.c) + endif() + add_executable(fuzzer_${FUZZER} ${FUZZER_SRCS}) configure_test_executable(fuzzer_${FUZZER}) target_link_libraries(fuzzer_${FUZZER} zlib) + if(FUZZING_ENGINE_FOUND) + target_link_libraries(fuzzer_${FUZZER} ${FUZZING_ENGINE}) + endif() set(FUZZER_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${ALL_SRC_FILES}) add_test(NAME fuzzer_${FUZZER} COMMAND ${FUZZER_COMMAND}) endforeach()