Files
fmt/test/fuzzing/CMakeLists.txt
T

33 lines
1.2 KiB
CMake
Raw Normal View History

2019-06-30 09:11:13 +02:00
# Copyright (c) 2019, Paul Dreik
2020-10-11 08:30:14 -07:00
# Link in the main function. Useful for reproducing, kcov, gdb, afl, valgrind.
# (Note that libFuzzer can also reproduce, just pass it the files.)
option(FMT_FUZZ_LINKMAIN "Enables the reproduce mode, instead of libFuzzer" On)
2019-06-30 09:11:13 +02:00
# For oss-fuzz - insert $LIB_FUZZING_ENGINE into the link flags, but only for
2020-10-11 08:30:14 -07:00
# the fuzz targets, otherwise the CMake configuration step fails.
2026-03-03 13:35:11 -08:00
set(FMT_FUZZ_LDFLAGS
""
CACHE STRING "LDFLAGS for the fuzz targets")
2019-06-30 09:11:13 +02:00
2020-10-14 07:13:37 -07:00
# Adds a binary for reproducing, i.e. no fuzzing, just enables replaying data
# through the fuzzers.
2026-03-03 13:35:11 -08:00
function (add_fuzzer source)
2020-10-11 08:30:14 -07:00
get_filename_component(basename ${source} NAME_WE)
2020-10-12 16:48:25 -07:00
set(name ${basename}-fuzzer)
2020-10-11 08:30:14 -07:00
add_executable(${name} ${source} fuzzer-common.h)
if (FMT_FUZZ_LINKMAIN)
2020-10-11 08:30:14 -07:00
target_sources(${name} PRIVATE main.cc)
endif ()
2019-06-30 09:11:13 +02:00
target_link_libraries(${name} PRIVATE fmt)
2020-10-11 08:30:14 -07:00
if (FMT_FUZZ_LDFLAGS)
target_link_libraries(${name} PRIVATE ${FMT_FUZZ_LDFLAGS})
endif ()
target_compile_features(${name} PRIVATE cxx_std_14)
2026-03-03 13:35:11 -08:00
endfunction ()
2019-06-30 09:11:13 +02:00
2026-03-03 13:35:11 -08:00
foreach (source chrono-duration.cc chrono-timepoint.cc float.cc named-arg.cc
one-arg.cc two-args.cc)
2020-10-11 08:30:14 -07:00
add_fuzzer(${source})
endforeach ()