llvm.org GIT mirror llvm / f4f4ffb
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320138 91177308-0d34-0410-b5e6-96231b3b80d8 Pavel Labath 1 year, 10 months ago
1 changed file(s) with 9 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
66 endif(NOT DEFINED LLVM_${target_name}_BUILD)
77
88 if (EXISTS ${LLVM_MAIN_SRC_DIR}/cmake/platforms/${toolchain}.cmake)
9 set(CROSS_TOOLCHAIN_FLAGS_${target_name}
10 -DCMAKE_TOOLCHAIN_FILE=\"${LLVM_MAIN_SRC_DIR}/cmake/platforms/${toolchain}.cmake\"
11 CACHE STRING "Toolchain file for ${target_name}")
9 set(CROSS_TOOLCHAIN_FLAGS_INIT
10 -DCMAKE_TOOLCHAIN_FILE=\"${LLVM_MAIN_SRC_DIR}/cmake/platforms/${toolchain}.cmake\")
11 else()
12 set(CROSS_TOOLCHAIN_FLAGS_INIT
13 -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
14 -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
15 )
1216 endif()
17 set(CROSS_TOOLCHAIN_FLAGS_${target_name} ${CROSS_TOOLCHAIN_FLAGS_INIT}
18 CACHE STRING "Toolchain configuration for ${target_name}")
1319
1420 if (buildtype)
1521 set(build_type_flags "-DCMAKE_BUILD_TYPE=${buildtype}")
3137
3238 add_custom_command(OUTPUT ${LLVM_${target_name}_BUILD}/CMakeCache.txt
3339 COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
34 -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
35 -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
3640 ${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_SOURCE_DIR}
3741 -DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE
3842 -DLLVM_TARGETS_TO_BUILD=Native