-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
89 lines (78 loc) · 2.85 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
cmake_minimum_required(VERSION 3.21)
# Specify the cross compiler
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR cortex-m7)
# Set paths
set(SCATTER_PATH ${CMAKE_SOURCE_DIR}/MDK-ARM/Objects/release.sct)
set(HEX_PATH ${CMAKE_SOURCE_DIR}/MDK-ARM/Objects/release.hex)
set(TOOLCHAIN_PATH C:/Tools/Keil_v5/ARM/ARMCLANG/)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PATH}bin/armclang.exe)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PATH}bin/armclang.exe)
set(CMAKE_C_COMPILER_WORKS TRUE)
set(CMAKE_CXX_COMPILER_WORKS TRUE)
set(CMAKE_C_LINK_EXECUTABLE ${TOOLCHAIN_PATH}bin/armlink.exe)
set(CMAKE_CXX_LINK_EXECUTABLE ${TOOLCHAIN_PATH}bin/armlink.exe)
set(CMAKE_ASM_LINK_EXECUTABLE ${TOOLCHAIN_PATH}bin/armlink.exe)
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(DBG_FLAGS "-O1")
elseif(CMAKE_BUILD_TYPE MATCHES Release)
set(DBG_FLAGS "-O3")
elseif(CMAKE_BUILD_TYPE MATCHES MinSizeRel)
set(DBG_FLAGS "-Oz")
elseif(CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
set(DBG_FLAGS "-Ofast")
endif()
# Set flags
set(FPU_FLAGS "-mfpu=fpv5-d16 -mfloat-abi=hard")
set(COMMON_FLAGS "--target=arm-arm-none-eabi -mcpu=${CMAKE_SYSTEM_PROCESSOR} ${FPU_FLAGS}")
set(CMAKE_C_FLAGS " ${COMMON_FLAGS} ${DBG_FLAGS} -std=c99 -Wall -fno-rtti -c -ffunction-sections -gdwarf-4")
set(CMAKE_CXX_FLAGS " ${COMMON_FLAGS} ${DBG_FLAGS} -std=c++11 -Wall -fno-rtti -c -ffunction-sections -gdwarf-4")
set(CMAKE_ASM_FLAGS " ${COMMON_FLAGS} -masm=auto -c -gdwarf-3")
set(CMAKE_EXE_LINKER_FLAGS "
--cpu Cortex-M7.fp.dp \
--strict --scatter ${SCATTER_PATH} \
--summary_stderr --info summarysizes \
--map --load_addr_map_info --xref --callgraph --symbols \
--info sizes --info totals --info unused --info veneers \
"
)
enable_language(ASM)
# Configure the project
project(STM32V7 C ASM)
add_definitions(
-DSTM32H743xx
)
include_directories(
${TOOLCHAIN_PATH}include
${TOOLCHAIN_PATH}include/arm_linux
${TOOLCHAIN_PATH}include/arm_linux_compat
${TOOLCHAIN_PATH}include/libcxx
Core/Inc
Drivers/STM32H7xx_HAL_Driver/Inc
Drivers/CMSIS/Device/ST/STM32H7xx/Include
Drivers/CMSIS/Include
Components/CMSIS-RTOS2/RTX/Include
Components/CMSIS-RTOS2/RTX/Source
Components/CMSIS-RTOS2/Include
Components/CMSIS-RTOS2/RTX/Config
Components/BSP
Components/Devices/TFTLCD
Components/Devices/Stepmotor
)
file(GLOB_RECURSE SOURCES
MDK-ARM/startup_*.s
Core/Src/*.c
Drivers/STM32*_Driver/Src/*.c
Components/CMSIS-RTOS2/RTX/Source/GCC/irq_armv7m.S
Components/CMSIS-RTOS2/RTX/Source/*.c
Components/CMSIS-RTOS2/Source/os_systick.c
Components/CMSIS-RTOS2/RTX/Config/RTX_Config.c
Components/BSP/*.c
Components/Devices/TFTLCD/tftlcd.c
Components/Devices/Stepmotor/stepmotor.c
)
add_executable(release ${SOURCES})
# Generate binary file
add_custom_command(TARGET release POST_BUILD
COMMAND ${TOOLCHAIN_PATH}bin/fromelf.exe --i32 -o ${HEX_PATH} release.elf
)