forked from OSchip/llvm-project
[cmake] Make setting of CMAKE_C(XX)_COMPILER flags overridable for cross-builds
Summary: r319898 made it possible to override these variables via the CROSS_TOOLCHAIN_FLAGS setting, but this only worked if one explicitly specifies these variables there. If, instead, one uses CROSS_TOOLCHAIN_FLAGS to specify a toolchain file (as our internal builds do, to point cmake to a checked-in toolchain), the CMAKE_C(XX)_COMPILER flags would still win over the ones specified by the toolchain file. To fix is to make the mere presence of these flags overridable. I do this by putting them as a default value for the CROSS_TOOLCHAIN_FLAGS setting, so they can be overridden at cmake configuration time. Reviewers: hintonda, beanz Subscribers: bogner, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D40947 llvm-svn: 320138
This commit is contained in:
parent
2cf601f28f
commit
f5f0fffea5
|
@ -7,10 +7,16 @@ function(llvm_create_cross_target_internal target_name toolchain buildtype)
|
|||
endif(NOT DEFINED LLVM_${target_name}_BUILD)
|
||||
|
||||
if (EXISTS ${LLVM_MAIN_SRC_DIR}/cmake/platforms/${toolchain}.cmake)
|
||||
set(CROSS_TOOLCHAIN_FLAGS_${target_name}
|
||||
-DCMAKE_TOOLCHAIN_FILE=\"${LLVM_MAIN_SRC_DIR}/cmake/platforms/${toolchain}.cmake\"
|
||||
CACHE STRING "Toolchain file for ${target_name}")
|
||||
set(CROSS_TOOLCHAIN_FLAGS_INIT
|
||||
-DCMAKE_TOOLCHAIN_FILE=\"${LLVM_MAIN_SRC_DIR}/cmake/platforms/${toolchain}.cmake\")
|
||||
else()
|
||||
set(CROSS_TOOLCHAIN_FLAGS_INIT
|
||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
)
|
||||
endif()
|
||||
set(CROSS_TOOLCHAIN_FLAGS_${target_name} ${CROSS_TOOLCHAIN_FLAGS_INIT}
|
||||
CACHE STRING "Toolchain configuration for ${target_name}")
|
||||
|
||||
if (buildtype)
|
||||
set(build_type_flags "-DCMAKE_BUILD_TYPE=${buildtype}")
|
||||
|
@ -32,8 +38,6 @@ function(llvm_create_cross_target_internal target_name toolchain buildtype)
|
|||
|
||||
add_custom_command(OUTPUT ${LLVM_${target_name}_BUILD}/CMakeCache.txt
|
||||
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
|
||||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
||||
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
|
||||
${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_SOURCE_DIR}
|
||||
-DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
|
||||
-DLLVM_TARGETS_TO_BUILD=Native
|
||||
|
|
Loading…
Reference in New Issue