Skip to content

Commit e036d88

Browse files
massonalfpistm
authored andcommitted
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 ef166a5 commit e036d88

File tree

517 files changed

+565
-571
lines changed

Some content is hidden

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

517 files changed

+565
-571
lines changed

CI/update/templates/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ target_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

cmake/handle_sketch.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set(SCRIPTS_FOLDER ${CMAKE_CURRENT_LIST_DIR}/../scripts)
55
# MAPFILE should be absolute!!
66
# only a rule is generated for the mapfile, not a target
77
function(handle_sketch TGTNAME MAPFILE SRCLIST)
8-
# TODO: have the sketch folder in the include path of core_config
8+
# TODO: have the sketch folder in the include path of base_config
99

1010
set(CURATED_SRC "")
1111
foreach(SRCFILE IN LISTS SRCLIST)

cmake/toolchain.cmake

-28
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,3 @@ set(BUILD_SHARED_LIBS false CACHE STRING "")
1919

2020
set(CMAKE_CXX_STANDARD 14)
2121
set(CMAKE_C_STANDARD 11)
22-
23-
# global compilation options
24-
add_compile_definitions(
25-
USE_FULL_LL_DRIVER
26-
ARDUINO=10607
27-
ARDUINO_ARCH_STM32
28-
)
29-
30-
add_compile_options(
31-
-mthumb
32-
--param max-inline-insns-single=500
33-
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
34-
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
35-
$<$<COMPILE_LANGUAGE:CXX>:-fno-use-cxa-atexit>
36-
$<$<COMPILE_LANGUAGE:CXX>:-fno-threadsafe-statics>
37-
-ffunction-sections
38-
-fdata-sections
39-
)
40-
41-
add_link_options(
42-
-mthumb
43-
LINKER:--cref
44-
LINKER:--check-sections
45-
LINKER:--gc-sections
46-
LINKER:--entry=Reset_Handler
47-
LINKER:--unresolved-symbols=report-all
48-
LINKER:--warn-common
49-
)

cores/arduino/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ target_include_directories(core_usage INTERFACE
88

99

1010
target_link_libraries(core_usage INTERFACE
11-
core_config
11+
base_config
1212
)
1313

1414
target_link_libraries(core INTERFACE core_usage)
1515

1616

1717

18-
add_library(core_bin EXCLUDE_FROM_ALL
18+
add_library(core_bin STATIC EXCLUDE_FROM_ALL
1919
HardwareSerial.cpp
2020
HardwareTimer.cpp
2121
IPAddress.cpp

libraries/CMSIS_DSP/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ target_include_directories(CMSIS_DSP_usage INTERFACE
1111

1212

1313
target_link_libraries(CMSIS_DSP_usage INTERFACE
14-
core_config
14+
base_config
1515
core
1616
)
1717

libraries/EEPROM/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ target_include_directories(EEPROM_usage INTERFACE
1111

1212

1313
target_link_libraries(EEPROM_usage INTERFACE
14-
core_config
14+
base_config
1515
core
1616
)
1717

libraries/IWatchdog/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ target_include_directories(IWatchdog_usage INTERFACE
1111

1212

1313
target_link_libraries(IWatchdog_usage INTERFACE
14-
core_config
14+
base_config
1515
core
1616
)
1717

libraries/Keyboard/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ target_include_directories(Keyboard_usage INTERFACE
1111

1212

1313
target_link_libraries(Keyboard_usage INTERFACE
14-
core_config
14+
base_config
1515
core
1616
)
1717

libraries/Mouse/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ target_include_directories(Mouse_usage INTERFACE
1111

1212

1313
target_link_libraries(Mouse_usage INTERFACE
14-
core_config
14+
base_config
1515
core
1616
)
1717

libraries/RGB_LED_TLC59731/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ target_include_directories(RGB_LED_TLC59731_usage INTERFACE
1111

1212

1313
target_link_libraries(RGB_LED_TLC59731_usage INTERFACE
14-
core_config
14+
base_config
1515
core
1616
)
1717

libraries/SPI/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ target_include_directories(SPI_usage INTERFACE
1111

1212

1313
target_link_libraries(SPI_usage INTERFACE
14-
core_config
14+
base_config
1515
core
1616
)
1717

libraries/Servo/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ target_include_directories(Servo_usage INTERFACE
1111

1212

1313
target_link_libraries(Servo_usage INTERFACE
14-
core_config
14+
base_config
1515
core
1616
)
1717

libraries/SoftwareSerial/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ target_include_directories(SoftwareSerial_usage INTERFACE
1111

1212

1313
target_link_libraries(SoftwareSerial_usage INTERFACE
14-
core_config
14+
base_config
1515
core
1616
)
1717

libraries/SrcWrapper/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ target_include_directories(SrcWrapper_usage INTERFACE
1111

1212

1313
target_link_libraries(SrcWrapper_usage INTERFACE
14-
core_config
14+
base_config
1515
core
1616
)
1717

libraries/Wire/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ target_include_directories(Wire_usage INTERFACE
1111

1212

1313
target_link_libraries(Wire_usage INTERFACE
14-
core_config
14+
base_config
1515
core
1616
)
1717

variants/STM32F0xx/F030C6T/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ target_include_directories(variant_usage INTERFACE
88

99

1010
target_link_libraries(variant_usage INTERFACE
11-
core_config
11+
base_config
1212
)
1313

1414
target_link_libraries(variant INTERFACE variant_usage)

variants/STM32F0xx/F030C8T/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ target_include_directories(variant_usage INTERFACE
88

99

1010
target_link_libraries(variant_usage INTERFACE
11-
core_config
11+
base_config
1212
)
1313

1414
target_link_libraries(variant INTERFACE variant_usage)

variants/STM32F0xx/F030CCT/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ target_include_directories(variant_usage INTERFACE
88

99

1010
target_link_libraries(variant_usage INTERFACE
11-
core_config
11+
base_config
1212
)
1313

1414
target_link_libraries(variant INTERFACE variant_usage)

0 commit comments

Comments
 (0)