diff options
author | Sebastian Pipping <sebastian@pipping.org> | 2019-09-03 21:44:47 +0200 |
---|---|---|
committer | Sebastian Pipping <sebastian@pipping.org> | 2019-09-03 23:20:26 +0200 |
commit | c9b669e42a3e1b4ecd91f23c43b3a536b080f207 (patch) | |
tree | f3fe2c8c09061321d2f4d42436518c8eb85e7b8d /expat/CMakeLists.txt | |
parent | 6da1f19625592bfb928253620cac568d9a9b9c65 (diff) | |
download | libexpat-git-c9b669e42a3e1b4ecd91f23c43b3a536b080f207.tar.gz |
CMake: Build fuzzing Expat once, not twelve times
Diffstat (limited to 'expat/CMakeLists.txt')
-rw-r--r-- | expat/CMakeLists.txt | 7 |
1 files changed, 6 insertions, 1 deletions
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=<sanitizer>' and " "-DCMAKE_CXX_FLAGS='-fsanitize=<sanitizer>' and " + "-DCMAKE_STATIC_LINKER_FLAGS='-fsanitize=<sanitizer>' and " "-DCMAKE_EXE_LINKER_FLAGS='-fsanitize=<sanitizer>' 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) |