forked from OSchip/llvm-project
[CMake] Automatically pick up subdirectories in llvm/tools as 'external projects' if they contain a 'CMakeLists.txt' file.
Allow CMake to pick up external projects in llvm/tools without the need to modify the "llvm/tools/CMakeLists.txt" file. This makes it easier to work with projects that live in other repositories, without needing to specify each one in "llvm/tools/CMakeLists.txt". llvm-svn: 188921
This commit is contained in:
parent
1e43d9521f
commit
7eec9d0c04
|
@ -146,6 +146,7 @@ macro(add_llvm_external_project name)
|
|||
if("${add_llvm_external_dir}" STREQUAL "")
|
||||
set(add_llvm_external_dir ${name})
|
||||
endif()
|
||||
list(APPEND LLVM_IMPLICIT_PROJECT_IGNORE "${CMAKE_CURRENT_SOURCE_DIR}/${add_llvm_external_dir}")
|
||||
string(REPLACE "-" "_" nameUNDERSCORE ${name})
|
||||
string(TOUPPER ${nameUNDERSCORE} nameUPPER)
|
||||
set(LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${add_llvm_external_dir}"
|
||||
|
@ -160,6 +161,34 @@ macro(add_llvm_external_project name)
|
|||
endif()
|
||||
endmacro(add_llvm_external_project)
|
||||
|
||||
macro(add_llvm_tool_subdirectory name)
|
||||
list(APPEND LLVM_IMPLICIT_PROJECT_IGNORE "${CMAKE_CURRENT_SOURCE_DIR}/${name}")
|
||||
add_subdirectory(${name})
|
||||
endmacro(add_llvm_tool_subdirectory)
|
||||
|
||||
macro(ignore_llvm_tool_subdirectory name)
|
||||
list(APPEND LLVM_IMPLICIT_PROJECT_IGNORE "${CMAKE_CURRENT_SOURCE_DIR}/${name}")
|
||||
endmacro(ignore_llvm_tool_subdirectory)
|
||||
|
||||
function(add_llvm_implicit_external_projects)
|
||||
set(list_of_implicit_subdirs "")
|
||||
file(GLOB sub-dirs "${CMAKE_CURRENT_SOURCE_DIR}/*")
|
||||
foreach(dir ${sub-dirs})
|
||||
if(IS_DIRECTORY "${dir}")
|
||||
list(FIND LLVM_IMPLICIT_PROJECT_IGNORE "${dir}" tool_subdir_ignore)
|
||||
if( tool_subdir_ignore EQUAL -1
|
||||
AND EXISTS "${dir}/CMakeLists.txt")
|
||||
get_filename_component(fn "${dir}" NAME)
|
||||
list(APPEND list_of_implicit_subdirs "${fn}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(external_proj ${list_of_implicit_subdirs})
|
||||
add_llvm_external_project("${external_proj}")
|
||||
endforeach()
|
||||
endfunction(add_llvm_implicit_external_projects)
|
||||
|
||||
# Generic support for adding a unittest.
|
||||
function(add_unittest test_suite test_name)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
|
|
@ -5,64 +5,74 @@
|
|||
if( NOT WIN32 OR MSYS OR CYGWIN )
|
||||
# We currently require 'sed' to build llvm-config, so don't try to build it
|
||||
# on pure Win32.
|
||||
add_subdirectory(llvm-config)
|
||||
add_llvm_tool_subdirectory(llvm-config)
|
||||
else()
|
||||
ignore_llvm_tool_subdirectory(llvm-config)
|
||||
endif()
|
||||
|
||||
add_subdirectory(opt)
|
||||
add_subdirectory(llvm-as)
|
||||
add_subdirectory(llvm-dis)
|
||||
add_subdirectory(llvm-mc)
|
||||
add_llvm_tool_subdirectory(opt)
|
||||
add_llvm_tool_subdirectory(llvm-as)
|
||||
add_llvm_tool_subdirectory(llvm-dis)
|
||||
add_llvm_tool_subdirectory(llvm-mc)
|
||||
|
||||
add_subdirectory(llc)
|
||||
add_subdirectory(llvm-ar)
|
||||
add_subdirectory(llvm-nm)
|
||||
add_subdirectory(llvm-size)
|
||||
add_llvm_tool_subdirectory(llc)
|
||||
add_llvm_tool_subdirectory(llvm-ar)
|
||||
add_llvm_tool_subdirectory(llvm-nm)
|
||||
add_llvm_tool_subdirectory(llvm-size)
|
||||
|
||||
add_subdirectory(llvm-cov)
|
||||
add_subdirectory(llvm-prof)
|
||||
add_subdirectory(llvm-link)
|
||||
add_subdirectory(lli)
|
||||
add_llvm_tool_subdirectory(llvm-cov)
|
||||
add_llvm_tool_subdirectory(llvm-prof)
|
||||
add_llvm_tool_subdirectory(llvm-link)
|
||||
add_llvm_tool_subdirectory(lli)
|
||||
|
||||
add_subdirectory(llvm-extract)
|
||||
add_subdirectory(llvm-diff)
|
||||
add_subdirectory(macho-dump)
|
||||
add_subdirectory(llvm-objdump)
|
||||
add_subdirectory(llvm-readobj)
|
||||
add_subdirectory(llvm-rtdyld)
|
||||
add_subdirectory(llvm-dwarfdump)
|
||||
add_llvm_tool_subdirectory(llvm-extract)
|
||||
add_llvm_tool_subdirectory(llvm-diff)
|
||||
add_llvm_tool_subdirectory(macho-dump)
|
||||
add_llvm_tool_subdirectory(llvm-objdump)
|
||||
add_llvm_tool_subdirectory(llvm-readobj)
|
||||
add_llvm_tool_subdirectory(llvm-rtdyld)
|
||||
add_llvm_tool_subdirectory(llvm-dwarfdump)
|
||||
if( LLVM_USE_INTEL_JITEVENTS )
|
||||
add_subdirectory(llvm-jitlistener)
|
||||
add_llvm_tool_subdirectory(llvm-jitlistener)
|
||||
else()
|
||||
ignore_llvm_tool_subdirectory(llvm-jitlistener)
|
||||
endif( LLVM_USE_INTEL_JITEVENTS )
|
||||
|
||||
add_subdirectory(bugpoint)
|
||||
add_subdirectory(bugpoint-passes)
|
||||
add_subdirectory(llvm-bcanalyzer)
|
||||
add_subdirectory(llvm-stress)
|
||||
add_subdirectory(llvm-mcmarkup)
|
||||
add_llvm_tool_subdirectory(bugpoint)
|
||||
add_llvm_tool_subdirectory(bugpoint-passes)
|
||||
add_llvm_tool_subdirectory(llvm-bcanalyzer)
|
||||
add_llvm_tool_subdirectory(llvm-stress)
|
||||
add_llvm_tool_subdirectory(llvm-mcmarkup)
|
||||
|
||||
add_subdirectory(llvm-symbolizer)
|
||||
add_llvm_tool_subdirectory(llvm-symbolizer)
|
||||
|
||||
add_subdirectory(obj2yaml)
|
||||
add_subdirectory(yaml2obj)
|
||||
add_llvm_tool_subdirectory(obj2yaml)
|
||||
add_llvm_tool_subdirectory(yaml2obj)
|
||||
|
||||
if( NOT WIN32 )
|
||||
add_subdirectory(lto)
|
||||
add_llvm_tool_subdirectory(lto)
|
||||
else()
|
||||
ignore_llvm_tool_subdirectory(lto)
|
||||
endif()
|
||||
|
||||
if( LLVM_ENABLE_PIC )
|
||||
# TODO: support other systems:
|
||||
if( (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
OR (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") )
|
||||
add_subdirectory(gold)
|
||||
add_llvm_tool_subdirectory(gold)
|
||||
else()
|
||||
ignore_llvm_tool_subdirectory(gold)
|
||||
endif()
|
||||
else()
|
||||
ignore_llvm_tool_subdirectory(gold)
|
||||
endif()
|
||||
|
||||
add_llvm_external_project(clang)
|
||||
|
||||
if( NOT LLVM_INCLUDE_TOOLS STREQUAL "bootstrap-only" )
|
||||
add_llvm_external_project(lld)
|
||||
add_llvm_external_project(lldb)
|
||||
add_llvm_external_project(polly)
|
||||
# Automatically add remaining sub-directories containing a 'CMakeLists.txt'
|
||||
# file as external projects.
|
||||
add_llvm_implicit_external_projects()
|
||||
endif()
|
||||
|
||||
set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} PARENT_SCOPE)
|
||||
|
|
Loading…
Reference in New Issue