From c9b669e42a3e1b4ecd91f23c43b3a536b080f207 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Tue, 3 Sep 2019 21:44:47 +0200 Subject: CMake: Build fuzzing Expat once, not twelve times --- expat/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'expat/CMakeLists.txt') diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt index 73433974..fd076429 100644 --- a/expat/CMakeLists.txt +++ b/expat/CMakeLists.txt @@ -384,6 +384,7 @@ if(EXPAT_BUILD_FUZZERS) "This is likely in error - consider adding " "-DCMAKE_C_FLAGS='-fsanitize=' and " "-DCMAKE_CXX_FLAGS='-fsanitize=' and " + "-DCMAKE_STATIC_LINKER_FLAGS='-fsanitize=' and " "-DCMAKE_EXE_LINKER_FLAGS='-fsanitize=' to your cmake " "execution.") endif() @@ -391,10 +392,14 @@ if(EXPAT_BUILD_FUZZERS) set(encoding_types UTF-16 UTF-8 ISO-8859-1 US-ASCII UTF-16BE UTF-16LE) set(fuzz_targets xml_parse_fuzzer xml_parsebuffer_fuzzer) + add_library(fuzzpat STATIC ${expat_SRCS}) + target_compile_options(fuzzpat PRIVATE -fsanitize=fuzzer-no-link) + foreach(fuzz_target ${fuzz_targets}) foreach(encoding_type ${encoding_types}) set(target_name ${fuzz_target}_${encoding_type}) - add_executable(${target_name} fuzz/${fuzz_target}.c ${expat_SRCS}) + add_executable(${target_name} fuzz/${fuzz_target}.c) + target_link_libraries(${target_name} fuzzpat) target_compile_definitions(${target_name} PRIVATE ENCODING_FOR_FUZZING=${encoding_type}) target_compile_options(${target_name} PRIVATE -fsanitize=fuzzer-no-link) -- cgit v1.2.1