CMakeLists.txt 968 Bytes
Newer Older
1 2
LINK_DIRECTORIES(${LIBGIT2_LIBDIRS})
INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES})
3
INCLUDE_DIRECTORIES(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
4

5 6 7 8
IF(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
	ADD_C_FLAG(-fsanitize=fuzzer)
ENDIF ()

9
FILE(GLOB SRC_FUZZ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *_fuzzer.c)
10 11
FOREACH(fuzz_target_src ${SRC_FUZZ})
	STRING(REPLACE ".c" "" fuzz_target_name ${fuzz_target_src})
12 13
	STRING(REPLACE "_fuzzer" "" fuzz_name ${fuzz_target_name})

14 15 16 17 18
	SET(${fuzz_target_name}_SOURCES ${fuzz_target_src} ${LIBGIT2_OBJECTS})
	IF(USE_STANDALONE_FUZZERS)
		LIST(APPEND ${fuzz_target_name}_SOURCES "standalone_driver.c")
	ENDIF()
	ADD_EXECUTABLE(${fuzz_target_name} ${${fuzz_target_name}_SOURCES})
19
	SET_TARGET_PROPERTIES(${fuzz_target_name} PROPERTIES C_STANDARD 90)
20
	TARGET_LINK_LIBRARIES(${fuzz_target_name} ${LIBGIT2_LIBS})
21 22

	ADD_TEST(${fuzz_target_name} "${CMAKE_CURRENT_BINARY_DIR}/${fuzz_target_name}" "${CMAKE_CURRENT_SOURCE_DIR}/corpora/${fuzz_name}")
23
ENDFOREACH()