Index: llvm/trunk/CMakeLists.txt =================================================================== --- llvm/trunk/CMakeLists.txt +++ llvm/trunk/CMakeLists.txt @@ -435,6 +435,8 @@ set(LLVM_USE_SANITIZER "" CACHE STRING "Define the sanitizer used to build binaries and tests.") +set(LLVM_LIB_FUZZING_ENGINE "" CACHE PATH + "Path to fuzzing library for linking with fuzz targets") option(LLVM_USE_SPLIT_DWARF "Use -gsplit-dwarf when compiling llvm." OFF) Index: llvm/trunk/cmake/modules/AddLLVM.cmake =================================================================== --- llvm/trunk/cmake/modules/AddLLVM.cmake +++ llvm/trunk/cmake/modules/AddLLVM.cmake @@ -894,7 +894,12 @@ macro(add_llvm_fuzzer name) cmake_parse_arguments(ARG "" "DUMMY_MAIN" "" ${ARGN}) - if( LLVM_USE_SANITIZE_COVERAGE ) + if( LLVM_LIB_FUZZING_ENGINE ) + set(LLVM_OPTIONAL_SOURCES ${ARG_DUMMY_MAIN}) + add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS}) + target_link_libraries(${name} ${LLVM_LIB_FUZZING_ENGINE}) + set_target_properties(${name} PROPERTIES FOLDER "Fuzzers") + elseif( LLVM_USE_SANITIZE_COVERAGE ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer") set(LLVM_OPTIONAL_SOURCES ${ARG_DUMMY_MAIN}) add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS}) @@ -902,7 +907,7 @@ elseif( ARG_DUMMY_MAIN ) add_llvm_executable(${name} ${ARG_DUMMY_MAIN} ${ARG_UNPARSED_ARGUMENTS}) set_target_properties(${name} PROPERTIES FOLDER "Fuzzers") -endif() + endif() endmacro() macro(add_llvm_target target_name)