From d6dbd6b88341f1f7492b8c170077cbbb2014f1e0 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Wed, 21 Aug 2013 19:13:44 +0000 Subject: [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 --- cmake/modules/AddLLVM.cmake | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'cmake') 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}) -- cgit v1.1