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

Last change on this file since 76 was 76, checked in by f.jahn, 11 days ago
File size: 9.9 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_FULL_LL_DRIVER
7 USBPD_PORT_COUNT=1
8 _SRC
9 USBPDCORE_LIB_PD3_FULL
10 USE_HAL_DRIVER
11 STM32G473xx
12 $<$<CONFIG:Debug>:DEBUG>
13)
14
15# STM32CubeMX generated include paths
16set(MX_Include_Dirs
17 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Inc
18 ${CMAKE_CURRENT_SOURCE_DIR}/../../USBPD/App
19 ${CMAKE_CURRENT_SOURCE_DIR}/../../USBPD/Target
20 ${CMAKE_CURRENT_SOURCE_DIR}/../../USBPD
21 ${CMAKE_CURRENT_SOURCE_DIR}/../../USB_Device/App
22 ${CMAKE_CURRENT_SOURCE_DIR}/../../USB_Device/Target
23 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Inc
24 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Inc/Legacy
25 ${CMAKE_CURRENT_SOURCE_DIR}/../../Middlewares/ST/STM32_USBPD_Library/Core/inc
26 ${CMAKE_CURRENT_SOURCE_DIR}/../../Middlewares/ST/STM32_USBPD_Library/Devices/STM32G4XX/inc
27 ${CMAKE_CURRENT_SOURCE_DIR}/../../Middlewares/ST/STM32_USB_Device_Library/Core/Inc
28 ${CMAKE_CURRENT_SOURCE_DIR}/../../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc
29 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/CMSIS/Device/ST/STM32G4xx/Include
30 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/CMSIS/Include
31)
32
33# STM32CubeMX generated application sources
34set(MX_Application_Src
35 ${CMAKE_CURRENT_SOURCE_DIR}/../../USBPD/App/usbpd.c
36 ${CMAKE_CURRENT_SOURCE_DIR}/../../USBPD/App/usbpd_pwr_if.c
37 ${CMAKE_CURRENT_SOURCE_DIR}/../../USBPD/App/usbpd_dpm_core.c
38 ${CMAKE_CURRENT_SOURCE_DIR}/../../USBPD/Target/usbpd_dpm_user.c
39 ${CMAKE_CURRENT_SOURCE_DIR}/../../USBPD/Target/usbpd_pwr_user.c
40 ${CMAKE_CURRENT_SOURCE_DIR}/../../USBPD/Target/usbpd_vdm_user.c
41 ${CMAKE_CURRENT_SOURCE_DIR}/../../USB_Device/App/usb_device.c
42 ${CMAKE_CURRENT_SOURCE_DIR}/../../USB_Device/App/usbd_desc.c
43 ${CMAKE_CURRENT_SOURCE_DIR}/../../USB_Device/App/usbd_cdc_if.c
44 ${CMAKE_CURRENT_SOURCE_DIR}/../../USB_Device/Target/usbd_conf.c
45 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/main.c
46 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/gpio.c
47 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/adc.c
48 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/crc.c
49 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/dac.c
50 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/dma.c
51 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/i2c.c
52 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/iwdg.c
53 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/rtc.c
54 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/spi.c
55 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/tim.c
56 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/ucpd.c
57 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/usart.c
58 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/stm32g4xx_it.c
59 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/stm32g4xx_hal_msp.c
60 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/sysmem.c
61 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/syscalls.c
62 ${CMAKE_CURRENT_SOURCE_DIR}/../../startup_stm32g473xx.s
63)
64
65# STM32 HAL/LL Drivers
66set(STM32_Drivers_Src
67 ${CMAKE_CURRENT_SOURCE_DIR}/../../Core/Src/system_stm32g4xx.c
68 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_utils.c
69 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_exti.c
70 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pcd.c
71 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pcd_ex.c
72 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_usb.c
73 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c
74 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c
75 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc_ex.c
76 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash.c
77 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ex.c
78 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ramfunc.c
79 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_gpio.c
80 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_exti.c
81 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma.c
82 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma_ex.c
83 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr.c
84 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr_ex.c
85 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_cortex.c
86 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_rcc.c
87 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_pwr.c
88 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_adc.c
89 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_adc_ex.c
90 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_adc.c
91 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_crc.c
92 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_crc_ex.c
93 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dac.c
94 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dac_ex.c
95 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c.c
96 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c_ex.c
97 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_iwdg.c
98 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rtc.c
99 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rtc_ex.c
100 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_spi.c
101 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_spi_ex.c
102 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim.c
103 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim_ex.c
104 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_ucpd.c
105 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_gpio.c
106 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_dma.c
107 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart.c
108 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart_ex.c
109 ${CMAKE_CURRENT_SOURCE_DIR}/../../Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_tim.c
110)
111
112# Drivers Midllewares
113
114
115set(USB_Device_Library_Src
116 ${CMAKE_CURRENT_SOURCE_DIR}/../../Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c
117 ${CMAKE_CURRENT_SOURCE_DIR}/../../Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c
118 ${CMAKE_CURRENT_SOURCE_DIR}/../../Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c
119 ${CMAKE_CURRENT_SOURCE_DIR}/../../Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c
120)
121set(USBPD_Src
122 ${CMAKE_CURRENT_SOURCE_DIR}/../../Middlewares/ST/STM32_USBPD_Library/Core/src/usbpd_trace.c
123 ${CMAKE_CURRENT_SOURCE_DIR}/../../Middlewares/ST/STM32_USBPD_Library/Devices/STM32G4XX/src/usbpd_cad_hw_if.c
124 ${CMAKE_CURRENT_SOURCE_DIR}/../../Middlewares/ST/STM32_USBPD_Library/Devices/STM32G4XX/src/usbpd_hw.c
125 ${CMAKE_CURRENT_SOURCE_DIR}/../../Middlewares/ST/STM32_USBPD_Library/Devices/STM32G4XX/src/usbpd_hw_if_it.c
126 ${CMAKE_CURRENT_SOURCE_DIR}/../../Middlewares/ST/STM32_USBPD_Library/Devices/STM32G4XX/src/usbpd_phy.c
127 ${CMAKE_CURRENT_SOURCE_DIR}/../../Middlewares/ST/STM32_USBPD_Library/Devices/STM32G4XX/src/usbpd_phy_hw_if.c
128 ${CMAKE_CURRENT_SOURCE_DIR}/../../Middlewares/ST/STM32_USBPD_Library/Devices/STM32G4XX/src/usbpd_pwr_hw_if.c
129 ${CMAKE_CURRENT_SOURCE_DIR}/../../Middlewares/ST/STM32_USBPD_Library/Devices/STM32G4XX/src/usbpd_timersserver.c
130)
131
132# Link directories setup
133set(MX_LINK_DIRS
134
135 ${CMAKE_CURRENT_SOURCE_DIR}/../../Middlewares/ST/STM32_USBPD_Library/Core/lib
136)
137# Project static libraries
138set(MX_LINK_LIBS
139 :USBPDCORE_PD3_FULL_CM4_wc32.a
140 STM32_Drivers
141 ${TOOLCHAIN_LINK_LIBRARIES}
142 USB_Device_Library
143 USBPD
144
145)
146# Interface library for includes and symbols
147add_library(stm32cubemx INTERFACE)
148target_include_directories(stm32cubemx INTERFACE ${MX_Include_Dirs})
149target_compile_definitions(stm32cubemx INTERFACE ${MX_Defines_Syms})
150
151# Create STM32_Drivers static library
152add_library(STM32_Drivers OBJECT)
153target_sources(STM32_Drivers PRIVATE ${STM32_Drivers_Src})
154target_link_libraries(STM32_Drivers PUBLIC stm32cubemx)
155
156
157# Create USB_Device_Library static library
158add_library(USB_Device_Library OBJECT)
159target_sources(USB_Device_Library PRIVATE ${USB_Device_Library_Src})
160target_link_libraries(USB_Device_Library PUBLIC stm32cubemx)
161
162# Create USBPD static library
163add_library(USBPD OBJECT)
164target_sources(USBPD PRIVATE ${USBPD_Src})
165target_link_libraries(USBPD PUBLIC stm32cubemx)
166
167# Add STM32CubeMX generated application sources to the project
168target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${MX_Application_Src})
169
170# Link directories setup
171target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE ${MX_LINK_DIRS})
172
173# Add libraries to the project
174target_link_libraries(${CMAKE_PROJECT_NAME} ${MX_LINK_LIBS})
175
176# Add the map file to the list of files to be removed with 'clean' target
177set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES ADDITIONAL_CLEAN_FILES ${CMAKE_PROJECT_NAME}.map)
178
179# Validate that STM32CubeMX code is compatible with C standard
180if((CMAKE_C_STANDARD EQUAL 90) OR (CMAKE_C_STANDARD EQUAL 99))
181 message(ERROR "Generated code requires C11 or higher")
182endif()
Note: See TracBrowser for help on using the repository browser.