summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorChris Bieneman <beanz@apple.com>2016-06-23 22:07:21 +0000
committerChris Bieneman <beanz@apple.com>2016-06-23 22:07:21 +0000
commitf444c52628dbb4a852fb4e1f2ca0a7216d90dce7 (patch)
treeb5f5a8723a7718412d626a41c6b5c9321b2d300e /cmake
parent55eeb454114ffd5478e31ac5312f514ab4db8493 (diff)
[CMake] Add LLVM runtimes directory
Summary: There are a few LLVM projects that produce runtime libraries. Ideally runtime libraries should be built differently than other projects, specifically they should be built using the just-built toolchain. There is support for building compiler-rt in this way from the clang build. Moving this logic into the LLVM build is interesting because it provides a simpler way to extend the just-built toolchain to include LLD and the LLVM object file tools. Once this functionality is better fleshed out and tested we’ll want to encapsulate it in a module that can be used for clang standalone builds, and we’ll want to make it the default way to build compiler-rt. With this patch applied there is no immediate change in the build. Moving compiler-rt out from llvm/projects into llvm/runtimes enables the functionality. This code has a few improvements over the method provided by LLVM_BUILD_EXTERNAL_COMPILER_RT. Specifically the sub-ninja command is always invoked, so changes to compiler-rt source files will get built properly, so this patch can be used for iterative development with just-built tools. This first patch only works with compiler-rt. Support for other runtime projects will be coming in follow-up patches. Reviewers: chandlerc, bogner Subscribers: kubabrecka, llvm-commits Differential Revision: http://reviews.llvm.org/D20992 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273620 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/LLVMExternalProjectUtils.cmake40
1 files changed, 30 insertions, 10 deletions
diff --git a/cmake/modules/LLVMExternalProjectUtils.cmake b/cmake/modules/LLVMExternalProjectUtils.cmake
index 40364aa8707..3e7355d4d6b 100644
--- a/cmake/modules/LLVMExternalProjectUtils.cmake
+++ b/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -19,6 +19,8 @@ endfunction()
# Exclude this project from the all target
# NO_INSTALL
# Don't generate install targets for this project
+# ALWAYS_CLEAN
+# Always clean the sub-project before building
# CMAKE_ARGS arguments...
# Optional cmake arguments to pass when configuring the project
# TOOLCHAIN_TOOLS targets...
@@ -27,11 +29,15 @@ endfunction()
# Targets that this project depends on
# EXTRA_TARGETS targets...
# Extra targets in the subproject to generate targets for
+# PASSTHROUGH_PREFIXES prefix...
+# Extra variable prefixes (name is always included) to pass down
# )
function(llvm_ExternalProject_Add name source_dir)
- cmake_parse_arguments(ARG "USE_TOOLCHAIN;EXCLUDE_FROM_ALL;NO_INSTALL"
+ cmake_parse_arguments(ARG
+ "USE_TOOLCHAIN;EXCLUDE_FROM_ALL;NO_INSTALL;ALWAYS_CLEAN"
"SOURCE_DIR"
- "CMAKE_ARGS;TOOLCHAIN_TOOLS;RUNTIME_LIBRARIES;DEPENDS;EXTRA_TARGETS" ${ARGN})
+ "CMAKE_ARGS;TOOLCHAIN_TOOLS;RUNTIME_LIBRARIES;DEPENDS;EXTRA_TARGETS;PASSTHROUGH_PREFIXES"
+ ${ARGN})
canonicalize_tool_name(${name} nameCanon)
if(NOT ARG_TOOLCHAIN_TOOLS)
set(ARG_TOOLCHAIN_TOOLS clang lld)
@@ -52,6 +58,10 @@ function(llvm_ExternalProject_Add name source_dir)
endif()
endforeach()
+ if(ARG_ALWAYS_CLEAN)
+ set(always_clean clean)
+ endif()
+
list(FIND TOOLCHAIN_TOOLS clang FOUND_CLANG)
if(FOUND_CLANG GREATER -1)
set(CLANG_IN_TOOLCHAIN On)
@@ -71,15 +81,18 @@ function(llvm_ExternalProject_Add name source_dir)
USES_TERMINAL
)
- # Find all variables that start with COMPILER_RT and populate a variable with
- # them.
+ # Find all variables that start with a prefix and propagate them through
get_cmake_property(variableNames VARIABLES)
- foreach(variableName ${variableNames})
- if(variableName MATCHES "^${nameCanon}")
- string(REPLACE ";" "\;" value "${${variableName}}")
- list(APPEND PASSTHROUGH_VARIABLES
- -D${variableName}=${value})
- endif()
+
+ list(APPEND ARG_PASSTHROUGH_PREFIXES ${nameCanon})
+ foreach(prefix ${ARG_PASSTHROUGH_PREFIXES})
+ foreach(variableName ${variableNames})
+ if(variableName MATCHES "^${prefix}")
+ string(REPLACE ";" "\;" value "${${variableName}}")
+ list(APPEND PASSTHROUGH_VARIABLES
+ -D${variableName}=${value})
+ endif()
+ endforeach()
endforeach()
if(ARG_USE_TOOLCHAIN)
@@ -117,6 +130,12 @@ function(llvm_ExternalProject_Add name source_dir)
CMAKE_ARGS ${${nameCanon}_CMAKE_ARGS}
${compiler_args}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
+ -DLLVM_BINARY_DIR=${PROJECT_BINARY_DIR}
+ -DLLVM_CONFIG_PATH=$<TARGET_FILE:llvm-config>
+ -DLLVM_ENABLE_WERROR=${LLVM_ENABLE_WERROR}
+ -DPACKAGE_VERSION=${PACKAGE_VERSION}
+ -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
+ -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
${ARG_CMAKE_ARGS}
${PASSTHROUGH_VARIABLES}
INSTALL_COMMAND ""
@@ -138,6 +157,7 @@ function(llvm_ExternalProject_Add name source_dir)
DEPENDEES configure
${force_deps}
WORKING_DIRECTORY ${BINARY_DIR}
+ EXCLUDE_FROM_MAIN 1
USES_TERMINAL 1
)
ExternalProject_Add_StepTargets(${name} clean)