[llvm] r312200 - cmake: Invent add_llvm_fuzzer to set up fuzzer targets
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 30 17:36:33 PDT 2017
Author: bogner
Date: Wed Aug 30 17:36:33 2017
New Revision: 312200
URL: http://llvm.org/viewvc/llvm-project?rev=312200&view=rev
Log:
cmake: Invent add_llvm_fuzzer to set up fuzzer targets
This moves the cmake configuration for fuzzers in LLVM to a new macro,
add_llvm_fuzzer. This will make it easier to keep things consistent
while implementing llvm.org/pr34314.
I've also made a couple of minor functional changes here:
- the fuzzers now use add_llvm_executable rather than add_llvm_tool.
This means they won't create install targets and stuff like that,
because those made little sense for these fuzzers.
- I've grouped these under "Fuzzers" rather than in with "Tools" for
people who build with IDEs.
Modified:
llvm/trunk/cmake/modules/AddLLVM.cmake
llvm/trunk/tools/llvm-as-fuzzer/CMakeLists.txt
llvm/trunk/tools/llvm-dwarfdump/CMakeLists.txt
llvm/trunk/tools/llvm-dwarfdump/fuzzer/CMakeLists.txt
llvm/trunk/tools/llvm-isel-fuzzer/CMakeLists.txt
llvm/trunk/tools/llvm-mc-assemble-fuzzer/CMakeLists.txt
llvm/trunk/tools/llvm-mc-disassemble-fuzzer/CMakeLists.txt
Modified: llvm/trunk/cmake/modules/AddLLVM.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=312200&r1=312199&r2=312200&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/AddLLVM.cmake (original)
+++ llvm/trunk/cmake/modules/AddLLVM.cmake Wed Aug 30 17:36:33 2017
@@ -892,6 +892,13 @@ macro(add_llvm_utility name)
endif()
endmacro(add_llvm_utility name)
+macro(add_llvm_fuzzer name)
+ if( LLVM_USE_SANITIZE_COVERAGE )
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
+ add_llvm_executable(${name} ${ARGN})
+ set_target_properties(${name} PROPERTIES FOLDER "Fuzzers")
+ endif()
+endmacro()
macro(add_llvm_target target_name)
include_directories(BEFORE
Modified: llvm/trunk/tools/llvm-as-fuzzer/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-as-fuzzer/CMakeLists.txt?rev=312200&r1=312199&r2=312200&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-as-fuzzer/CMakeLists.txt (original)
+++ llvm/trunk/tools/llvm-as-fuzzer/CMakeLists.txt Wed Aug 30 17:36:33 2017
@@ -1,12 +1,7 @@
-if( LLVM_USE_SANITIZE_COVERAGE )
-
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
- set(LLVM_LINK_COMPONENTS
- AsmParser
- BitWriter
- Core
- Support
- )
- add_llvm_tool(llvm-as-fuzzer
- llvm-as-fuzzer.cpp)
-endif()
+set(LLVM_LINK_COMPONENTS
+ AsmParser
+ BitWriter
+ Core
+ Support
+)
+add_llvm_fuzzer(llvm-as-fuzzer llvm-as-fuzzer.cpp)
Modified: llvm/trunk/tools/llvm-dwarfdump/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/CMakeLists.txt?rev=312200&r1=312199&r2=312200&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/CMakeLists.txt (original)
+++ llvm/trunk/tools/llvm-dwarfdump/CMakeLists.txt Wed Aug 30 17:36:33 2017
@@ -11,6 +11,4 @@ add_llvm_tool(llvm-dwarfdump
llvm-dwarfdump.cpp
)
-if(LLVM_USE_SANITIZE_COVERAGE)
- add_subdirectory(fuzzer)
-endif()
+add_subdirectory(fuzzer)
Modified: llvm/trunk/tools/llvm-dwarfdump/fuzzer/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/fuzzer/CMakeLists.txt?rev=312200&r1=312199&r2=312200&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwarfdump/fuzzer/CMakeLists.txt (original)
+++ llvm/trunk/tools/llvm-dwarfdump/fuzzer/CMakeLists.txt Wed Aug 30 17:36:33 2017
@@ -4,9 +4,7 @@ set(LLVM_LINK_COMPONENTS
Support
)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
-
-add_llvm_executable(llvm-dwarfdump-fuzzer
+add_llvm_fuzzer(llvm-dwarfdump-fuzzer
EXCLUDE_FROM_ALL
llvm-dwarfdump-fuzzer.cpp
)
Modified: llvm/trunk/tools/llvm-isel-fuzzer/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-isel-fuzzer/CMakeLists.txt?rev=312200&r1=312199&r2=312200&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-isel-fuzzer/CMakeLists.txt (original)
+++ llvm/trunk/tools/llvm-isel-fuzzer/CMakeLists.txt Wed Aug 30 17:36:33 2017
@@ -1,20 +1,15 @@
-if( LLVM_USE_SANITIZE_COVERAGE )
-
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
- set(LLVM_LINK_COMPONENTS
- ${LLVM_TARGETS_TO_BUILD}
- Analysis
- AsmPrinter
- CodeGen
- Core
- FuzzMutate
- IRReader
- MC
- ScalarOpts
- SelectionDAG
- Support
- Target
- )
- add_llvm_tool(llvm-isel-fuzzer
- llvm-isel-fuzzer.cpp)
-endif()
+set(LLVM_LINK_COMPONENTS
+ ${LLVM_TARGETS_TO_BUILD}
+ Analysis
+ AsmPrinter
+ CodeGen
+ Core
+ FuzzMutate
+ IRReader
+ MC
+ ScalarOpts
+ SelectionDAG
+ Support
+ Target
+)
+add_llvm_fuzzer(llvm-isel-fuzzer llvm-isel-fuzzer.cpp)
Modified: llvm/trunk/tools/llvm-mc-assemble-fuzzer/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc-assemble-fuzzer/CMakeLists.txt?rev=312200&r1=312199&r2=312200&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc-assemble-fuzzer/CMakeLists.txt (original)
+++ llvm/trunk/tools/llvm-mc-assemble-fuzzer/CMakeLists.txt Wed Aug 30 17:36:33 2017
@@ -1,16 +1,10 @@
-if( LLVM_USE_SANITIZE_COVERAGE )
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
-
- set(LLVM_LINK_COMPONENTS
- AllTargetsAsmPrinters
- AllTargetsAsmParsers
- AllTargetsDescs
- AllTargetsInfos
- MC
- MCParser
- Support
- )
-
- add_llvm_tool(llvm-mc-assemble-fuzzer
- llvm-mc-assemble-fuzzer.cpp)
-endif()
+set(LLVM_LINK_COMPONENTS
+ AllTargetsAsmPrinters
+ AllTargetsAsmParsers
+ AllTargetsDescs
+ AllTargetsInfos
+ MC
+ MCParser
+ Support
+)
+add_llvm_fuzzer(llvm-mc-assemble-fuzzer llvm-mc-assemble-fuzzer.cpp)
Modified: llvm/trunk/tools/llvm-mc-disassemble-fuzzer/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc-disassemble-fuzzer/CMakeLists.txt?rev=312200&r1=312199&r2=312200&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc-disassemble-fuzzer/CMakeLists.txt (original)
+++ llvm/trunk/tools/llvm-mc-disassemble-fuzzer/CMakeLists.txt Wed Aug 30 17:36:33 2017
@@ -1,16 +1,11 @@
-if( LLVM_USE_SANITIZE_COVERAGE )
-
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
- set(LLVM_LINK_COMPONENTS
- AllTargetsAsmPrinters
- AllTargetsDescs
- AllTargetsDisassemblers
- AllTargetsInfos
- MC
- MCDisassembler
- MCParser
- Support
- )
- add_llvm_tool(llvm-mc-disassemble-fuzzer
- llvm-mc-disassemble-fuzzer.cpp)
-endif()
+set(LLVM_LINK_COMPONENTS
+ AllTargetsAsmPrinters
+ AllTargetsDescs
+ AllTargetsDisassemblers
+ AllTargetsInfos
+ MC
+ MCDisassembler
+ MCParser
+ Support
+)
+add_llvm_fuzzer(llvm-mc-disassemble-fuzzer llvm-mc-disassemble-fuzzer.cpp)
More information about the llvm-commits
mailing list