From 0c976ec704948eccc5d63e8d1cd7c709241e1f8a Mon Sep 17 00:00:00 2001 From: lazymio Date: Wed, 6 Oct 2021 16:24:52 +0200 Subject: [PATCH] Don't build samples and tests to save time when fuzzing --- CMakeLists.txt | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00e57bc4..b561cf5c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1145,25 +1145,6 @@ else() endif() -foreach(SAMPLE_FILE ${UNICORN_SAMPLE_FILE}) - add_executable(${SAMPLE_FILE} - ${CMAKE_CURRENT_SOURCE_DIR}/samples/${SAMPLE_FILE}.c - ) - target_link_libraries(${SAMPLE_FILE} - ${SAMPLES_LIB} - ) -endforeach(SAMPLE_FILE) - -foreach(TEST_FILE ${UNICORN_TEST_FILE}) - add_executable(${TEST_FILE} - ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit/${TEST_FILE}.c - ) - target_link_libraries(${TEST_FILE} - ${SAMPLES_LIB} - ) - add_test(${TEST_FILE} ${TEST_FILE}) -endforeach(TEST_FILE) - if(UNICORN_FUZZ) set(UNICORN_FUZZ_SUFFIX "arm_arm;arm_armbe;arm_thumb;arm64_arm;arm64_armbe;m68k_be;mips_32be;mips_32le;sparc_32be;x86_16;x86_32;x86_64") set(SAMPLES_LIB ${SAMPLES_LIB} rt) @@ -1175,11 +1156,26 @@ if(UNICORN_FUZZ) target_link_libraries(fuzz_emu_${SUFFIX} ${SAMPLES_LIB} ) - # oss-fuzz requires statically linked executables. - target_link_options(fuzz_emu_${SUFFIX} PRIVATE - -static - ) endforeach() +else() + foreach(SAMPLE_FILE ${UNICORN_SAMPLE_FILE}) + add_executable(${SAMPLE_FILE} + ${CMAKE_CURRENT_SOURCE_DIR}/samples/${SAMPLE_FILE}.c + ) + target_link_libraries(${SAMPLE_FILE} + ${SAMPLES_LIB} + ) + endforeach(SAMPLE_FILE) + + foreach(TEST_FILE ${UNICORN_TEST_FILE}) + add_executable(${TEST_FILE} + ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit/${TEST_FILE}.c + ) + target_link_libraries(${TEST_FILE} + ${SAMPLES_LIB} + ) + add_test(${TEST_FILE} ${TEST_FILE}) + endforeach(TEST_FILE) endif() if(NOT MSVC)