aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-08-21 19:13:44 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-08-21 19:13:44 +0000
commitd6dbd6b88341f1f7492b8c170077cbbb2014f1e0 (patch)
treeadc548448d249a7dd8420ad9e6138e4d801dc468 /cmake
parent795cfe3cfd48f7fc3794da8ce4fe0811bf1e298d (diff)
downloadexternal_llvm-d6dbd6b88341f1f7492b8c170077cbbb2014f1e0.zip
external_llvm-d6dbd6b88341f1f7492b8c170077cbbb2014f1e0.tar.gz
external_llvm-d6dbd6b88341f1f7492b8c170077cbbb2014f1e0.tar.bz2
[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". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188921 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/AddLLVM.cmake29
1 files changed, 29 insertions, 0 deletions
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake
index 24afeea..277914f 100644
--- a/cmake/modules/AddLLVM.cmake
+++ b/cmake/modules/AddLLVM.cmake
@@ -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})