-
Notifications
You must be signed in to change notification settings - Fork 22
/
CMakeLists.txt
175 lines (161 loc) · 4.63 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
# openchronos-ng-elf project
#
# Copyright (C) 2016 Benjamin Sølberg <[email protected]>
# Copyright (C) 2017 Alexandre Pretyman <[email protected]>
#
# http://github.com/BenjaminSoelberg/openchronos-ng-elf
#
# This file is part of openchronos-ng.
#
# openchronos-ng is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# openchronos-ng is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.2)
project(openchronos-ng-elf C)
set(openchronos_binary_filename "openchronos.elf")
set(module_config_files
${CMAKE_CURRENT_SOURCE_DIR}/config.h
${CMAKE_CURRENT_SOURCE_DIR}/modinit.c
)
set(rtca_header ${CMAKE_CURRENT_SOURCE_DIR}/drivers/rtca_now.h)
set(source_files
${rtca_header}
${module_config_files}
messagebus.c
openchronos.c
boot.c
menu.c
drivers/lpm.c
drivers/battery.c
drivers/vti_as.c
drivers/infomem.c
drivers/buzzer.c
drivers/display.c
drivers/temperature.c
drivers/rtca.c
drivers/rtc_dst.c
drivers/ports.c
drivers/dsp.c
drivers/radio.c
drivers/vti_ps.c
drivers/adc12.c
drivers/timer.c
drivers/pmm.c
drivers/rf1a.c
drivers/wdt.c
modules/battery.c
modules/alarm.c
modules/music.c
modules/reset.c
modules/tide.c
modules/temperature.c
modules/clock.c
modules/hashutils.c
modules/otp.c
modules/stopwatch.c
modules/accelerometer.c
modules/buzztest.c
)
add_executable(${openchronos_binary_filename} ${source_files})
target_include_directories(${openchronos_binary_filename} PRIVATE .)
find_package(PythonInterp)
if(NOT PYTHONINTERP_FOUND)
message(WARNING "Python interpreter not found - Python tools disabled")
else()
# explicit config target
add_custom_target(config
COMMAND
${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_LIST_DIR}/tools/config.py
COMMAND
${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_LIST_DIR}/tools/make_modinit.py
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
USES_TERMINAL
)
# this will make config.py and make_modinit.py run when trying to compile
# and there is no config.h and modinit.c
add_custom_command(
OUTPUT ${module_config_files}
COMMAND
${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_LIST_DIR}/tools/config.py
COMMAND
${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_LIST_DIR}/tools/make_modinit.py
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
set(openchronos_hex_filename "openchronos.txt")
add_custom_command(
OUTPUT
${openchronos_hex_filename}
COMMAND
${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_LIST_DIR}/tools/memory.py
-i ${openchronos_binary_filename}
-o ${openchronos_hex_filename}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
DEPENDS
${openchronos_binary_filename}
)
add_custom_target(
radio-install
COMMAND
${PYTHON_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/contrib/ChronosTool.py
rfbsl ${openchronos_hex_filename}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
DEPENDS
${openchronos_hex_filename}
)
endif()
add_custom_command(
OUTPUT "${rtca_header}"
COMMAND
bash tools/update_rtca_now.sh
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
find_program(mspdebug_executable "mspdebug")
if(NOT mspdebug_executable)
message(WARNING
"mspdebug not found: targets usb-install and usb-debug disabled"
)
else()
add_custom_target(usb-install
COMMAND
${mspdebug_executable} rf2500 "prog ${openchronos_binary_filename}"
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS
${openchronos_binary_filename}
)
add_custom_target(usb-debug
COMMAND
${mspdebug_executable} rf2500 "gdb"
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS
${openchronos_binary_filename}
)
endif()
find_package(Doxygen)
if(NOT DOXYGEN_FOUND)
message(WARNING "Doxygen not found: target doc disabled")
else()
add_custom_target(
doc
COMMAND
${DOXYGEN_EXECUTABLE} Doxyfile
WORKING_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}
)
endif()