-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
93 lines (70 loc) · 2.27 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
cmake_minimum_required(VERSION 3.22)
#
# This file is generated only once,
# and is not re-generated if converter is called multiple times.
#
# User is free to modify the file as much as necessary
#
# Setup compiler settings
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Define the build type
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif ()
# Set the project name
set(CMAKE_PROJECT_NAME template)
# Include toolchain file
include("cmake/gcc-arm-none-eabi.cmake")
# Enable compile command to ease indexing with e.g. clangd
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
# Core project settings
project(${CMAKE_PROJECT_NAME} C CXX ASM)
message("Build type: " ${CMAKE_BUILD_TYPE})
# Create an executable object type
add_executable(${CMAKE_PROJECT_NAME})
add_custom_target(ci DEPENDS ${CMAKE_PROJECT_NAME}) # for CI build testing
# Add STM32CubeMX generated sources
add_subdirectory(cmake/stm32cubemx)
add_subdirectory(${CMAKE_SOURCE_DIR}/libs)
add_subdirectory(${CMAKE_SOURCE_DIR}/src)
# Link directories setup
target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE
# Add user defined library search paths
)
# Add sources to executable
target_sources(${CMAKE_PROJECT_NAME} PRIVATE
# Add user sources here
)
# Add include paths
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
# Add user defined include paths
)
# Add project symbols (macros)
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE
# Add user defined symbols
)
# Add linked libraries
target_link_libraries(${CMAKE_PROJECT_NAME}
stm32cubemx
# Add user defined libraries
${PROJECT_NAME}_libs
)
# # Convert ELF to BIN for flashing
# add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
# COMMAND ${CMAKE_OBJCOPY} -O binary ${CMAKE_PROJECT_NAME}.elf ${CMAKE_PROJECT_NAME}.bin
# DEPENDS ${CMAKE_PROJECT_NAME}
# COMMENT "Converting ELF to BIN"
# )
# Add openocd functions
include(${CMAKE_SOURCE_DIR}/openocd/flash-target.cmake)
# 调用 add_erase_and_reset 函数
add_erase_and_reset()
# 调用 flash_target 函数
flash_target()
# enable irobotEC
set(IROBOTEC_PLATFORM STM32)
add_subdirectory(${CMAKE_SOURCE_DIR}/irobotEC)
add_subdirectory(${CMAKE_SOURCE_DIR}/user)