forked from DualTachyon/uv-k5-firmware
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
176 lines (142 loc) · 4.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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# Copyright 2023 Manuel Jedinger
# https://github.com/manujedi
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.25)
# Enable features
set(ENABLE_AIRCOPY 1)
set(ENABLE_ALARM 1)
set(ENABLE_FMRADIO 1)
set(ENABLE_NOAA 1)
set(ENABLE_OVERLAY 0)
set(ENABLE_SWD 1)
set(ENABLE_TX1750 1)
set(ENABLE_UART 1)
set(ENABLE_BATT_MODS 1) # Also saves space
set(ENABLE_CHANNEL_SCAN 1)
set(ENABLE_MINIMAL_SPECTRUM 1)
if (ENABLE_AIRCOPY)
add_compile_definitions(ENABLE_AIRCOPY)
endif ()
if (ENABLE_ALARM)
add_compile_definitions(ENABLE_ALARM)
endif ()
if (ENABLE_FMRADIO)
add_compile_definitions(ENABLE_FMRADIO)
endif ()
if (ENABLE_NOAA)
add_compile_definitions(ENABLE_NOAA)
endif ()
if (ENABLE_OVERLAY)
add_compile_definitions(ENABLE_OVERLAY)
endif ()
if (ENABLE_SWD)
add_compile_definitions(ENABLE_SWD)
endif ()
if (ENABLE_TX1750)
add_compile_definitions(ENABLE_TX1750)
endif ()
if (ENABLE_UART)
add_compile_definitions(ENABLE_UART)
endif ()
if (ENABLE_BATT_MODS)
add_compile_definitions(ENABLE_BATT_MODS)
endif ()
if (ENABLE_CHANNEL_SCAN)
add_compile_definitions(ENABLE_CHANNEL_SCAN)
endif ()
if (ENABLE_MINIMAL_SPECTRUM)
add_compile_definitions(ENABLE_MINIMAL_SPECTRUM)
endif ()
# specify cross compilers and tools
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_ASM_COMPILER arm-none-eabi-gcc)
set(CMAKE_AR arm-none-eabi-ar)
set(CMAKE_OBJCOPY arm-none-eabi-objcopy)
set(CMAKE_OBJDUMP arm-none-eabi-objdump)
set(CMAKE_SIZE_UTIL arm-none-eabi-size)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
# project settings
project(firmware ASM C)
set(CMAKE_C_STANDARD 11)
set(MCPU cortex-m0)
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
add_compile_options(-mcpu=${MCPU} -Wall -Werror -fno-builtin -MMD -fno-delete-null-pointer-checks)
add_compile_options(-DPRINTF_INCLUDE_CONFIG_H)
set(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/firmware.ld)
add_link_options(-mcpu=${MCPU} -nostartfiles -Wl,-T ${LINKER_SCRIPT})
add_compile_options(-DGIT_HASH=\"${GIT_HASH}\")
if ("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
add_compile_options(-Os -DNDEBUG)
MESSAGE("Min Size build")
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeDeb")
add_compile_options(-Os -g)
MESSAGE("Min Size build")
else ()
MESSAGE("Using Min Size build")
add_compile_options(-Os -g)
endif ()
add_executable(${PROJECT_NAME}.elf ${SOURCES} ${LINKER_SCRIPT})
include_directories(
${CMAKE_SOURCE_DIR}/
${CMAKE_SOURCE_DIR}/external/CMSIS_5/CMSIS/Core/Include
${CMAKE_SOURCE_DIR}/external/CMSIS_5/Device/ARM/ARMCM0/Include
)
# External
target_sources(firmware.elf PRIVATE
${CMAKE_SOURCE_DIR}/external/printf/printf.c
)
# Startup
if (ENABLE_OVERLAY)
target_sources(firmware.elf PRIVATE
${CMAKE_SOURCE_DIR}/sram-overlay.c
)
endif ()
target_sources(firmware.elf PRIVATE
${CMAKE_SOURCE_DIR}/start.S
${CMAKE_SOURCE_DIR}/init.c
)
add_subdirectory(driver)
add_subdirectory(app)
add_subdirectory(helper)
add_subdirectory(ui)
#Main
target_sources(firmware.elf PRIVATE
${CMAKE_SOURCE_DIR}/audio.c
${CMAKE_SOURCE_DIR}/bitmaps.c
${CMAKE_SOURCE_DIR}/board.c
${CMAKE_SOURCE_DIR}/dcs.c
${CMAKE_SOURCE_DIR}/font.c
${CMAKE_SOURCE_DIR}/frequencies.c
${CMAKE_SOURCE_DIR}/functions.c
${CMAKE_SOURCE_DIR}/misc.c
${CMAKE_SOURCE_DIR}/radio.c
${CMAKE_SOURCE_DIR}/scheduler.c
${CMAKE_SOURCE_DIR}/settings.c
${CMAKE_SOURCE_DIR}/version.c
${CMAKE_SOURCE_DIR}/main.c
)
set(HEX_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.hex)
set(BIN_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.bin)
add_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
COMMAND ${CMAKE_SIZE_UTIL} $<TARGET_FILE:${PROJECT_NAME}.elf>
COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${PROJECT_NAME}.elf> ${HEX_FILE}
COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${PROJECT_NAME}.elf> ${BIN_FILE}
COMMAND python3 ${CMAKE_SOURCE_DIR}/fw-pack.py ${BIN_FILE} ${GIT_HASH} ${PROJECT_NAME}.packed.bin
)