summaryrefslogtreecommitdiffstats
path: root/llvm/cmake/modules/AddLLVM.cmake
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2015-08-11 17:16:35 +0000
committerReid Kleckner <rnk@google.com>2015-08-11 17:16:35 +0000
commitde98228fab8547e09cfec4e5f3ce2868997fa7e0 (patch)
treed637fa04e4059a2fba5e8db737934ab00d4b7d7f /llvm/cmake/modules/AddLLVM.cmake
parentae1b23bd6160abbde8ea11ba3548a3bc9e9f7953 (diff)
downloadbcm5719-llvm-de98228fab8547e09cfec4e5f3ce2868997fa7e0.tar.gz
bcm5719-llvm-de98228fab8547e09cfec4e5f3ce2868997fa7e0.zip
[cmake] Add helper for finding potentially external projects
I plan to use this from compiler-rt, but it's useful for any LLVM project that depends on more than just LLVM. llvm-svn: 244633
Diffstat (limited to 'llvm/cmake/modules/AddLLVM.cmake')
-rw-r--r--llvm/cmake/modules/AddLLVM.cmake17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index f87e18bfcff..f4cb93ded59 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -717,6 +717,23 @@ macro(add_llvm_tool_subdirectory name)
add_llvm_external_project(${name})
endmacro(add_llvm_tool_subdirectory)
+# Finds a (potentially external) project that normally lives at
+# llvm/${subdir}/${name}. For example, to find clang:
+# find_llvm_external_project(tools clang CLANG_SRC)
+# Returns nothing if the project is not configured to build.
+function(find_llvm_external_project subdir name path_out)
+ canonicalize_tool_name(${name} nameUPPER)
+ if (NOT LLVM_TOOL_${nameUPPER}_BUILD)
+ set(${path_out} PARENT_SCOPE)
+ elseif (EXISTS LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR)
+ set(${path_out} LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR PARENT_SCOPE)
+ elseif (EXISTS ${LLVM_MAIN_SRC_DIR}/${subdir}/${name})
+ set(${path_out} ${LLVM_MAIN_SRC_DIR}/${subdir}/${name} PARENT_SCOPE)
+ else()
+ set(${path_out} PARENT_SCOPE)
+ endif()
+endfunction(find_llvm_external_project)
+
function(get_project_name_from_src_var var output)
string(REGEX MATCH "LLVM_EXTERNAL_(.*)_SOURCE_DIR"
MACHED_TOOL "${var}")
OpenPOWER on IntegriCloud