Skip to content

Commit d9c69f2

Browse files
committedAug 2, 2022
refactor: moved flags out of the toolchain file
"Modern" CMake encourages the use of target-specific functions instead of global ones. The "overall configuration target" has also been renamed from core_config to base_config, to avoid confusion wrt. core, core_bin, core_usage.
1 parent cfce4af commit d9c69f2

File tree

519 files changed

+567
-573
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

519 files changed

+567
-573
lines changed
 

‎CI/update/templates/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ taget_link_options({{target}}_usage INTERFACE
2222
{% endif %}
2323

2424
target_link_libraries({{target}}_usage INTERFACE
25-
core_config
25+
base_config
2626
{% for lib in extra_libs | sort %}
2727
{{lib}}
2828
{% endfor %}

‎CMakeLists.txt

+49-27
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,26 @@ set(CMSIS5_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5" CACHE STRING "Path to CMSI
3434
option(AUTODL_CMSIS OFF)
3535
ensure_CMSIS(${CMSIS5_PATH} ${AUTODL_CMSIS})
3636

37-
add_library(core_config INTERFACE)
37+
add_library(base_config INTERFACE)
3838

3939
if(${BUILD_RELPATH})
40-
# $<TARGET_PROPERTY:SOURCE_DIR> is evaluated by the final consumer, no core_config
41-
target_compile_options(core_config INTERFACE
40+
# $<TARGET_PROPERTY:SOURCE_DIR> is evaluated by the final consumer, no base_config
41+
target_compile_options(base_config INTERFACE
4242
"-fmacro-prefix-map=$<TARGET_PROPERTY:SOURCE_DIR>=."
4343
)
4444
endif()
4545

4646
if(${BUILD_NDEBUG})
47-
add_compile_definitions(core_config INTERFACE NDEBUG)
47+
add_compile_definitions(base_config INTERFACE NDEBUG)
4848
endif()
4949

5050
# configuration specifics
5151
if (${FEAT_XSERIAL} STREQUAL "GENERIC")
52-
target_compile_definitions(core_config INTERFACE
52+
target_compile_definitions(base_config INTERFACE
5353
HAL_UART_MODULE_ENABLED
5454
)
5555
elseif (${FEAT_XSERIAL} STREQUAL "NONE")
56-
target_compile_definitions(core_config INTERFACE
56+
target_compile_definitions(base_config INTERFACE
5757
HAL_UART_MODULE_ENABLED
5858
HWSERIAL_NONE
5959
)
@@ -78,7 +78,7 @@ endif()
7878
if (${FEAT_USB} STREQUAL "NONE")
7979
#nothing
8080
elseif (${FEAT_USB} STREQUAL "CDCGEN")
81-
target_compile_definitions(core_config INTERFACE
81+
target_compile_definitions(base_config INTERFACE
8282
USBCON
8383
${USB_SPEED}
8484
USBD_VID=${USB_VID}
@@ -87,7 +87,7 @@ elseif (${FEAT_USB} STREQUAL "CDCGEN")
8787
USBD_USE_CDC
8888
)
8989
elseif (${FEAT_USB} STREQUAL "CDC")
90-
target_compile_definitions(core_config INTERFACE
90+
target_compile_definitions(base_config INTERFACE
9191
USBCON
9292
${USB_SPEED}
9393
USBD_VID=${USB_VID}
@@ -97,7 +97,7 @@ elseif (${FEAT_USB} STREQUAL "CDC")
9797
DISABLE_GENERIC_SERIALUSB
9898
)
9999
elseif (${FEAT_USB} STREQUAL "HID")
100-
target_compile_definitions(core_config INTERFACE
100+
target_compile_definitions(base_config INTERFACE
101101
USBCON
102102
${USB_SPEED}
103103
USBD_VID=${USB_VID}
@@ -110,16 +110,16 @@ else()
110110
endif()
111111

112112
if (${FEAT_NANOC})
113-
target_link_options(core_config INTERFACE
113+
target_link_options(base_config INTERFACE
114114
"--specs=nano.specs"
115115
)
116116
if (${FEAT_FPF})
117-
target_link_options(core_config INTERFACE
117+
target_link_options(base_config INTERFACE
118118
"SHELL:-u _printf_float"
119119
)
120120
endif()
121121
if(${FEAT_FSF})
122-
target_link_options(core_config INTERFACE
122+
target_link_options(base_config INTERFACE
123123
"SHELL:-u _scanf_float"
124124
)
125125
endif()
@@ -128,22 +128,22 @@ endif()
128128
if (${FEAT_VIRTIO} STREQUAL "DISABLED")
129129
# nothing
130130
elseif (${FEAT_VIRTIO} STREQUAL "GENERIC")
131-
target_compile_definitions(core_config INTERFACE
131+
target_compile_definitions(base_config INTERFACE
132132
VIRTIOCON
133133
NO_ATOMIC_64_SUPPORT
134134
METAL_INTERNAL
135135
METAL_MAX_DEVICE_REGIONS=2
136136
VIRTIO_SLAVE_ONLY
137137
VIRTIO_LOG
138138
)
139-
target_include_directories(core_config INTERFACE
139+
target_include_directories(base_config INTERFACE
140140
${BUILD_SYSTEM_PATH}/Middlewares/OpenAMP
141141
${BUILD_SYSTEM_PATH}/Middlewares/OpenAMP/open-amp/lib/include
142142
${BUILD_SYSTEM_PATH}/Middlewares/OpenAMP/libmetal/lib/include
143143
${BUILD_SYSTEM_PATH}/Middlewares/OpenAMP/virtual_driver
144144
)
145145
elseif (${FEAT_VIRTIO} STREQUAL "ENABLED")
146-
target_compile_definitions(core_config INTERFACE
146+
target_compile_definitions(base_config INTERFACE
147147
VIRTIOCON
148148
NO_ATOMIC_64_SUPPORT
149149
METAL_INTERNAL
@@ -152,7 +152,7 @@ elseif (${FEAT_VIRTIO} STREQUAL "ENABLED")
152152
VIRTIO_LOG
153153
DISABLE_GENERIC_SERIALVIRTIO
154154
)
155-
target_include_directories(core_config INTERFACE
155+
target_include_directories(base_config INTERFACE
156156
${BUILD_SYSTEM_PATH}/Middlewares/OpenAMP
157157
${BUILD_SYSTEM_PATH}/Middlewares/OpenAMP/open-amp/lib/include
158158
${BUILD_SYSTEM_PATH}/Middlewares/OpenAMP/libmetal/lib/include
@@ -163,48 +163,70 @@ else()
163163
endif()
164164

165165
if (${FEAT_TIMER})
166-
target_compile_definitions(core_config INTERFACE
166+
target_compile_definitions(base_config INTERFACE
167167
HAL_TIM_MODULE_ENABLE
168168
)
169169
else ()
170170
# triggers a user-directed warning
171-
target_compile_definitions(core_config INTERFACE
171+
target_compile_definitions(base_config INTERFACE
172172
HAL_TIM_MODULE_DISABLED
173173
)
174174
endif()
175175

176176
if (${BUILD_OPT} MATCHES "^[0-3gs]$")
177-
target_compile_options(core_config INTERFACE
177+
target_compile_options(base_config INTERFACE
178178
-O${BUILD_OPT}
179179
)
180180
else()
181181
message(SEND_ERROR "Bad value for BUILD_OPT: got `${BUILD_OPT}`, expected one of 0123gs.")
182182
endif()
183183

184184
if (${BUILD_DBG})
185-
target_compile_options(core_config INTERFACE
185+
target_compile_options(base_config INTERFACE
186186
-g
187187
)
188188
endif()
189189

190190
if (${BUILD_LTO})
191-
target_compile_options(core_config INTERFACE
191+
target_compile_options(base_config INTERFACE
192192
-flto
193193
)
194-
target_link_options(core_config INTERFACE
194+
target_link_options(base_config INTERFACE
195195
-flto
196196
)
197197
endif()
198198

199199
# generic compilation options
200-
target_link_libraries(core_config INTERFACE board)
201-
target_link_options(core_config INTERFACE
200+
target_link_libraries(base_config INTERFACE board)
201+
target_compile_definitions(base_config INTERFACE
202+
USE_FULL_LL_DRIVER
203+
ARDUINO_ARCH_STM32
204+
)
205+
target_compile_options(base_config INTERFACE
206+
-mthumb
207+
--param max-inline-insns-single=500
208+
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
209+
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
210+
$<$<COMPILE_LANGUAGE:CXX>:-fno-use-cxa-atexit>
211+
$<$<COMPILE_LANGUAGE:CXX>:-fno-threadsafe-statics>
212+
-ffunction-sections
213+
-fdata-sections
214+
)
215+
216+
target_link_options(base_config INTERFACE
217+
-mthumb
218+
LINKER:--cref
219+
LINKER:--check-sections
220+
LINKER:--gc-sections
221+
LINKER:--entry=Reset_Handler
222+
LINKER:--unresolved-symbols=report-all
223+
LINKER:--warn-common
202224
LINKER:--script=${BUILD_SYSTEM_PATH}/ldscript.ld
203225
)
204-
target_link_directories(core_config INTERFACE
226+
target_link_directories(base_config INTERFACE
205227
"${CMSIS5_PATH}/CMSIS/DSP/Lib/GCC"
206228
)
207-
target_include_directories(core_config INTERFACE
229+
target_include_directories(base_config INTERFACE
208230
"${BUILD_CORE_PATH}"
209231
"${BUILD_CORE_PATH}/avr"
210232
"${BUILD_CORE_PATH}/stm32"
@@ -235,7 +257,7 @@ target_link_libraries(stm32_runtime INTERFACE
235257
# but SrcWrapper is an object library, not an archive, so it isn't necessary
236258
# (this means the linker takes all the object unconditionally, as opposed to an archive where it picks what it needs)
237259
# note: SrcWrapper in particular MUST be an object library, due to possible weak+strong symbols (cf. library.properties)
238-
core_config
260+
base_config
239261

240262
SrcWrapper
241263
core

0 commit comments

Comments
 (0)