tests UPDATE fuzz build and sources updated
diff --git a/tests/fuzz/CMakeLists.txt b/tests/fuzz/CMakeLists.txt
index 66c0353..98737c7 100644
--- a/tests/fuzz/CMakeLists.txt
+++ b/tests/fuzz/CMakeLists.txt
@@ -1,32 +1,28 @@
-cmake_minimum_required(VERSION 2.8.12)
+if(ENABLE_FUZZ_TARGETS)
+ set(fuzz_targets lys_parse_mem lyd_parse_mem_xml lyd_parse_mem_json buf_add_char yang_parse_module)
-if (ENABLE_FUZZ_TARGETS)
- set(fuzz_targets lys_parse_mem lyd_parse_mem_xml lyd_parse_mem_json buf_add_char yang_parse_module)
-
- if(FUZZER STREQUAL "AFL")
- foreach(target_name IN LISTS fuzz_targets)
- add_executable(${target_name}_fuzz_harness ${target_name}.c main.c $<TARGET_OBJECTS:yangobj>)
- target_link_libraries(${target_name}_fuzz_harness yang)
- target_link_libraries(${target_name}_fuzz_harness ${CMAKE_THREADS_LIB_INIT})
- endforeach(target_name)
- elseif(FUZZER STREQUAL "LibFuzzer")
- foreach(target_name IN LISTS fuzz_targets)
- add_executable(${target_name}_fuzz_harness ${target_name}.c $<TARGET_OBJECTS:yangobj>)
- set_source_files_properties(${target_name}.c PROPERTIES COMPILE_FLAGS "-fsanitize=fuzzer")
- target_link_libraries(${target_name}_fuzz_harness yang "-fsanitize=fuzzer")
- endforeach(target_name)
- endif()
+ if(FUZZER STREQUAL "AFL")
+ foreach(target_name IN LISTS fuzz_targets)
+ add_executable(${target_name}_fuzz_harness ${target_name}.c main.c)
+ target_link_libraries(${target_name}_fuzz_harness yang)
+ endforeach()
+ elseif()
+ foreach(target_name IN LISTS fuzz_targets)
+ add_executable(${target_name}_fuzz_harness ${target_name}.c)
+ set_source_files_properties(${target_name}.c PROPERTIES COMPILE_FLAGS "-fsanitize=fuzzer")
+ target_link_libraries(${target_name}_fuzz_harness yang "-fsanitize=fuzzer")
+ endforeach()
+ endif()
endif()
-if (ENABLE_TESTS)
- add_executable(fuzz_regression_test fuzz_regression_test.c)
- set(fuzz_regression_tests lys_parse_mem lyd_parse_mem_xml lyd_parse_mem_json)
- foreach(target_name IN LISTS fuzz_regression_tests)
- file(COPY ${CMAKE_SOURCE_DIR}/tests/fuzz/corpus/${target_name} DESTINATION ${CMAKE_BINARY_DIR}/tests/fuzz/)
- add_executable(regress_fuzz_${target_name} ${target_name}.c main.c $<TARGET_OBJECTS:yangobj>)
- set_target_properties(regress_fuzz_${target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests/fuzz/${target_name}")
- target_link_libraries(regress_fuzz_${target_name} yang)
- target_link_libraries(regress_fuzz_${target_name} ${CMAKE_THREADS_LIB_INIT})
- add_test(NAME regress_fuzz_${target_name} COMMAND fuzz_regression_test regress_fuzz_${target_name} . WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fuzz/${target_name})
- endforeach(target_name)
+if(ENABLE_TESTS)
+ add_executable(fuzz_regression_test fuzz_regression_test.c)
+ set(fuzz_regression_tests lys_parse_mem lyd_parse_mem_xml lyd_parse_mem_json)
+ foreach(target_name IN LISTS fuzz_regression_tests)
+ file(COPY ${CMAKE_SOURCE_DIR}/tests/fuzz/corpus/${target_name} DESTINATION ${CMAKE_BINARY_DIR}/tests/fuzz/)
+ add_executable(regress_fuzz_${target_name} ${target_name}.c main.c)
+ set_target_properties(regress_fuzz_${target_name} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests/fuzz/${target_name}")
+ target_link_libraries(regress_fuzz_${target_name} yang)
+ add_test(NAME regress_fuzz_${target_name} COMMAND fuzz_regression_test regress_fuzz_${target_name} . WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/tests/fuzz/${target_name})
+ endforeach()
endif()