From a987f5c9eaa328be5d316dd046f10a1f3db85dc8 Mon Sep 17 00:00:00 2001 From: Marcos Pividori Date: Wed, 8 Feb 2017 00:03:26 +0000 Subject: [PATCH] [libFuzzer] Use custom target instead of list of binaries for tests. Update cmake to use a custom target TestBinaries instead of a list of targets. This simplifies cmake, and fix some errors. This way, we don't have to propagate the values into parents directories. We only need to use add_dependencies. Differential Revision: https://reviews.llvm.org/D29593 llvm-svn: 294389 --- lib/Fuzzer/test/CMakeLists.txt | 15 +++++++-------- lib/Fuzzer/test/no-coverage/CMakeLists.txt | 3 +-- lib/Fuzzer/test/ubsan/CMakeLists.txt | 3 --- lib/Fuzzer/test/uninstrumented/CMakeLists.txt | 3 --- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/lib/Fuzzer/test/CMakeLists.txt b/lib/Fuzzer/test/CMakeLists.txt index 7fa75a8abc5..cf9c99a36ca 100644 --- a/lib/Fuzzer/test/CMakeLists.txt +++ b/lib/Fuzzer/test/CMakeLists.txt @@ -39,6 +39,8 @@ if(MSVC) set(CMAKE_CXX_CREATE_SHARED_LIBRARY " ${CMAKE_CXX_FLAGS} ${CRT_FLAG} /LD -o /link ") endif() +add_custom_target(TestBinaries) + # add_libfuzzer_test( # SOURCES source0.cpp [source1.cpp ...] # ) @@ -63,12 +65,9 @@ function(add_libfuzzer_test name) PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/Fuzzer/test" ) - set(TestBinaries ${TestBinaries} LLVMFuzzer-${name} PARENT_SCOPE) + add_dependencies(TestBinaries LLVMFuzzer-${name}) endfunction() -# Variable to keep track of all test targets -set(TestBinaries) - ############################################################################### # Basic tests ############################################################################### @@ -166,13 +165,13 @@ target_include_directories(LLVMFuzzer-Unittest PRIVATE "${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include" ) -set(TestBinaries ${TestBinaries} LLVMFuzzer-Unittest) +add_dependencies(TestBinaries LLVMFuzzer-Unittest) set_target_properties(LLVMFuzzer-Unittest PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" ) -set(TestBinaries ${TestBinaries} LLVMFuzzer-StandaloneInitializeTest) +add_dependencies(TestBinaries LLVMFuzzer-StandaloneInitializeTest) set_target_properties(LLVMFuzzer-StandaloneInitializeTest PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" @@ -218,7 +217,7 @@ else(MSVC) LIBRARY_DIR "${CMAKE_BINARY_DIR}/lib/Fuzzer/lib") endif() -set(TestBinaries ${TestBinaries} LLVMFuzzer-DSOTest) +add_dependencies(TestBinaries LLVMFuzzer-DSOTest) ############################################################################### # Configure lit to run the tests @@ -243,7 +242,7 @@ configure_lit_site_cfg( add_lit_testsuite(check-fuzzer "Running Fuzzer tests" ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS ${TestBinaries} + DEPENDS TestBinaries ) # Don't add dependencies on Windows. The linker step would fail on Windows, diff --git a/lib/Fuzzer/test/no-coverage/CMakeLists.txt b/lib/Fuzzer/test/no-coverage/CMakeLists.txt index 6aa7db183e2..52e7240333e 100644 --- a/lib/Fuzzer/test/no-coverage/CMakeLists.txt +++ b/lib/Fuzzer/test/no-coverage/CMakeLists.txt @@ -25,6 +25,5 @@ if(NOT MSVC) "${CMAKE_BINARY_DIR}/lib/Fuzzer/test" ) - # Propagate value into parent directory - set(TestBinaries ${TestBinaries} AFLDriverTest PARENT_SCOPE) + add_dependencies(TestBinaries AFLDriverTest) endif() diff --git a/lib/Fuzzer/test/ubsan/CMakeLists.txt b/lib/Fuzzer/test/ubsan/CMakeLists.txt index 7a9eacdbe7d..55e0a118186 100644 --- a/lib/Fuzzer/test/ubsan/CMakeLists.txt +++ b/lib/Fuzzer/test/ubsan/CMakeLists.txt @@ -10,6 +10,3 @@ set(UbsanTests foreach(Test ${UbsanTests}) add_libfuzzer_test(${Test}-Ubsan SOURCES ../${Test}.cpp) endforeach() - -# Propagate value into parent directory -set(TestBinaries ${TestBinaries} PARENT_SCOPE) diff --git a/lib/Fuzzer/test/uninstrumented/CMakeLists.txt b/lib/Fuzzer/test/uninstrumented/CMakeLists.txt index 29b66e6e586..f4ab59e5b18 100644 --- a/lib/Fuzzer/test/uninstrumented/CMakeLists.txt +++ b/lib/Fuzzer/test/uninstrumented/CMakeLists.txt @@ -11,6 +11,3 @@ set(UninstrumentedTests foreach(Test ${UninstrumentedTests}) add_libfuzzer_test(${Test}-Uninstrumented SOURCES ../${Test}.cpp) endforeach() - -# Propagate value into parent directory -set(TestBinaries ${TestBinaries} PARENT_SCOPE)