1 include(CheckCXXSourceCompiles)
4 CHECK_CXX_SOURCE_COMPILES("
5 static thread_local int blah;
11 if( NOT HAS_THREAD_LOCAL )
12 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Dthread_local=__thread")
16 set(LIBFUZZER_FLAGS_BASE "${CMAKE_CXX_FLAGS}")
17 if( LLVM_USE_SANITIZE_COVERAGE )
18 if(NOT "${LLVM_USE_SANITIZER}" STREQUAL "Address")
20 "LibFuzzer and its tests require LLVM_USE_SANITIZER=Address and "
21 "LLVM_USE_SANITIZE_COVERAGE=YES to be set."
25 # Disable the coverage and sanitizer instrumentation for the fuzzer itself.
26 set(CMAKE_CXX_FLAGS "${LIBFUZZER_FLAGS_BASE} -fno-sanitize-coverage=trace-pc-guard,edge,trace-cmp,indirect-calls,8bit-counters -Werror")
29 # Compile libFuzzer if the compilation is specifically requested, OR
30 # if the platform is known to be working.
31 if ( LLVM_USE_SANITIZE_COVERAGE OR CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux" )
32 add_library(LLVMFuzzerNoMainObjects OBJECT
35 FuzzerExtFunctionsDlsym.cpp
36 FuzzerExtFunctionsDlsymWin.cpp
37 FuzzerExtFunctionsWeak.cpp
38 FuzzerExtraCounters.cpp
47 FuzzerShmemWindows.cpp
55 add_library(LLVMFuzzerNoMain STATIC
56 $<TARGET_OBJECTS:LLVMFuzzerNoMainObjects>
58 target_link_libraries(LLVMFuzzerNoMain ${LLVM_PTHREAD_LIB})
59 add_library(LLVMFuzzer STATIC
61 $<TARGET_OBJECTS:LLVMFuzzerNoMainObjects>
63 target_link_libraries(LLVMFuzzer ${LLVM_PTHREAD_LIB})
66 if( LLVM_USE_SANITIZE_COVERAGE AND LLVM_INCLUDE_TESTS )
67 add_subdirectory(test)