-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
216 lines (163 loc) · 6.75 KB
/
CMakeLists.txt
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#
# This file is part of the µOS++ distribution.
# (https://github.com/micro-os-plus)
# Copyright (c) 2021 Liviu Ionescu
#
# Permission to use, copy, modify, and/or distribute this software
# for any purpose is hereby granted, under the terms of the MIT license.
#
# If a copy of the license was not distributed with this file, it can
# be obtained from https://opensource.org/licenses/MIT/.
#
# -----------------------------------------------------------------------------
# This file is intended to be consumed by applications with:
#
# `add_subdirectory("xpacks/micro-os-plus-platform-stm32f4discovery")`
#
# The result is a static library that can be added to the linker with:
#
# `target_link_libraries(your-target PUBLIC micro-os-plus::platform-stm32f4discovery)`
# -----------------------------------------------------------------------------
## Preamble ##
# https://cmake.org/cmake/help/v3.20/
cmake_minimum_required(VERSION 3.20)
project(
micro-os-plus-platform-stm32f4discovery
DESCRIPTION "µOS++ STM32F4DISCOVERY board support"
)
if(COMMAND xpack_get_package_name_and_version)
xpack_get_package_name_and_version("${CMAKE_CURRENT_SOURCE_DIR}/package.json")
message(VERBOSE "Processing xPack ${PACKAGE_JSON_NAME}@${PACKAGE_JSON_VERSION}...")
endif()
# -----------------------------------------------------------------------------
# Preprocessor symbols.
set(xpack_platform_compile_definition "PLATFORM_STM32F4DISCOVERY")
set(xpack_device_compile_definition "STM32F407xx")
string(TOLOWER ${xpack_device_compile_definition} xpack_device_name)
# -----------------------------------------------------------------------------
## The project library definitions ##
# https://cmake.org/cmake/help/v3.20/command/add_library.html?highlight=interface#normal-libraries
# PRIVATE: build definitions, used internally
# INTERFACE: usage definitions, passed up to targets linking to it
# PUBLIC: both
add_library(micro-os-plus-device-interface INTERFACE EXCLUDE_FROM_ALL)
# -----------------------------------------------------------------------------
# Target settings.
# Add the CubeMX device specific definitions.
target_include_directories(
micro-os-plus-device-interface
INTERFACE
# For the CMSIS Core headers.
"stm32cubemx/Drivers/CMSIS/Include"
# For the CMSIS vendor files (stm32f4xx.h, system_stm32f4xx.h)
"stm32cubemx/Drivers/CMSIS/Device/ST/STM32F4xx/Include"
)
target_sources(
micro-os-plus-device-interface
INTERFACE
"stm32cubemx/Core/Src/system_stm32f4xx.c"
)
target_compile_definitions(
micro-os-plus-device-interface
INTERFACE
# Already defined in the micro-os-plus-device-stm32f4-extras.
# ${xpack_device_compile_definition}
# ... add preprocessor macro definitions.
)
target_compile_options(
micro-os-plus-device-interface
INTERFACE
# ... perhaps ignore some warnings.
)
target_link_libraries(
micro-os-plus-device-interface
INTERFACE
micro-os-plus::devices-cortexm
micro-os-plus::devices-${xpack_device_name}-extras
micro-os-plus::startup
)
if (COMMAND xpack_display_target_lists)
xpack_display_target_lists(micro-os-plus-device-interface)
endif()
# -----------------------------------------------------------------------------
# Aliases.
# https://cmake.org/cmake/help/v3.20/command/add_library.html#alias-libraries
add_library(micro-os-plus::device ALIAS micro-os-plus-device-interface)
message(VERBOSE "> micro-os-plus::device -> micro-os-plus-device-interface")
# =============================================================================
add_library(micro-os-plus-platform-stm32f4discovery-interface INTERFACE EXCLUDE_FROM_ALL)
if(NOT PLATFORM_STM32F4DISCOVERY_WITHOUT_HAL)
target_include_directories(
micro-os-plus-platform-stm32f4discovery-interface
INTERFACE
# For the stm32f4xx_hal_conf.h, stm32f4xx_it.h, gpio.h, main.h
"stm32cubemx/Core/Inc"
# For the stm32f4xx_hal.h and stm32f4xx_hal_*.h
"stm32cubemx/Drivers/STM32F4xx_HAL_Driver/Inc"
)
target_sources(
micro-os-plus-platform-stm32f4discovery-interface
INTERFACE
stm32cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c
stm32cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c
stm32cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c
stm32cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c
stm32cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c
stm32cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c
stm32cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c
stm32cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c
stm32cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c
stm32cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c
stm32cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c
stm32cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c
stm32cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c
stm32cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c
stm32cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c
# system_stm32f4xx.c is not here but in the device library.
# These are not in the device library because they include
# stm32f4xx_hal_conf.h, which is part of the platform.
stm32cubemx/Core/Src/gpio.c
stm32cubemx/Core/Src/main.c
stm32cubemx/Core/Src/stm32f4xx_hal_msp.c
stm32cubemx/Core/Src/stm32f4xx_it.c
)
endif()
target_compile_definitions(
micro-os-plus-platform-stm32f4discovery-interface
INTERFACE
"${xpack_platform_compile_definition}"
)
if(NOT PLATFORM_STM32F4DISCOVERY_WITHOUT_HAL)
target_compile_definitions(
micro-os-plus-platform-stm32f4discovery-interface
INTERFACE
USE_HAL_DRIVER
)
endif()
target_compile_options(
micro-os-plus-platform-stm32f4discovery-interface
INTERFACE
# To silence HAL warnings.
-Wno-padded
-Wno-switch-enum
-Wno-conversion
-Wno-redundant-decls
-Wno-switch-default
-Wno-unused-parameter
$<$<COMPILE_LANG_AND_ID:C,GNU>:-Wno-bad-function-cast>
)
target_link_libraries(
micro-os-plus-platform-stm32f4discovery-interface
INTERFACE
micro-os-plus::device
micro-os-plus::diag-trace
)
if (COMMAND xpack_display_target_lists)
xpack_display_target_lists(micro-os-plus-platform-stm32f4discovery-interface)
endif()
# -----------------------------------------------------------------------------
# Aliases.
# https://cmake.org/cmake/help/v3.20/command/add_library.html#alias-libraries
add_library(micro-os-plus::platform-stm32f4discovery ALIAS micro-os-plus-platform-stm32f4discovery-interface)
message(VERBOSE "> micro-os-plus::platform-stm32f4discovery -> micro-os-plus-platform-stm32f4discovery-interface")
# -----------------------------------------------------------------------------