-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
55 lines (44 loc) · 1.67 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
cmake_minimum_required(VERSION 3.13)
set(CROSS_COMPILER "/opt/gcc-arm-none-eabi-x86_64-linux/bin/arm-none-eabi-")
set(CMAKE_C_COMPILER "${CROSS_COMPILER}gcc")
set(CMAKE_CXX_COMPILER "${CROSS_COMPILER}g++")
set(ASM_COMPILER "${CROSS_COMPILER}g++")
set(CMAKE_C_COMPILER_LAUNCHER "ccache")
set(CMAKE_CXX_COMPILER_LAUNCHER "ccache")
set(CMAKE_OBJSIZE "${CROSS_COMPILER}size")
set(CMAKE_OBJCOPY "${CROSS_COMPILER}objcopy")
set(CMAKE_OBJDUMP "${CROSS_COMPILER}objdump")
set(CMAKE_C_FLAGS
"-Wall -fno-common -O0 -g -mthumb -mcpu=cortex-m4 --specs=nosys.specs"
)
set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS})
set(CMAKE_ASM_FLAGS ${CMAKE_C_FLAGS})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -T ${CMAKE_CURRENT_LIST_DIR}/drivers/linker/AT32F415xC_FLASH.ld")
project(at32-framework
LANGUAGES C ASM)
add_definitions(-DAT32F415RCT7)
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/app/src app)
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/drivers/cmsis/src cmsis)
aux_source_directory(${CMAKE_CURRENT_LIST_DIR}/drivers/at32f415/src at32f415)
include_directories(
${CMAKE_CURRENT_LIST_DIR}/app/inc
${CMAKE_CURRENT_LIST_DIR}/drivers/cmsis/inc
${CMAKE_CURRENT_LIST_DIR}/drivers/at32f415/inc
)
add_executable(
${PROJECT_NAME}.elf
${app}
${cmsis}
${at32f415}
${CMAKE_CURRENT_LIST_DIR}/drivers/startup/startup_at32f415.s
)
target_link_libraries(
${PROJECT_NAME}.elf
)
add_custom_command(
TARGET ${PROJECT_NAME}.elf
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} ARGS -Obinary ${PROJECT_NAME}.elf ${PROJECT_NAME}.bin
COMMAND ${CMAKE_OBJSIZE} ARGS ${PROJECT_NAME}.elf
COMMAND md5sum ARGS ${PROJECT_NAME}.bin
)