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

Commit

Permalink
Define CLR specific compiler option CLR_CMAKE_COMPILER
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
franksinankaya committed Feb 6, 2019
1 parent dfaf7be commit 86e4ccf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
21 changes: 17 additions & 4 deletions cross/toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ if(DEFINED ENV{TOOLCHAIN})
set(TOOLCHAIN $ENV{TOOLCHAIN})
endif()

# This gets called with CLR_CMAKE_COMPILER set on the first invocation
# but the cmake variable is not getting populated into other calls.
# Use environment variable to keep CLR_CMAKE_COMPILER around.
if (NOT DEFINED CLR_CMAKE_COMPILER)
set(CLR_CMAKE_COMPILER $ENV{CLR_CMAKE_COMPILER})
else()
set(ENV{CLR_CMAKE_COMPILER} ${CLR_CMAKE_COMPILER})
endif()

# Specify include paths
if(TARGET_ARCH_NAME STREQUAL "armel")
if(DEFINED TIZEN_TOOLCHAIN)
Expand Down Expand Up @@ -62,8 +71,10 @@ endmacro()

# Specify link flags
add_compile_param(CROSS_LINK_FLAGS "--sysroot=${CROSS_ROOTFS}")
add_compile_param(CROSS_LINK_FLAGS "--gcc-toolchain=${CROSS_ROOTFS}/usr")
add_compile_param(CROSS_LINK_FLAGS "--target=${TOOLCHAIN}")
if (CLR_CMAKE_COMPILER STREQUAL "Clang")
add_compile_param(CROSS_LINK_FLAGS "--gcc-toolchain=${CROSS_ROOTFS}/usr")
add_compile_param(CROSS_LINK_FLAGS "--target=${TOOLCHAIN}")
endif()

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

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

# Specify compile options
add_compile_options("--sysroot=${CROSS_ROOTFS}")
add_compile_options("--target=${TOOLCHAIN}")
add_compile_options("--gcc-toolchain=${CROSS_ROOTFS}/usr")
if (CLR_CMAKE_COMPILER STREQUAL "Clang")
add_compile_options("--target=${TOOLCHAIN}")
add_compile_options("--gcc-toolchain=${CROSS_ROOTFS}/usr")
endif()

if(TARGET_ARCH_NAME MATCHES "^(arm|armel|arm64)$")
set(CMAKE_C_COMPILER_TARGET ${TOOLCHAIN})
Expand Down
1 change: 1 addition & 0 deletions src/pal/tools/gen-buildsys-clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ cmake \
"-DCMAKE_BUILD_TYPE=$buildtype" \
"-DCMAKE_EXPORT_COMPILE_COMMANDS=1 " \
"-DCLR_CMAKE_ENABLE_CODE_COVERAGE=$code_coverage" \
"-DCLR_CMAKE_COMPILER=Clang" \
$cmake_extra_defines \
$__UnprocessedCMakeArgs \
"$1"
1 change: 1 addition & 0 deletions src/pal/tools/gen-buildsys-gcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ cmake \
"-DCMAKE_BUILD_TYPE=$buildtype" \
"-DCMAKE_EXPORT_COMPILE_COMMANDS=1 " \
"-DCLR_CMAKE_ENABLE_CODE_COVERAGE=$code_coverage" \
"-DCLR_CMAKE_COMPILER=GNU" \
$cmake_extra_defines \
$__UnprocessedCMakeArgs \
"$1"

0 comments on commit 86e4ccf

Please sign in to comment.