Mercurial > minori
comparison dep/fmt/test/fuzzing/CMakeLists.txt @ 343:1faa72660932
*: transfer back to cmake from autotools
autotools just made lots of things more complicated than
they should have and many things broke (i.e. translations)
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Thu, 20 Jun 2024 05:56:06 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
342:adb79bdde329 | 343:1faa72660932 |
---|---|
1 # Copyright (c) 2019, Paul Dreik | |
2 # License: see LICENSE.rst in the fmt root directory | |
3 | |
4 # Link in the main function. Useful for reproducing, kcov, gdb, afl, valgrind. | |
5 # (Note that libFuzzer can also reproduce, just pass it the files.) | |
6 option(FMT_FUZZ_LINKMAIN "Enables the reproduce mode, instead of libFuzzer" On) | |
7 | |
8 # For oss-fuzz - insert $LIB_FUZZING_ENGINE into the link flags, but only for | |
9 # the fuzz targets, otherwise the CMake configuration step fails. | |
10 set(FMT_FUZZ_LDFLAGS "" CACHE STRING "LDFLAGS for the fuzz targets") | |
11 | |
12 # Adds a binary for reproducing, i.e. no fuzzing, just enables replaying data | |
13 # through the fuzzers. | |
14 function(add_fuzzer source) | |
15 get_filename_component(basename ${source} NAME_WE) | |
16 set(name ${basename}-fuzzer) | |
17 add_executable(${name} ${source} fuzzer-common.h) | |
18 if (FMT_FUZZ_LINKMAIN) | |
19 target_sources(${name} PRIVATE main.cc) | |
20 endif () | |
21 target_link_libraries(${name} PRIVATE fmt) | |
22 if (FMT_FUZZ_LDFLAGS) | |
23 target_link_libraries(${name} PRIVATE ${FMT_FUZZ_LDFLAGS}) | |
24 endif () | |
25 target_compile_features(${name} PRIVATE cxx_std_14) | |
26 endfunction() | |
27 | |
28 foreach (source chrono-duration.cc chrono-timepoint.cc float.cc named-arg.cc one-arg.cc two-args.cc) | |
29 add_fuzzer(${source}) | |
30 endforeach () |