From b8352de5514276e7e66998744e5d9eb477076d29 Mon Sep 17 00:00:00 2001 From: Oscar Fuentes Date: Mon, 23 Nov 2009 00:21:43 +0000 Subject: [PATCH] CMake: generate targets for tools and examples even when LLVM_BUILD_TOOLS or LLVM_BUILD_EXAMPLES are OFF. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89635 91177308-0d34-0410-b5e6-96231b3b80d8 --- CMakeLists.txt | 8 ++------ cmake/modules/AddLLVM.cmake | 21 ++++++++++++++++----- docs/CMake.html | 10 ++++++++-- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00214782ca2..a7a595a8eb2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -319,14 +319,10 @@ add_subdirectory(lib/Archive) add_subdirectory(projects) option(LLVM_BUILD_TOOLS "Build LLVM tool programs." ON) -if(LLVM_BUILD_TOOLS) - add_subdirectory(tools) -endif() +add_subdirectory(tools) option(LLVM_BUILD_EXAMPLES "Build LLVM example programs." OFF) -if(LLVM_BUILD_EXAMPLES) - add_subdirectory(examples) -endif () +add_subdirectory(examples) install(DIRECTORY include/ DESTINATION include diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake index c0ce897f4f1..27ed9565117 100755 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake @@ -46,7 +46,12 @@ endmacro(add_llvm_loadable_module name) macro(add_llvm_executable name) llvm_process_sources( ALL_FILES ${ARGN} ) - add_executable(${name} ${ALL_FILES}) + if( EXCLUDE_FROM_ALL ) + add_executable(${name} EXCLUDE_FROM_ALL ${ALL_FILES}) + else() + add_executable(${name} ${ALL_FILES}) + endif() + set(EXCLUDE_FROM_ALL OFF) if( LLVM_USED_LIBS ) foreach(lib ${LLVM_USED_LIBS}) target_link_libraries( ${name} ${lib} ) @@ -67,17 +72,23 @@ endmacro(add_llvm_executable name) macro(add_llvm_tool name) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR}) + if( LLVM_BUILD_TOOLS ) + install(TARGETS ${name} RUNTIME DESTINATION bin) + else() + set(EXCLUDE_FROM_ALL ON) + endif() add_llvm_executable(${name} ${ARGN}) - install(TARGETS ${name} - RUNTIME DESTINATION bin) endmacro(add_llvm_tool name) macro(add_llvm_example name) # set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_EXAMPLES_BINARY_DIR}) + if( LLVM_BUILD_EXAMPLES ) + install(TARGETS ${name} RUNTIME DESTINATION examples) + else() + set(EXCLUDE_FROM_ALL ON) + endif() add_llvm_executable(${name} ${ARGN}) - install(TARGETS ${name} - RUNTIME DESTINATION examples) endmacro(add_llvm_example name) diff --git a/docs/CMake.html b/docs/CMake.html index 190d102c832..2b7fda34477 100644 --- a/docs/CMake.html +++ b/docs/CMake.html @@ -251,10 +251,16 @@ -DLLVM_TARGETS_TO_BUILD="X86;PowerPC;Alpha".
LLVM_BUILD_TOOLS:BOOL
-
Build LLVM tools. Defaults to ON.
+
Build LLVM tools. Defaults to ON. Targets for building each tool + are generated in any case. You can build an tool separately by + invoking its target. For example, you can build llvm-as + with a makefile-based system executing make llvm-as on the + root of your build directory.
LLVM_BUILD_EXAMPLES:BOOL
-
Build LLVM examples. Defaults to OFF.
+
Build LLVM examples. Defaults to OFF. Targets for building each + example are generated in any case. See documentation + for LLVM_BUILD_TOOLS above for more details.
LLVM_ENABLE_THREADS:BOOL
Build with threads support, if available. Defaults to ON.