1set(LIBFUZZER_FLAGS_BASE "${CMAKE_CXX_FLAGS}") 2# Disable the coverage and sanitizer instrumentation for the fuzzer itself. 3set(CMAKE_CXX_FLAGS "${LIBFUZZER_FLAGS_BASE} -fno-sanitize=all -fno-sanitize-coverage=edge,trace-cmp,indirect-calls,8bit-counters -Werror") 4if( LLVM_USE_SANITIZE_COVERAGE ) 5 if(NOT "${LLVM_USE_SANITIZER}" STREQUAL "Address") 6 message(FATAL_ERROR 7 "LibFuzzer and its tests require LLVM_USE_SANITIZER=Address and " 8 "LLVM_USE_SANITIZE_COVERAGE=YES to be set." 9 ) 10 endif() 11 add_library(LLVMFuzzerNoMainObjects OBJECT 12 FuzzerCrossOver.cpp 13 FuzzerTraceState.cpp 14 FuzzerDriver.cpp 15 FuzzerExtFunctionsDlsym.cpp 16 FuzzerExtFunctionsWeak.cpp 17 FuzzerIO.cpp 18 FuzzerLoop.cpp 19 FuzzerMutate.cpp 20 FuzzerSHA1.cpp 21 FuzzerTracePC.cpp 22 FuzzerUtil.cpp 23 ) 24 add_library(LLVMFuzzerNoMain STATIC 25 $<TARGET_OBJECTS:LLVMFuzzerNoMainObjects> 26 ) 27 target_link_libraries(LLVMFuzzerNoMain ${PTHREAD_LIB}) 28 add_library(LLVMFuzzer STATIC 29 FuzzerMain.cpp 30 $<TARGET_OBJECTS:LLVMFuzzerNoMainObjects> 31 ) 32 target_link_libraries(LLVMFuzzer ${PTHREAD_LIB}) 33 34 if( LLVM_INCLUDE_TESTS ) 35 add_subdirectory(test) 36 endif() 37endif() 38