forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtarget.cmake
61 lines (54 loc) · 1.78 KB
/
target.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# SPDX-License-Identifier: Apache-2.0
if(CONFIG_LLVM_USE_LD)
set(LINKER ld)
elseif(CONFIG_LLVM_USE_LLD)
set(LINKER lld)
endif()
if("${ARCH}" STREQUAL "arm")
if(DEFINED CONFIG_ARMV8_M_MAINLINE)
# ARMv8-M mainline is ARMv7-M with additional features from ARMv8-M.
set(triple armv8m.main-none-eabi)
elseif(DEFINED CONFIG_ARMV8_M_BASELINE)
# ARMv8-M baseline is ARMv6-M with additional features from ARMv8-M.
set(triple armv8m.base-none-eabi)
elseif(DEFINED CONFIG_ARMV7_M_ARMV8_M_MAINLINE)
# ARMV7_M_ARMV8_M_MAINLINE means that ARMv7-M or backward compatible ARMv8-M
# processor is used.
set(triple armv7m-none-eabi)
elseif(DEFINED CONFIG_ARMV6_M_ARMV8_M_BASELINE)
# ARMV6_M_ARMV8_M_BASELINE means that ARMv6-M or ARMv8-M supporting the
# Baseline implementation processor is used.
set(triple armv6m-none-eabi)
else()
# Default ARM target supported by all processors.
set(triple arm-none-eabi)
endif()
set(CMAKE_EXE_LINKER_FLAGS_INIT "--specs=nosys.specs")
elseif("${ARCH}" STREQUAL "x86")
if(CONFIG_64BIT)
set(triple x86_64-pc-none-elf)
else()
set(triple i686-pc-none-elf)
endif()
elseif("${ARCH}" STREQUAL "riscv")
if(CONFIG_64BIT)
set(triple riscv64-unknown-elf)
else()
set(triple riscv32-unknown-elf)
endif()
endif()
if(DEFINED triple)
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_ASM_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER_TARGET ${triple})
unset(triple)
endif()
if(CONFIG_LIBGCC_RTLIB)
set(runtime_lib "libgcc")
elseif(CONFIG_COMPILER_RT_RTLIB)
set(runtime_lib "compiler_rt")
endif()
list(APPEND TOOLCHAIN_C_FLAGS --config
${ZEPHYR_BASE}/cmake/toolchain/llvm/clang_${runtime_lib}.cfg)
list(APPEND TOOLCHAIN_LD_FLAGS --config
${ZEPHYR_BASE}/cmake/toolchain/llvm/clang_${runtime_lib}.cfg)