-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
53 lines (46 loc) · 1.7 KB
/
CMakeLists.txt
File metadata and controls
53 lines (46 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
cmake_minimum_required(VERSION 3.20)
project(protocol_parser C)
# ── Normal library + application build ──────────────────────────────
add_library(protocol STATIC
src/decoder.c
src/session.c
)
target_include_directories(protocol PUBLIC include)
target_compile_definitions(protocol PUBLIC PROTO_MAX_VERSIONS=8)
add_executable(parser src/main.c)
target_link_libraries(parser PRIVATE protocol)
# ── Fuzzing targets ─────────────────────────────────────────────────
#
# Enable with:
# cmake -B build -G Ninja \
# -DENABLE_FUZZING=ON \
# -DCMAKE_C_COMPILER=clang \
# -DAbsolution_DIR=<prefix>/lib/cmake/Absolution
#
# cmake --build build --target fuzz_decode
#
# Run:
# ./build/fuzz_decode corpus/ -seed=1
option(ENABLE_FUZZING "Build fuzz targets" OFF)
if(ENABLE_FUZZING)
find_package(Absolution REQUIRED)
# The TARGETS are the .c files whose globals we want absolution to sample.
# The HARNESS is our test function that exercises the code under those globals.
# ENTRY names the function in the harness (must match the C definition).
#
# LINK_LIBRARIES automatically propagates include dirs and compile
# definitions from the protocol target (declared PUBLIC above), so we
# don't need to duplicate INCLUDE_DIRECTORIES or COMPILE_DEFINITIONS.
absolution_add_fuzzer(
NAME fuzz_decode
TARGETS
src/decoder.c
src/session.c
HARNESS
fuzz/fuzz_decode.c
ENTRY
FuzzDecode
LINK_LIBRARIES
protocol
)
endif()