-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists_appl.txt
101 lines (77 loc) · 3.03 KB
/
CMakeLists_appl.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
# Copyright (c) 2017, Franz Hollerer.
# SPDX-License-Identifier: MIT
# -------------------------------------------- minimum cmake version ---
# We tested the build with cmake 3.5, but it probably also works with
# older versions.
cmake_minimum_required(VERSION 3.5)
# ------------------------------------------ build process debugging ---
set(CMAKE_VERBOSE_MAKEFILE false)
# ---------------------------------------- project specific settings ---
set(TARGET_NAME "project_template_appl")
set(CMAKE_SOURCE_DIR "${PROJECT_ROOT_DIR}/appl")
set(HODEA_ROOT_DIR "${PROJECT_ROOT_DIR}/hodea-lib")
set(CMSIS_ROOT_DIR "${PROJECT_ROOT_DIR}/hodea-stm32f0-vpkg/CMSIS")
add_executable(${TARGET_NAME}
"${CMAKE_SOURCE_DIR}/main.cpp"
"${CMAKE_SOURCE_DIR}/system_stm32f0xx.cpp"
"${CMAKE_SOURCE_DIR}/gcc/startup_stm32f091xc.s"
"${CMAKE_SOURCE_DIR}/gcc/bootloader_binary.s"
"${CMAKE_SOURCE_DIR}/../share/boot_appl_if.cpp"
"${HODEA_ROOT_DIR}/hodea/device/stm32/retarget_stdout_uart.cpp"
"${HODEA_ROOT_DIR}/hodea/rte/setup.cpp"
)
target_include_directories(${TARGET_NAME} PRIVATE
"${CMAKE_SOURCE_DIR}"
"${HODEA_ROOT_DIR}"
"${CMSIS_ROOT_DIR}/Include"
"${CMSIS_ROOT_DIR}/Device/ST/STM32F0xx/Include"
)
add_definitions(-DSTM32F091xC)
# ------------------------------------------------ compiler settings ---
set(CMAKE_SYSTEM_NAME Generic)
set(TARGET_TRIPLET "arm-none-eabi")
set(CMAKE_ASM_COMPILER "${TARGET_TRIPLET}-gcc")
set(CMAKE_C_COMPILER "${TARGET_TRIPLET}-gcc")
set(CMAKE_CXX_COMPILER "${TARGET_TRIPLET}-g++")
set(CMAKE_OBJCOPY "${TARGET_TRIPLET}-objcopy")
enable_language(ASM)
set(CMAKE_EXECUTABLE_SUFFIX ".elf")
set(CMAKE_C_FLAGS_DEBUG "-O0")
set(CMAKE_C_FLAGS_RELEASE "-O3")
set(CMAKE_CXX_FLAGS_DEBUG "-O0")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_C_FLAGS "\
-g -Wall -Wextra -ffreestanding -ffunction-sections -fdata-sections \
-fno-common -mcpu=cortex-m0 -mthumb -std=c11 \
-fno-rtti -fno-exceptions"
)
set(CMAKE_CXX_FLAGS "\
-g -Wall -Wextra -ffreestanding -ffunction-sections -fdata-sections \
-fno-common -mcpu=cortex-m0 -mthumb -std=c++11 \
-fno-rtti -fno-exceptions"
)
set(CMAKE_ASM_FLAGS ${CMAKE_C_FLAGS})
set(CMAKE_EXE_LINKER_FLAGS "\
--specs=nosys.specs --specs=nano.specs -Xlinker --gc-sections \
-T${CMAKE_SOURCE_DIR}/gcc/stm32f091rc_appl.ld \
-Xlinker -Map=${TARGET_NAME}.map"
)
# workaround to expand __FILE__ to the file's basename instead of the
# file name with absolute path.
set(CMAKE_C_FLAGS "\
${CMAKE_C_FLAGS} \
-Wno-builtin-macro-redefined \
-D__FILE__='\"$(shell basename $<)\"'"
)
set(CMAKE_CXX_FLAGS "\
${CMAKE_CXX_FLAGS} \
-Wno-builtin-macro-redefined \
-D__FILE__='\"$(shell basename $<)\"'"
)
# ----------------------------------------------- .bin and .hex file ---
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD COMMAND
${CMAKE_OBJCOPY} -Obinary ${TARGET_NAME}.elf ${TARGET_NAME}.bin
)
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD COMMAND
${CMAKE_OBJCOPY} -Oihex ${TARGET_NAME}.elf ${TARGET_NAME}.hex
)