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

Last change on this file was 20, checked in by f.jahn, 4 days ago

adc dma funktioniert und modbus funktioniert

File size: 5.4 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/spi.c
30    ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/usart.c
31    ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/usb.c
32    ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/stm32g4xx_it.c
33    ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/stm32g4xx_hal_msp.c
34    ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/sysmem.c
35    ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/syscalls.c
36    ${CMAKE_CURRENT_SOURCE_DIR}/../../startup_stm32g473xx.s
37)
38
39# STM32 HAL/LL Drivers
40set(STM32_Drivers_Src
41    ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/system_stm32g4xx.c
42    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_adc.c
43    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_adc_ex.c
44    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_adc.c
45    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c
46    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c
47    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc_ex.c
48    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash.c
49    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ex.c
50    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ramfunc.c
51    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_gpio.c
52    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_exti.c
53    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma.c
54    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma_ex.c
55    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr.c
56    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr_ex.c
57    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_cortex.c
58    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_crc.c
59    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_crc_ex.c
60    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_fdcan.c
61    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c.c
62    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c_ex.c
63    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_spi.c
64    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_spi_ex.c
65    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart.c
66    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart_ex.c
67    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pcd.c
68    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pcd_ex.c
69    ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_usb.c
70)
71
72# Drivers Midllewares
73
74
75
76# Link directories setup
77set(MX_LINK_DIRS
78
79)
80# Project static libraries
81set(MX_LINK_LIBS
82    STM32_Drivers
83    ${TOOLCHAIN_LINK_LIBRARIES}
84   
85)
86# Interface library for includes and symbols
87add_library(stm32cubemx INTERFACE)
88target_include_directories(stm32cubemx INTERFACE ${MX_Include_Dirs})
89target_compile_definitions(stm32cubemx INTERFACE ${MX_Defines_Syms})
90
91# Create STM32_Drivers static library
92add_library(STM32_Drivers OBJECT)
93target_sources(STM32_Drivers PRIVATE ${STM32_Drivers_Src})
94target_link_libraries(STM32_Drivers PUBLIC stm32cubemx)
95
96
97# Add STM32CubeMX generated application sources to the project
98target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${MX_Application_Src})
99
100# Link directories setup
101target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE ${MX_LINK_DIRS})
102
103# Add libraries to the project
104target_link_libraries(${CMAKE_PROJECT_NAME} ${MX_LINK_LIBS})
105
106# Add the map file to the list of files to be removed with 'clean' target
107set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES ADDITIONAL_CLEAN_FILES ${CMAKE_PROJECT_NAME}.map)
108
109# Validate that STM32CubeMX code is compatible with C standard
110if((CMAKE_C_STANDARD EQUAL 90) OR (CMAKE_C_STANDARD EQUAL 99))
111    message(ERROR "Generated code requires C11 or higher")
112endif()
Note: See TracBrowser for help on using the repository browser.