Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 6d417e6

Browse files
Define CLR specific compiler option CLR_CMAKE_COMPILER
By the time toolchain.cmake is called, the compiler detection from cmake is not active. We need an intermediate definition to pass to compiler detection.
1 parent 4616bc8 commit 6d417e6

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

cross/toolchain.cmake

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ if(DEFINED ENV{TOOLCHAIN})
3535
set(TOOLCHAIN $ENV{TOOLCHAIN})
3636
endif()
3737

38+
# This gets called with CLR_CMAKE_COMPILER set on the first invocation
39+
# but the cmake variable is not getting populated into other calls.
40+
# Use environment variable to keep CLR_CMAKE_COMPILER around.
41+
if (NOT DEFINED CLR_CMAKE_COMPILER)
42+
set(CLR_CMAKE_COMPILER $ENV{CLR_CMAKE_COMPILER})
43+
else()
44+
set(ENV{CLR_CMAKE_COMPILER} ${CLR_CMAKE_COMPILER})
45+
endif()
46+
3847
# Specify include paths
3948
if(TARGET_ARCH_NAME STREQUAL "armel")
4049
if(DEFINED TIZEN_TOOLCHAIN)
@@ -62,8 +71,10 @@ endmacro()
6271

6372
# Specify link flags
6473
add_compile_param(CROSS_LINK_FLAGS "--sysroot=${CROSS_ROOTFS}")
65-
add_compile_param(CROSS_LINK_FLAGS "--gcc-toolchain=${CROSS_ROOTFS}/usr")
66-
add_compile_param(CROSS_LINK_FLAGS "--target=${TOOLCHAIN}")
74+
if (CLR_CMAKE_COMPILER STREQUAL "Clang")
75+
add_compile_param(CROSS_LINK_FLAGS "--gcc-toolchain=${CROSS_ROOTFS}/usr")
76+
add_compile_param(CROSS_LINK_FLAGS "--target=${TOOLCHAIN}")
77+
endif()
6778

6879
add_compile_param(CROSS_LINK_FLAGS "-fuse-ld=gold")
6980

@@ -84,8 +95,10 @@ add_compile_param(CMAKE_MODULE_LINKER_FLAGS "${CROSS_LINK_FLAGS}" "TOOLCHAIN_EXE
8495

8596
# Specify compile options
8697
add_compile_options("--sysroot=${CROSS_ROOTFS}")
87-
add_compile_options("--target=${TOOLCHAIN}")
88-
add_compile_options("--gcc-toolchain=${CROSS_ROOTFS}/usr")
98+
if (CLR_CMAKE_COMPILER STREQUAL "Clang")
99+
add_compile_options("--target=${TOOLCHAIN}")
100+
add_compile_options("--gcc-toolchain=${CROSS_ROOTFS}/usr")
101+
endif()
89102

90103
if(TARGET_ARCH_NAME MATCHES "^(arm|armel|arm64)$")
91104
set(CMAKE_C_COMPILER_TARGET ${TOOLCHAIN})

src/pal/tools/gen-buildsys-clang.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ cmake \
162162
"-DCMAKE_BUILD_TYPE=$buildtype" \
163163
"-DCMAKE_EXPORT_COMPILE_COMMANDS=1 " \
164164
"-DCLR_CMAKE_ENABLE_CODE_COVERAGE=$code_coverage" \
165+
"-DCLR_CMAKE_COMPILER=Clang" \
165166
$cmake_extra_defines \
166167
$__UnprocessedCMakeArgs \
167168
"$1"

src/pal/tools/gen-buildsys-gcc.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ cmake \
182182
"-DCMAKE_BUILD_TYPE=$buildtype" \
183183
"-DCMAKE_EXPORT_COMPILE_COMMANDS=1 " \
184184
"-DCLR_CMAKE_ENABLE_CODE_COVERAGE=$code_coverage" \
185+
"-DCLR_CMAKE_COMPILER=GNU" \
185186
$cmake_extra_defines \
186187
$__UnprocessedCMakeArgs \
187188
"$1"

0 commit comments

Comments
 (0)