summaryrefslogtreecommitdiff
path: root/cmake/Modules
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2018-06-13 05:32:22 +0000
committerPetr Hosek <phosek@chromium.org>2018-06-13 05:32:22 +0000
commit5182c97e8f15d72eaac6b4b4ad93729130343011 (patch)
tree50f7831ed458fd8d219c24b26a966ec2d8d7cba6 /cmake/Modules
parentae4112bcf197aaf39d26a79f9fd65da32c95e553 (diff)
Reland "Passthrough additional flags to custom libcxx CMake build"
This is needed when we're cross-compiling compiler-rt. Differential Revision: https://reviews.llvm.org/D47834 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@334570 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake/Modules')
-rw-r--r--cmake/Modules/AddCompilerRT.cmake35
1 files changed, 24 insertions, 11 deletions
diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake
index 2383670a9..95432e298 100644
--- a/cmake/Modules/AddCompilerRT.cmake
+++ b/cmake/Modules/AddCompilerRT.cmake
@@ -474,11 +474,6 @@ macro(add_custom_libcxx name prefix)
endif()
cmake_parse_arguments(LIBCXX "USE_TOOLCHAIN" "" "DEPS;CFLAGS;CMAKE_ARGS" ${ARGN})
- foreach(flag ${LIBCXX_CFLAGS})
- set(flagstr "${flagstr} ${flag}")
- endforeach()
- set(LIBCXX_C_FLAGS ${flagstr})
- set(LIBCXX_CXX_FLAGS ${flagstr})
if(LIBCXX_USE_TOOLCHAIN)
set(compiler_args -DCMAKE_C_COMPILER=${COMPILER_RT_TEST_COMPILER}
@@ -514,9 +509,29 @@ macro(add_custom_libcxx name prefix)
add_custom_target(${name}-clobber
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${name}-clobber-stamp)
- if(CMAKE_SYSROOT)
- set(sysroot_arg -DCMAKE_SYSROOT=${CMAKE_SYSROOT})
- endif()
+ set(PASSTHROUGH_VARIABLES
+ CMAKE_C_COMPILER_TARGET
+ CMAKE_CXX_COMPILER_TARGET
+ CMAKE_INSTALL_PREFIX
+ CMAKE_MAKE_PROGRAM
+ CMAKE_LINKER
+ CMAKE_AR
+ CMAKE_RANLIB
+ CMAKE_NM
+ CMAKE_OBJCOPY
+ CMAKE_OBJDUMP
+ CMAKE_STRIP
+ CMAKE_SYSROOT
+ CMAKE_SYSTEM_NAME)
+ foreach(variable ${PASSTHROUGH_VARIABLES})
+ if(${variable})
+ list(APPEND CMAKE_PASSTHROUGH_VARIABLES -D${variable}=${${variable}})
+ endif()
+ endforeach()
+
+ string(REPLACE ";" " " FLAGS_STRING "${LIBCXX_CFLAGS}")
+ set(LIBCXX_C_FLAGS "${FLAGS_STRING}")
+ set(LIBCXX_CXX_FLAGS "${FLAGS_STRING}")
ExternalProject_Add(${name}
DEPENDS ${name}-clobber ${LIBCXX_DEPS}
@@ -524,13 +539,11 @@ macro(add_custom_libcxx name prefix)
SOURCE_DIR ${COMPILER_RT_LIBCXX_PATH}
STAMP_DIR ${STAMP_DIR}
BINARY_DIR ${BINARY_DIR}
- CMAKE_ARGS -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
+ CMAKE_ARGS ${CMAKE_PASSTHROUGH_VARIABLES}
${compiler_args}
- ${sysroot_arg}
-DCMAKE_C_FLAGS=${LIBCXX_C_FLAGS}
-DCMAKE_CXX_FLAGS=${LIBCXX_CXX_FLAGS}
-DCMAKE_BUILD_TYPE=Release
- -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLLVM_PATH=${LLVM_MAIN_SRC_DIR}
-DLLVM_BINARY_DIR=${prefix}
-DLLVM_LIBRARY_OUTPUT_INTDIR=${prefix}/lib