[llvm] r315629 - [cmake] Allow building fuzzers with OSS-Fuzz flags.
Matt Morehouse via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 12 14:58:41 PDT 2017
Author: morehouse
Date: Thu Oct 12 14:58:41 2017
New Revision: 315629
URL: http://llvm.org/viewvc/llvm-project?rev=315629&view=rev
Log:
[cmake] Allow building fuzzers with OSS-Fuzz flags.
Reviewers: kcc, bogner
Reviewed By: bogner
Subscribers: mgorny, llvm-commits
Differential Revision: https://reviews.llvm.org/D38858
Modified:
llvm/trunk/CMakeLists.txt
llvm/trunk/cmake/modules/AddLLVM.cmake
Modified: llvm/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=315629&r1=315628&r2=315629&view=diff
==============================================================================
--- llvm/trunk/CMakeLists.txt (original)
+++ llvm/trunk/CMakeLists.txt Thu Oct 12 14:58:41 2017
@@ -435,6 +435,8 @@ endif( LLVM_USE_OPROFILE )
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)
Modified: llvm/trunk/cmake/modules/AddLLVM.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=315629&r1=315628&r2=315629&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/AddLLVM.cmake (original)
+++ llvm/trunk/cmake/modules/AddLLVM.cmake Thu Oct 12 14:58:41 2017
@@ -894,7 +894,12 @@ endmacro(add_llvm_utility name)
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 @@ macro(add_llvm_fuzzer name)
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)
More information about the llvm-commits
mailing list