Skip to content

Commit 3fea961

Browse files
committed
fixed cmake lists
1 parent d8d8757 commit 3fea961

File tree

2 files changed

+44
-79
lines changed

2 files changed

+44
-79
lines changed

.vscode/c_cpp_properties.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"version": 4,
3+
"configurations": [
4+
{
5+
"name": "STM32",
6+
"configurationProvider": "ms-vscode.cmake-tools",
7+
"intelliSenseMode": "${default}",
8+
"includePath": [
9+
"${workspaceFolder}/Core/Inc",
10+
"${workspaceFolder}/Drivers/CMSIS/Include",
11+
"${workspaceFolder}/Drivers/CMSIS/Device/ST/STM32H7xx/Include",
12+
"${workspaceFolder}/Drivers/STM32H7xx_HAL_Driver/Inc"
13+
],
14+
"defines": [
15+
"STM32H743xx",
16+
"USE_HAL_DRIVER"
17+
],
18+
"browse": {
19+
"path": [
20+
"${workspaceFolder}/Core/Inc",
21+
"${workspaceFolder}/Drivers"
22+
],
23+
"limitSymbolsToIncludedHeaders": true
24+
}
25+
}
26+
]
27+
}

cmake/stm32cubemx/CMakeLists.txt

Lines changed: 17 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,35 @@
11
cmake_minimum_required(VERSION 3.22)
2-
# Enable CMake support for ASM and C languages
32
enable_language(C ASM)
4-
# STM32CubeMX generated symbols (macros)
5-
set(MX_Defines_Syms
6-
USE_PWR_LDO_SUPPLY
7-
USE_HAL_DRIVER
8-
STM32H743xx
3+
set(MX_Defines_Syms
4+
USE_PWR_LDO_SUPPLY
5+
USE_HAL_DRIVER
6+
STM32H743xx
97
$<$<CONFIG:Debug>:DEBUG>
108
)
11-
12-
# STM32CubeMX generated include paths
139
set(MX_Include_Dirs
1410
${CMAKE_SOURCE_DIR}/Core/Inc
1511
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Inc
1612
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Inc/Legacy
1713
${CMAKE_SOURCE_DIR}/Drivers/CMSIS/Device/ST/STM32H7xx/Include
1814
${CMAKE_SOURCE_DIR}/Drivers/CMSIS/Include
1915
)
20-
21-
# STM32CubeMX generated application sources
22-
set(MX_Application_Src
23-
${CMAKE_SOURCE_DIR}/Core/Src/main.c
24-
${CMAKE_SOURCE_DIR}/Core/Src/stm32h7xx_it.c
25-
${CMAKE_SOURCE_DIR}/Core/Src/stm32h7xx_hal_msp.c
26-
${CMAKE_SOURCE_DIR}/Core/Src/sysmem.c
27-
${CMAKE_SOURCE_DIR}/Core/Src/syscalls.c
28-
${CMAKE_SOURCE_DIR}/startup_stm32h743xx.s
16+
file(GLOB_RECURSE CORE_SOURCES
17+
"${CMAKE_SOURCE_DIR}/Core/Src/*.[cCsS]"
18+
"${CMAKE_SOURCE_DIR}/Core/Src/*.cpp"
2919
)
30-
31-
# STM32 HAL/LL Drivers
32-
set(STM32_Drivers_Src
33-
${CMAKE_SOURCE_DIR}/Core/Src/system_stm32h7xx.c
34-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cortex.c
35-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc.c
36-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc_ex.c
37-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_flash.c
38-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_flash_ex.c
39-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_gpio.c
40-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_hsem.c
41-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma.c
42-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma_ex.c
43-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_mdma.c
44-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr.c
45-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr_ex.c
46-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.c
47-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c.c
48-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c_ex.c
49-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_exti.c
50-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_spi.c
51-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_spi_ex.c
52-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim.c
53-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim_ex.c
54-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart.c
55-
${CMAKE_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart_ex.c
20+
file(GLOB_RECURSE DRIVER_SOURCES
21+
"${CMAKE_SOURCE_DIR}/Drivers/**/*.[cCsS]"
22+
"${CMAKE_SOURCE_DIR}/Drivers/**/*.cpp"
5623
)
57-
58-
# Drivers Midllewares
59-
60-
61-
62-
# Link directories setup
63-
set(MX_LINK_DIRS
64-
65-
)
66-
# Project static libraries
67-
set(MX_LINK_LIBS
68-
STM32_Drivers
69-
70-
)
71-
# Interface library for includes and symbols
7224
add_library(stm32cubemx INTERFACE)
7325
target_include_directories(stm32cubemx INTERFACE ${MX_Include_Dirs})
7426
target_compile_definitions(stm32cubemx INTERFACE ${MX_Defines_Syms})
75-
76-
# Create STM32_Drivers static library
77-
add_library(STM32_Drivers OBJECT)
78-
target_sources(STM32_Drivers PRIVATE ${STM32_Drivers_Src})
79-
target_link_libraries(STM32_Drivers PUBLIC stm32cubemx)
80-
81-
82-
# Add STM32CubeMX generated application sources to the project
83-
target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${MX_Application_Src})
84-
85-
# Link directories setup
86-
target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE ${MX_LINK_DIRS})
87-
88-
# Add libraries to the project
89-
target_link_libraries(${CMAKE_PROJECT_NAME} ${MX_LINK_LIBS})
90-
91-
# Add the map file to the list of files to be removed with 'clean' target
92-
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES ADDITIONAL_CLEAN_FILES ${CMAKE_PROJECT_NAME}.map)
93-
94-
# Validate that STM32CubeMX code is compatible with C standard
27+
target_sources(${CMAKE_PROJECT_NAME} PRIVATE
28+
${CORE_SOURCES}
29+
${DRIVER_SOURCES}
30+
)
31+
target_link_libraries(${CMAKE_PROJECT_NAME} stm32cubemx)
32+
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES ADDITIONAL_CLEAN_FILES "${CMAKE_PROJECT_NAME}.map")
9533
if((CMAKE_C_STANDARD EQUAL 90) OR (CMAKE_C_STANDARD EQUAL 99))
96-
message(ERROR "Generated code requires C11 or higher")
34+
message(FATAL_ERROR "Generated code requires C11 or higher")
9735
endif()

0 commit comments

Comments
 (0)