source: trunk/fw_g473rct/cmake/stm32cubemx/CMakeLists.txt@ 38

Last change on this file since 38 was 38, checked in by f.jahn, 7 weeks ago
File size: 5.8 KB
Line 
1cmake_minimum_required(VERSION 3.22)
2# Enable CMake support for ASM and C languages
3enable_language(C ASM)
4# STM32CubeMX generated symbols (macros)
5set(MX_Defines_Syms
6 USE_HAL_DRIVER
7 STM32G473xx
8 $<$<CONFIG:Debug>:DEBUG>
9)
10
11# STM32CubeMX generated include paths
12set(MX_Include_Dirs
13 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Inc
14 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Inc
15 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Inc/Legacy
16 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/CMSIS/Device/ST/STM32G4xx/Include
17 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/CMSIS/Include
18)
19
20# STM32CubeMX generated application sources
21set(MX_Application_Src
22 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/main.c
23 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/gpio.c
24 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/adc.c
25 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/crc.c
26 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/dma.c
27 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/fdcan.c
28 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/i2c.c
29 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/iwdg.c
30 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/rtc.c
31 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/spi.c
32 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/usart.c
33 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/usb.c
34 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/stm32g4xx_it.c
35 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/stm32g4xx_hal_msp.c
36 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/sysmem.c
37 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/syscalls.c
38 ${CMAKE_CURRENT_SOURCE_DIR}/../../startup_stm32g473xx.s
39)
40
41# STM32 HAL/LL Drivers
42set(STM32_Drivers_Src
43 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/system_stm32g4xx.c
44 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_adc.c
45 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_adc_ex.c
46 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_adc.c
47 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c
48 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c
49 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc_ex.c
50 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash.c
51 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ex.c
52 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ramfunc.c
53 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_gpio.c
54 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_exti.c
55 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma.c
56 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma_ex.c
57 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr.c
58 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr_ex.c
59 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_cortex.c
60 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_crc.c
61 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_crc_ex.c
62 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_fdcan.c
63 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c.c
64 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c_ex.c
65 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_iwdg.c
66 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rtc.c
67 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rtc_ex.c
68 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_spi.c
69 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_spi_ex.c
70 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart.c
71 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart_ex.c
72 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pcd.c
73 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pcd_ex.c
74 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_usb.c
75)
76
77# Drivers Midllewares
78
79
80
81# Link directories setup
82set(MX_LINK_DIRS
83
84)
85# Project static libraries
86set(MX_LINK_LIBS
87 STM32_Drivers
88 ${TOOLCHAIN_LINK_LIBRARIES}
89
90)
91# Interface library for includes and symbols
92add_library(stm32cubemx INTERFACE)
93target_include_directories(stm32cubemx INTERFACE ${MX_Include_Dirs})
94target_compile_definitions(stm32cubemx INTERFACE ${MX_Defines_Syms})
95
96# Create STM32_Drivers static library
97add_library(STM32_Drivers OBJECT)
98target_sources(STM32_Drivers PRIVATE ${STM32_Drivers_Src})
99target_link_libraries(STM32_Drivers PUBLIC stm32cubemx)
100
101
102# Add STM32CubeMX generated application sources to the project
103target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${MX_Application_Src})
104
105# Link directories setup
106target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE ${MX_LINK_DIRS})
107
108# Add libraries to the project
109target_link_libraries(${CMAKE_PROJECT_NAME} ${MX_LINK_LIBS})
110
111# Add the map file to the list of files to be removed with 'clean' target
112set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES ADDITIONAL_CLEAN_FILES ${CMAKE_PROJECT_NAME}.map)
113
114# Validate that STM32CubeMX code is compatible with C standard
115if((CMAKE_C_STANDARD EQUAL 90) OR (CMAKE_C_STANDARD EQUAL 99))
116 message(ERROR "Generated code requires C11 or higher")
117endif()
Note: See TracBrowser for help on using the repository browser.