summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2017-12-11 19:53:23 +0000
committerJustin Bogner <mail@justinbogner.com>2017-12-11 19:53:23 +0000
commit9b89282304887fe84d17dd9cb693774e50c9027b (patch)
tree4064b041b1e3616072b216ecc11787a781c93f29 /cmake
parent1559083a44c32e2d1a70ef9bc5a4942414b4469a (diff)
[cmake] Pass TARGETS_TO_BUILD through to host tools build
In r319620, the host build was changed to use Native for TARGETS_TO_BUILD because passing semicolons through add_custom_command is surprisingly difficult. However, Native really doesn't make any sense here, and it only works because we don't technically do any codegen in the host tools so pretty well anything will "work". The problem here is that passing something other than the correct value is very fragile - as evidence note how the llvm-config in the host tools acts differently than the target one now, and misreports the targets to build. Similarly, if there is any logic conditional on the targets in tablegen (now or in the future), it will do the wrong thing. To fix this, we need to escape the semicolons in the targets string and pass it through to the child cmake invocation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320413 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/CrossCompile.cmake7
1 files changed, 6 insertions, 1 deletions
diff --git a/cmake/modules/CrossCompile.cmake b/cmake/modules/CrossCompile.cmake
index 3f3a9a87b9c..117eda77878 100644
--- a/cmake/modules/CrossCompile.cmake
+++ b/cmake/modules/CrossCompile.cmake
@@ -36,11 +36,16 @@ function(llvm_create_cross_target_internal target_name toolchain buildtype)
add_custom_target(CREATE_LLVM_${target_name}
DEPENDS ${LLVM_${target_name}_BUILD})
+ # Escape semicolons in the targets list so that cmake doesn't expand
+ # them to spaces.
+ string(REPLACE ";" "$<SEMICOLON>" targets_to_build_arg
+ "${LLVM_TARGETS_TO_BUILD}")
+
add_custom_command(OUTPUT ${LLVM_${target_name}_BUILD}/CMakeCache.txt
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_SOURCE_DIR}
-DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
- -DLLVM_TARGETS_TO_BUILD=Native
+ -DLLVM_TARGETS_TO_BUILD="${targets_to_build_arg}"
${build_type_flags} ${linker_flag} ${external_clang_dir}
WORKING_DIRECTORY ${LLVM_${target_name}_BUILD}
DEPENDS CREATE_LLVM_${target_name}