-
Notifications
You must be signed in to change notification settings - Fork 3k
/
GCC_ARM.cmake
100 lines (90 loc) · 2.59 KB
/
GCC_ARM.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set(CMAKE_ASM_COMPILER "arm-none-eabi-gcc")
set(CMAKE_C_COMPILER "arm-none-eabi-gcc")
set(CMAKE_CXX_COMPILER "arm-none-eabi-g++")
set(GCC_ELF2BIN "arm-none-eabi-objcopy")
set_property(GLOBAL PROPERTY ELF2BIN ${GCC_ELF2BIN})
# Sets toolchain options
function(mbed_set_toolchain_options target)
list(APPEND link_options
"-Wl,--start-group"
"-lstdc++"
"-lsupc++"
"-lm"
"-lc"
"-lgcc"
"-lnosys"
"-Wl,--end-group"
"-specs=nosys.specs"
"-T" "${CMAKE_BINARY_DIR}/${APP_TARGET}.link_script.ld"
"-Wl,-Map=${CMAKE_BINARY_DIR}/${APP_TARGET}.map"
"-Wl,--cref"
)
# Add linking time preprocessor macro for TFM targets
if("TFM" IN_LIST MBED_TARGET_LABELS)
list(APPEND link_options
"-DDOMAIN_NS=1"
)
endif()
list(APPEND common_options
"-Wall"
"-Wextra"
"-Wno-unused-parameter"
"-Wno-missing-field-initializers"
"-fmessage-length=0"
"-fno-exceptions"
"-ffunction-sections"
"-fdata-sections"
"-funsigned-char"
"-MMD"
"-fomit-frame-pointer"
"-g3"
)
target_compile_options(${target}
INTERFACE
${common_options}
)
target_link_options(${target}
INTERFACE
${common_options}
${link_options}
)
endfunction()
# Configure the toolchain to select the selected C library
function(mbed_set_c_lib target lib_type)
if (${lib_type} STREQUAL "small")
target_compile_definitions(${target}
INTERFACE
MBED_RTOS_SINGLE_THREAD
__NEWLIB_NANO
)
target_link_options(${target}
INTERFACE
"--specs=nano.specs"
)
endif()
endfunction()
# Configure the toolchain to select the selected printf library
function(mbed_set_printf_lib target lib_type)
if (${lib_type} STREQUAL "minimal-printf")
target_compile_definitions(${target}
INTERFACE
MBED_MINIMAL_PRINTF
)
list(APPEND link_options
"-Wl,--wrap,printf"
"-Wl,--wrap,sprintf"
"-Wl,--wrap,snprintf"
"-Wl,--wrap,vprintf"
"-Wl,--wrap,vsprintf"
"-Wl,--wrap,vsnprintf"
"-Wl,--wrap,fprintf"
"-Wl,--wrap,vfprintf"
)
target_link_options(${target}
INTERFACE
${link_options}
)
endif()
endfunction()