| a0630906 |
Poul Sander |
2022-01-15 13:59 |
1 |
# Copyright (c) 2019, Paul Dreik |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
2 |
# License: see LICENSE.rst in the fmt root directory |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
3 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
4 |
# Link in the main function. Useful for reproducing, kcov, gdb, afl, valgrind. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
5 |
# (Note that libFuzzer can also reproduce, just pass it the files.) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
6 |
option(FMT_FUZZ_LINKMAIN "Enables the reproduce mode, instead of libFuzzer" On) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
7 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
8 |
# For oss-fuzz - insert $LIB_FUZZING_ENGINE into the link flags, but only for |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
9 |
# the fuzz targets, otherwise the CMake configuration step fails. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
10 |
set(FMT_FUZZ_LDFLAGS "" CACHE STRING "LDFLAGS for the fuzz targets") |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
11 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
12 |
# Adds a binary for reproducing, i.e. no fuzzing, just enables replaying data |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
13 |
# through the fuzzers. |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
14 |
function(add_fuzzer source) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
15 |
get_filename_component(basename ${source} NAME_WE) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
16 |
set(name ${basename}-fuzzer) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
17 |
add_executable(${name} ${source} fuzzer-common.h) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
18 |
if (FMT_FUZZ_LINKMAIN) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
19 |
target_sources(${name} PRIVATE main.cc) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
20 |
endif () |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
21 |
target_link_libraries(${name} PRIVATE fmt) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
22 |
if (FMT_FUZZ_LDFLAGS) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
23 |
target_link_libraries(${name} PRIVATE ${FMT_FUZZ_LDFLAGS}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
24 |
endif () |
| 47fd5c32 |
Poul Sander |
2024-10-05 08:44 |
25 |
target_compile_features(${name} PRIVATE cxx_std_14) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
26 |
endfunction() |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
27 |
|
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
28 |
foreach (source chrono-duration.cc chrono-timepoint.cc float.cc named-arg.cc one-arg.cc two-args.cc) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
29 |
add_fuzzer(${source}) |
| a0630906 |
Poul Sander |
2022-01-15 13:59 |
30 |
endforeach () |
|
|
1970-01-01 00:00 |
31 |
|