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
This commit is contained in:
Oscar Fuentes 2009-11-23 00:21:43 +00:00
parent ead2dacc9e
commit b8352de551
3 changed files with 26 additions and 13 deletions

View File

@ -319,14 +319,10 @@ add_subdirectory(lib/Archive)
add_subdirectory(projects) add_subdirectory(projects)
option(LLVM_BUILD_TOOLS "Build LLVM tool programs." ON) option(LLVM_BUILD_TOOLS "Build LLVM tool programs." ON)
if(LLVM_BUILD_TOOLS) add_subdirectory(tools)
add_subdirectory(tools)
endif()
option(LLVM_BUILD_EXAMPLES "Build LLVM example programs." OFF) option(LLVM_BUILD_EXAMPLES "Build LLVM example programs." OFF)
if(LLVM_BUILD_EXAMPLES) add_subdirectory(examples)
add_subdirectory(examples)
endif ()
install(DIRECTORY include/ install(DIRECTORY include/
DESTINATION include DESTINATION include

View File

@ -46,7 +46,12 @@ endmacro(add_llvm_loadable_module name)
macro(add_llvm_executable name) macro(add_llvm_executable name)
llvm_process_sources( ALL_FILES ${ARGN} ) 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 ) if( LLVM_USED_LIBS )
foreach(lib ${LLVM_USED_LIBS}) foreach(lib ${LLVM_USED_LIBS})
target_link_libraries( ${name} ${lib} ) target_link_libraries( ${name} ${lib} )
@ -67,17 +72,23 @@ endmacro(add_llvm_executable name)
macro(add_llvm_tool name) macro(add_llvm_tool name)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR}) 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}) add_llvm_executable(${name} ${ARGN})
install(TARGETS ${name}
RUNTIME DESTINATION bin)
endmacro(add_llvm_tool name) endmacro(add_llvm_tool name)
macro(add_llvm_example name) macro(add_llvm_example name)
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_EXAMPLES_BINARY_DIR}) # 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}) add_llvm_executable(${name} ${ARGN})
install(TARGETS ${name}
RUNTIME DESTINATION examples)
endmacro(add_llvm_example name) endmacro(add_llvm_example name)

View File

@ -251,10 +251,16 @@
<i>-DLLVM_TARGETS_TO_BUILD="X86;PowerPC;Alpha"</i>.</dd> <i>-DLLVM_TARGETS_TO_BUILD="X86;PowerPC;Alpha"</i>.</dd>
<dt><b>LLVM_BUILD_TOOLS</b>:BOOL</dt> <dt><b>LLVM_BUILD_TOOLS</b>:BOOL</dt>
<dd>Build LLVM tools. Defaults to ON.</dd> <dd>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 <i>llvm-as</i>
with a makefile-based system executing <i>make llvm-as</i> on the
root of your build directory.</dd>
<dt><b>LLVM_BUILD_EXAMPLES</b>:BOOL</dt> <dt><b>LLVM_BUILD_EXAMPLES</b>:BOOL</dt>
<dd>Build LLVM examples. Defaults to OFF.</dd> <dd>Build LLVM examples. Defaults to OFF. Targets for building each
example are generated in any case. See documentation
for <i>LLVM_BUILD_TOOLS</i> above for more details.</dd>
<dt><b>LLVM_ENABLE_THREADS</b>:BOOL</dt> <dt><b>LLVM_ENABLE_THREADS</b>:BOOL</dt>
<dd>Build with threads support, if available. Defaults to ON.</dd> <dd>Build with threads support, if available. Defaults to ON.</dd>