File: CMakeLists.txt

package info (click to toggle)
cjson 1.7.19-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,996 kB
  • sloc: ansic: 16,797; ruby: 3,083; makefile: 338; python: 220; sh: 26
file content (34 lines) | stat: -rw-r--r-- 1,169 bytes parent folder | download | duplicates (4)
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
option(ENABLE_FUZZING "Create executables and targets for fuzzing cJSON with afl." Off)
if (ENABLE_FUZZING)
    find_program(AFL_FUZZ afl-fuzz)
    if ("${AFL_FUZZ}" MATCHES "AFL_FUZZ-NOTFOUND")
        message(FATAL_ERROR "Couldn't find afl-fuzz.")
    endif()

    add_executable(afl-main afl.c)
    target_link_libraries(afl-main "${CJSON_LIB}")

    if (NOT ENABLE_SANITIZERS)
        message(FATAL_ERROR "Enable sanitizers with -DENABLE_SANITIZERS=On to do fuzzing.")
    endif()

    option(ENABLE_FUZZING_PRINT "Fuzz printing functions together with parser." On)
    set(fuzz_print_parameter "no")
    if (ENABLE_FUZZING_PRINT)
        set(fuzz_print_parameter "yes")
    endif()

    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error")

    add_custom_target(afl
        COMMAND "${AFL_FUZZ}" -i "${CMAKE_CURRENT_SOURCE_DIR}/inputs" -o "${CMAKE_CURRENT_BINARY_DIR}/findings" -x "${CMAKE_CURRENT_SOURCE_DIR}/json.dict" -- "${CMAKE_CURRENT_BINARY_DIR}/afl-main" "@@" "${fuzz_print_parameter}"
        DEPENDS afl-main)


endif()

if(ENABLE_CJSON_TEST)
    ADD_EXECUTABLE(fuzz_main fuzz_main.c cjson_read_fuzzer.c)
    TARGET_LINK_LIBRARIES(fuzz_main cjson)
endif()