-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
119 lines (106 loc) · 4.14 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
cmake_minimum_required(VERSION 3.28)
message("Entering ${CMAKE_CURRENT_LIST_FILE}")
set(PROJECT_TYPE_EXECUTABLE "exe")
set(PROJECT_TYPE_STATIC_LIBRARY "static-lib")
set(PROJECT_NAME "STM32-VSCode-CMake-streamlined")
set(PROJECT_TYPE "exe")
set(LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/STM32L4A6ZGTX_FLASH.ld")
set(MCPU "-mcpu=cortex-m4")
set(MFPU "-mfpu=fpv4-sp-d16")
set(MFLOAT_ABI "-mfloat-abi=hard")
set(RUNTIME_LIBRARY "--specs=nano.specs")
set(RUNTIME_LIBRARY_SYSCALLS "--specs=nosys.specs")
set(PROJECT_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/main.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/gpio.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/stm32l4xx_hal_msp.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/stm32l4xx_it.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/syscalls.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/sysmem.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Src/system_stm32l4xx.c
${CMAKE_CURRENT_SOURCE_DIR}/Core/Startup/startup_stm32l4a6zgtx.s
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c
${CMAKE_CURRENT_SOURCE_DIR}/Application/main.cpp
)
set(PROJECT_INCLUDES
${CMAKE_CURRENT_SOURCE_DIR}/Core/Inc
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32L4xx_HAL_Driver/Inc
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32L4xx_HAL_Driver/Inc/Legacy
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/CMSIS/Device/ST/STM32L4xx/Include
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/CMSIS/Include
${CMAKE_CURRENT_SOURCE_DIR}/Application
)
set(PROJECT_DEFINES
DEBUG
STM32L4A6xx
USE_HAL_DRIVER
)
project(${PROJECT_NAME})
enable_language(C CXX ASM)
set(CMAKE_EXECUTABLE_SUFFIX ".elf")
set(CMAKE_STATIC_LIBRARY_SUFFIX ".a")
add_executable(${PROJECT_NAME} ${PROJECT_SOURCES})
add_compile_definitions(${PROJECT_DEFINES})
include_directories(${PROJECT_INCLUDES})
target_compile_options(${PROJECT_NAME} PRIVATE
-mthumb
-mcpu=cortex-m4
-mfpu=fpv4-sp-d16
-mfloat-abi=hard
$<$<COMPILE_LANGUAGE:C>:
-std=gnu18
-g3
-O0
-ffunction-sections
-fdata-sections
-Wall
-fstack-usage
--specs=nano.specs
>
$<$<COMPILE_LANGUAGE:CXX>:
-std=c++20
-g3
-O0
-ffunction-sections
-fdata-sections
-fno-exceptions
-fno-rtti
-fno-use-cxa-atexit
-Wall
-fstack-usage
--specs=nano.specs
>
$<$<COMPILE_LANGUAGE:ASM>:
-g3
-c
-x
assembler-with-cpp
--specs=nano.specs
>
)
target_link_options(${PROJECT_NAME} PRIVATE
-T${LINKER_SCRIPT}
-mthumb
-mcpu=cortex-m4
-mfpu=fpv4-sp-d16
-mfloat-abi=hard
--specs=nano.specs
--specs=nosys.specs
-Wl,-Map=${CMAKE_PROJECT_NAME}.map
-Wl,--gc-sections -static
-Wl,--start-group -lc -lm -Wl,--end-group
)