1 set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} FuzzerCLI)
2 set(CXX_FLAGS_NOFUZZ ${CMAKE_CXX_FLAGS})
3 set(DUMMY_MAIN DummyClangFuzzer.cpp)
4 if(LLVM_LIB_FUZZING_ENGINE)
6 elseif(LLVM_USE_SANITIZE_COVERAGE)
7 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
8 set(CXX_FLAGS_NOFUZZ "${CXX_FLAGS_NOFUZZ} -fsanitize=fuzzer-no-link")
12 # Needed by LLVM's CMake checks because this file defines multiple targets.
13 set(LLVM_OPTIONAL_SOURCES
15 ClangObjectiveCFuzzer.cpp
17 ExampleClangProtoFuzzer.cpp
18 ExampleClangLoopProtoFuzzer.cpp
19 ExampleClangLLVMProtoFuzzer.cpp
22 if(CLANG_ENABLE_PROTO_FUZZER)
23 # Create protobuf .h and .cc files, and put them in a library for use by
24 # clang-proto-fuzzer components.
25 find_package(Protobuf REQUIRED)
26 add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
27 include_directories(${PROTOBUF_INCLUDE_DIRS})
28 include_directories(${CMAKE_CURRENT_BINARY_DIR})
29 protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
30 protobuf_generate_cpp(LOOP_PROTO_SRCS LOOP_PROTO_HDRS cxx_loop_proto.proto)
31 set(LLVM_OPTIONAL_SOURCES ${LLVM_OPTIONAL_SOURCES} ${PROTO_SRCS})
32 add_clang_library(clangCXXProto
40 add_clang_library(clangCXXLoopProto
48 # Build and include libprotobuf-mutator
49 include(ProtobufMutator)
50 include_directories(${ProtobufMutator_INCLUDE_DIRS})
52 # Build the protobuf->C++ translation library and driver.
53 add_clang_subdirectory(proto-to-cxx)
55 # Build the protobuf->LLVM IR translation library and driver.
56 add_clang_subdirectory(proto-to-llvm)
58 # Build the fuzzer initialization library.
59 add_clang_subdirectory(fuzzer-initialize)
61 # Build the protobuf fuzzer
62 add_clang_executable(clang-proto-fuzzer
64 ExampleClangProtoFuzzer.cpp
67 # Build the loop protobuf fuzzer
68 add_clang_executable(clang-loop-proto-fuzzer
70 ExampleClangLoopProtoFuzzer.cpp
73 # Build the llvm protobuf fuzzer
74 add_clang_executable(clang-llvm-proto-fuzzer
76 ExampleClangLLVMProtoFuzzer.cpp
79 set(COMMON_PROTO_FUZZ_LIBRARIES
80 ${ProtobufMutator_LIBRARIES}
82 ${LLVM_LIB_FUZZING_ENGINE}
86 target_link_libraries(clang-proto-fuzzer
88 ${COMMON_PROTO_FUZZ_LIBRARIES}
93 target_link_libraries(clang-loop-proto-fuzzer
95 ${COMMON_PROTO_FUZZ_LIBRARIES}
100 target_link_libraries(clang-llvm-proto-fuzzer
102 ${COMMON_PROTO_FUZZ_LIBRARIES}
110 add_clang_subdirectory(handle-cxx)
111 add_clang_subdirectory(handle-llvm)
112 add_clang_subdirectory(dictionary)
114 add_clang_executable(clang-fuzzer
120 target_link_libraries(clang-fuzzer
122 ${LLVM_LIB_FUZZING_ENGINE}
126 add_clang_executable(clang-objc-fuzzer
129 ClangObjectiveCFuzzer.cpp
132 target_link_libraries(clang-objc-fuzzer
134 ${LLVM_LIB_FUZZING_ENGINE}