blob: cc38904843b709e4a2834ab7ca06e46676a0bcd2 [file] [log] [blame]
Juraj Vijtiukf3939c92019-05-14 13:07:38 +02001cmake_minimum_required(VERSION 2.8.12)
2
Juraj Vijtiukc496e6f2020-06-30 16:15:01 +02003set(fuzz_targets lys_parse_mem lyd_parse_mem buf_add_char yang_parse_module)
Juraj Vijtiukf3939c92019-05-14 13:07:38 +02004
Juraj Vijtiuk260407e2020-03-18 10:32:13 +01005if(FUZZER STREQUAL "AFL")
6 foreach(target_name IN LISTS fuzz_targets)
7 add_executable(${target_name} ${target_name}.c main.c $<TARGET_OBJECTS:yangobj>)
8 target_link_libraries(${target_name} yang)
9 target_link_libraries(${target_name} ${CMAKE_THREADS_LIB_INIT})
10 endforeach(target_name)
11elseif(FUZZER STREQUAL "LibFuzzer")
12 foreach(target_name IN LISTS fuzz_targets)
13 add_executable(${target_name} ${target_name}.c $<TARGET_OBJECTS:yangobj>)
14 set_source_files_properties(${target_name}.c PROPERTIES COMPILE_FLAGS "-fsanitize=fuzzer")
15 target_link_libraries(${target_name} yang "-fsanitize=fuzzer")
16 endforeach(target_name)
17endif()