1set(LIBFUZZER_FLAGS_BASE "${CMAKE_CXX_FLAGS_RELEASE}")
2# Disable the coverage and sanitizer instrumentation for the fuzzer itself.
3set(CMAKE_CXX_FLAGS_RELEASE "${LIBFUZZER_FLAGS_BASE} -O2 -fno-sanitize=all")
4if( LLVM_USE_SANITIZE_COVERAGE )
5  add_library(LLVMFuzzerNoMainObjects OBJECT
6    FuzzerCrossOver.cpp
7    FuzzerInterface.cpp
8    FuzzerTraceState.cpp
9    FuzzerDriver.cpp
10    FuzzerIO.cpp
11    FuzzerLoop.cpp
12    FuzzerMutate.cpp
13    FuzzerSanitizerOptions.cpp
14    FuzzerSHA1.cpp
15    FuzzerUtil.cpp
16    )
17  add_library(LLVMFuzzerNoMain STATIC
18    $<TARGET_OBJECTS:LLVMFuzzerNoMainObjects>
19    )
20  if( HAVE_LIBPTHREAD )
21    target_link_libraries(LLVMFuzzerNoMain pthread)
22  endif()
23  add_library(LLVMFuzzer STATIC
24    FuzzerMain.cpp
25    $<TARGET_OBJECTS:LLVMFuzzerNoMainObjects>
26    )
27  if( HAVE_LIBPTHREAD )
28    target_link_libraries(LLVMFuzzer pthread)
29  endif()
30
31  if( LLVM_INCLUDE_TESTS )
32    add_subdirectory(test)
33  endif()
34endif()
35