-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
132 lines (102 loc) · 3.44 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
120
121
122
123
124
125
126
127
128
129
130
131
132
cmake_minimum_required(VERSION 3.20)
set(CMAKE_TOOLCHAIN_FILE cmake/gcc-arm-none-eabi.cmake)
# Allow assembler
enable_language(ASM)
project("Unity_TEST" C CXX ASM)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(INCLUDE_DIRS_HAL_LIB
Drivers/STM32F4xx_HAL_Driver/Inc
Drivers/STM32F4xx_HAL_Driver/Inc/Legacy
Drivers/CMSIS/Device/ST/STM32F4xx/Include
Drivers/CMSIS/Include
)
set(INCLUDE_DIRS_APP
Core/Inc
Core/Src
)
set(INCLUDE_DIRS_TEST
Core/test/vbat
Core/test/unity
Core/test/unity/fixture
Core/test/unity/core
)
set(GLOBAL_DEFINES
-DDEBUG
-DUNITY_INCLUDE_CONFIG_H
-DUSE_HAL_DRIVER
-DSTM32F446xx
)
set(C_SRCS_HAL_LIB
Core/Src/utils/stm32f4xx_hal_msp.c
Core/Src/utils/stm32f4xx_it.c
Core/Src/utils/syscalls.c
Core/Src/utils/sysmem.c
Core/Src/utils/system_stm32f4xx.c
Core/Startup/startup_stm32f446retx.s
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c
)
set(C_SRCS_APP
Core/Src/main.c
Core/Src/vbat.c
Core/Src/adc.c
Core/Src/alarmSignal.c
)
set(C_SRCS_TEST
Core/test/vbat/vbat_test_runner.c
Core/test/vbat/vbat_test.c
Core/test/vbat/mock_alarmSignal.c
Core/test/vbat/mock_adc.c
Core/test/vbat/output.c
Core/test/unity/core/unity.c
Core/test/unity/fixture/unity_fixture.c
)
include(cmake/compiler_flags.cmake)
include(cmake/static-analysis_cppcheck.cmake)
include(cmake/static-analysis_clang.cmake)
include(cmake/format_clang.cmake)
add_executable(${PROJECT_NAME} ${C_SRCS_HAL_LIB} ${C_SRCS_APP})
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE ${INCLUDE_DIRS_HAL_LIB} ${INCLUDE_DIRS_APP})
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE ${GLOBAL_DEFINES})
add_custom_command(
TARGET ${PROJECT_NAME}
COMMAND ${CMAKE_SIZE} $<TARGET_FILE:${PROJECT_NAME}>
)
#generate hex file
add_custom_command(
TARGET ${PROJECT_NAME}
COMMAND ${CMAKE_OBJCOPY} -O ihex
$<TARGET_FILE:${PROJECT_NAME}> ${PROJECT_NAME}.hex
)
#generate bin file
add_custom_command(
TARGET ${PROJECT_NAME}
COMMAND ${CMAKE_OBJCOPY} -O binary
$<TARGET_FILE:${PROJECT_NAME}> ${PROJECT_NAME}.bin
)
#generate extended listing
add_custom_command(
TARGET ${PROJECT_NAME}
COMMAND ${CMAKE_OBJDUMP} -h -S
$<TARGET_FILE:${PROJECT_NAME}> > ${PROJECT_NAME}.lss
)
#generate memory dump
add_custom_command(
TARGET ${PROJECT_NAME}
COMMAND ${CMAKE_OBJDUMP} -x --syms
$<TARGET_FILE:${PROJECT_NAME}> > ${PROJECT_NAME}.dmp
)