[PATCH] D38858: [cmake] Allow building fuzzers with OSS-Fuzz flags.

Matt Morehouse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 12 14:58:57 PDT 2017


This revision was automatically updated to reflect the committed changes.
morehouse marked an inline comment as done.
Closed by commit rL315629: [cmake] Allow building fuzzers with OSS-Fuzz flags. (authored by morehouse).

Changed prior to commit:
  https://reviews.llvm.org/D38858?vs=118839&id=118849#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38858

Files:
  llvm/trunk/CMakeLists.txt
  llvm/trunk/cmake/modules/AddLLVM.cmake


Index: llvm/trunk/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/trunk/cmake/modules/AddLLVM.cmake
+++ llvm/trunk/cmake/modules/AddLLVM.cmake
@@ -894,15 +894,20 @@
 
 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})
     set_target_properties(${name} PROPERTIES FOLDER "Fuzzers")
   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)
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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38858.118849.patch
Type: text/x-patch
Size: 1602 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171012/c6261eb5/attachment.bin>


More information about the llvm-commits mailing list