From 4b794c9a9990fdea831966c7ebd3be46efe261a1 Mon Sep 17 00:00:00 2001 From: "Michael J. Spencer" Date: Fri, 24 Sep 2010 19:10:51 +0000 Subject: [PATCH] CMake: Don't include tools, unittets, or examples as available targets unless LLVM_INCLUDE_X is ON. LLVM_BUILD_X implies LLVM_INCLUDE_X git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114747 91177308-0d34-0410-b5e6-96231b3b80d8 --- CMakeLists.txt | 6 ++++++ cmake/modules/AddLLVM.cmake | 8 ++++++-- unittests/CMakeLists.txt | 4 +++- utils/unittest/CMakeLists.txt | 24 +++++++++++++----------- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7959f65647b..8b2b2dc36a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -364,12 +364,18 @@ add_subdirectory(lib/Archive) add_subdirectory(projects) option(LLVM_BUILD_TOOLS "Build LLVM tool programs." ON) +option(LLVM_INCLUDE_TOOLS + "Include LLVM tool programs as an available target." ON) add_subdirectory(tools) option(LLVM_BUILD_EXAMPLES "Build LLVM example programs." OFF) +option(LLVM_INCLUDE_EXAMPLES + "Include LLVM example programs as an available target." OFF) add_subdirectory(examples) option(LLVM_BUILD_TESTS "Build LLVM unit tests." OFF) +option(LLVM_INCLUDE_TESTS + "Include LLVM unit tests as an available target." OFF) add_subdirectory(test) add_subdirectory(utils/unittest) add_subdirectory(unittests) diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake index 22a456e460c..699754f6a2b 100755 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake @@ -77,7 +77,9 @@ macro(add_llvm_tool name) if( NOT LLVM_BUILD_TOOLS ) set(EXCLUDE_FROM_ALL ON) endif() - add_llvm_executable(${name} ${ARGN}) + if( LLVM_INCLUDE_TOOLS OR LLVM_BUILD_TOOLS ) + add_llvm_executable(${name} ${ARGN}) + endif() if( LLVM_BUILD_TOOLS ) install(TARGETS ${name} RUNTIME DESTINATION bin) endif() @@ -89,7 +91,9 @@ macro(add_llvm_example name) if( NOT LLVM_BUILD_EXAMPLES ) set(EXCLUDE_FROM_ALL ON) endif() - add_llvm_executable(${name} ${ARGN}) + if( LLVM_INCLUDE_EXAMPLES OR LLVM_BUILD_EXAMPLES ) + add_llvm_executable(${name} ${ARGN}) + endif() if( LLVM_BUILD_EXAMPLES ) install(TARGETS ${name} RUNTIME DESTINATION examples) endif() diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index 595ec21454e..ab4d53c90bb 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -9,7 +9,9 @@ function(add_llvm_unittest test_name) if( NOT LLVM_BUILD_TESTS ) set(EXCLUDE_FROM_ALL ON) endif() - add_llvm_executable(${test_name}Tests ${ARGN}) + if (LLVM_INCLUDE_TESTS OR LLVM_BUILD_TESTS) + add_llvm_executable(${test_name}Tests ${ARGN}) + endif() endfunction() include_directories(${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include) diff --git a/utils/unittest/CMakeLists.txt b/utils/unittest/CMakeLists.txt index 70685463014..99741c8f056 100644 --- a/utils/unittest/CMakeLists.txt +++ b/utils/unittest/CMakeLists.txt @@ -20,15 +20,17 @@ if(WIN32) add_definitions(-DGTEST_OS_WINDOWS=1) endif() -add_llvm_library(gtest - googletest/gtest.cc - googletest/gtest-death-test.cc - googletest/gtest-filepath.cc - googletest/gtest-port.cc - googletest/gtest-test-part.cc - googletest/gtest-typed-test.cc - ) +if (LLVM_INCLUDE_TESTS OR LLVM_BUILD_TESTS) + add_llvm_library(gtest + googletest/gtest.cc + googletest/gtest-death-test.cc + googletest/gtest-filepath.cc + googletest/gtest-port.cc + googletest/gtest-test-part.cc + googletest/gtest-typed-test.cc + ) -add_llvm_library(gtest_main - UnitTestMain/TestMain.cpp - ) + add_llvm_library(gtest_main + UnitTestMain/TestMain.cpp + ) +endif()