• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-coverage=trace-pc-guard,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    FuzzerDriver.cpp
14    FuzzerExtFunctionsDlsym.cpp
15    FuzzerExtFunctionsWeak.cpp
16    FuzzerExtFunctionsWeakAlias.cpp
17    FuzzerIO.cpp
18    FuzzerIOPosix.cpp
19    FuzzerIOWindows.cpp
20    FuzzerLoop.cpp
21    FuzzerMerge.cpp
22    FuzzerMutate.cpp
23    FuzzerSHA1.cpp
24    FuzzerTracePC.cpp
25    FuzzerTraceState.cpp
26    FuzzerUtil.cpp
27    FuzzerUtilDarwin.cpp
28    FuzzerUtilLinux.cpp
29    FuzzerUtilPosix.cpp
30    FuzzerUtilWindows.cpp
31    )
32  add_library(LLVMFuzzerNoMain STATIC
33    $<TARGET_OBJECTS:LLVMFuzzerNoMainObjects>
34    )
35  target_link_libraries(LLVMFuzzerNoMain ${PTHREAD_LIB})
36  add_library(LLVMFuzzer STATIC
37    FuzzerMain.cpp
38    $<TARGET_OBJECTS:LLVMFuzzerNoMainObjects>
39    )
40  target_link_libraries(LLVMFuzzer ${PTHREAD_LIB})
41
42  if( LLVM_INCLUDE_TESTS )
43    add_subdirectory(test)
44  endif()
45endif()
46