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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
|
From d49e5ea2988b2086c7deaa40d3e077531e449844 Mon Sep 17 00:00:00 2001
From: Xue Liu <liuxuenetmail@gmail.com>
Date: Thu, 21 Feb 2019 00:27:42 +0100
Subject: [PATCH 1/3] - add cmake support
Signed-off-by: Xue Liu <liuxuenetmail@gmail.com>
---
CMakeLists.txt | 77 +++++++++++++++
cmake/loragw-config.cmake | 1 +
libloragw/CMakeLists.txt | 150 ++++++++++++++++++++++++++++++
libloragw/loragw.pc.in | 10 ++
libloragw/loragw_config.h.in | 14 +++
util_lbt_test/CMakeLists.txt | 23 +++++
util_pkt_logger/CMakeLists.txt | 29 ++++++
util_spectral_scan/CMakeLists.txt | 23 +++++
util_spi_stress/CMakeLists.txt | 23 +++++
util_tx_continuous/CMakeLists.txt | 23 +++++
util_tx_test/CMakeLists.txt | 23 +++++
11 files changed, 396 insertions(+)
create mode 100644 CMakeLists.txt
create mode 100644 cmake/loragw-config.cmake
create mode 100644 libloragw/CMakeLists.txt
create mode 100644 libloragw/loragw.pc.in
create mode 100644 libloragw/loragw_config.h.in
create mode 100644 util_lbt_test/CMakeLists.txt
create mode 100644 util_pkt_logger/CMakeLists.txt
create mode 100644 util_spectral_scan/CMakeLists.txt
create mode 100644 util_spi_stress/CMakeLists.txt
create mode 100644 util_tx_continuous/CMakeLists.txt
create mode 100644 util_tx_test/CMakeLists.txt
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,77 @@
+# -- Minimum required version
+cmake_minimum_required (VERSION 3.2)
+
+# -- Project name
+project (lora_gateway)
+
+# -- Various includes
+include (CMakePackageConfigHelpers)
+include (GNUInstallDirs)
+include (CheckFunctionExists)
+
+# -- set c99 standard default
+set(CMAKE_C_STANDARD 99)
+
+# -- options for shared lib (defaults off)
+option(lora_gateway_build_shared_libs "build as a shared library" OFF)
+set(BUILD_SHARED_LIBS ${lora_gateway_build_shared_libs})
+
+# -- Required to build
+set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
+set(THREADS_PREFER_PTHREAD_FLAG TRUE)
+find_package(Threads REQUIRED)
+
+# -- Versioning with git tag
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
+ execute_process(
+ COMMAND git describe --tags --always
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ OUTPUT_VARIABLE "lora_gateway_VERSION"
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(lora_gateway_VERSION STREQUAL "")
+ set(lora_gateway_VERSION 0)
+ endif(lora_gateway_VERSION STREQUAL "")
+ message( STATUS "Git full version: ${lora_gateway_VERSION}" )
+ execute_process(
+ COMMAND /bin/bash -c "git describe --tags --abbrev=0 | cut --delimiter='v' --fields=2"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ OUTPUT_VARIABLE "lora_gateway_VERSION_SHORT"
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(lora_gateway_VERSION_SHORT STREQUAL "")
+ set(lora_gateway_VERSION_SHORT 0)
+ endif(lora_gateway_VERSION_SHORT STREQUAL "")
+ message( STATUS "Git version: ${lora_gateway_VERSION_SHORT}" )
+else(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
+ set(lora_gateway_VERSION_SHORT 0)
+ set(lora_gateway_VERSION 0)
+endif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
+
+# when building, don't use the install RPATH already
+# (but later on when installing)
+SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
+if (NOT (${CMAKE_INSTALL_PREFIX} STREQUAL "/usr" ) )
+ SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
+endif()
+
+# -- add the core library
+add_subdirectory(libloragw)
+
+# -- add util_lbt_test
+add_subdirectory(util_lbt_test)
+
+# -- add util_pkt_logger
+add_subdirectory(util_pkt_logger)
+
+# -- add util_pkt_logger
+add_subdirectory(util_spectral_scan)
+
+# -- add util_spi_stress
+add_subdirectory(util_spi_stress)
+
+# -- add util_tx_continuous
+add_subdirectory(util_tx_continuous)
+
+# -- add util_tx_test
+add_subdirectory(util_tx_test)
--- /dev/null
+++ b/cmake/loragw-config.cmake
@@ -0,0 +1 @@
+include("${CMAKE_CURRENT_LIST_DIR}/loragw-targets.cmake")
--- /dev/null
+++ b/libloragw/CMakeLists.txt
@@ -0,0 +1,150 @@
+set(TARGET loragw)
+
+add_library(${TARGET} "")
+
+# -- add additional debug options
+# Set the DEBUG_* to 1 to activate debug mode in individual modules.
+# Warning: that makes the module *very verbose*, do not use for production
+option(DEBUG_AUX "Active debug mode in AUX module" OFF)
+option(DEBUG_SPI "Active debug mode in SPI module" OFF)
+option(DEBUG_REG "Active debug mode in REG module" OFF)
+option(DEBUG_HAL "Active debug mode in HAL module" OFF)
+option(DEBUG_GPIO "Active debug mode in GPIO module" OFF)
+option(DEBUG_LBT "Active debug mode in LBT module" OFF)
+option(DEBUG_GPS "Active debug mode in GPS module" OFF)
+
+message("-- Build with debug AUX: ${DEBUG_AUX}")
+message("-- Build with debug SPI: ${DEBUG_SPI}")
+message("-- Build with debug REG: ${DEBUG_REG}")
+message("-- Build with debug HAL: ${DEBUG_HAL}")
+message("-- Build with debug GPIO: ${DEBUG_GPIO}")
+message("-- Build with debug LBT: ${DEBUG_LBT}")
+message("-- Build with debug GPS: ${DEBUG_GPS}")
+
+# -- add the compile options
+target_compile_options(
+ ${TARGET}
+ PRIVATE
+ -Werror
+ -Wall
+ -Wextra
+)
+
+target_sources(${TARGET}
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/src/loragw_aux.c
+ ${CMAKE_CURRENT_LIST_DIR}/src/loragw_fpga.c
+ ${CMAKE_CURRENT_LIST_DIR}/src/loragw_gps.c
+ ${CMAKE_CURRENT_LIST_DIR}/src/loragw_hal.c
+ ${CMAKE_CURRENT_LIST_DIR}/src/loragw_lbt.c
+ ${CMAKE_CURRENT_LIST_DIR}/src/loragw_radio.c
+ ${CMAKE_CURRENT_LIST_DIR}/src/loragw_reg.c
+ ${CMAKE_CURRENT_LIST_DIR}/src/loragw_spi.native.c
+)
+
+# -- add the public headers
+set (${TARGET}_PUBLIC_HEADERS
+ ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_aux.h
+ ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_fpga.h
+ ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_gps.h
+ ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_hal.h
+ ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_lbt.h
+ ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_radio.h
+ ${CMAKE_CURRENT_LIST_DIR}/inc/loragw_reg.h
+)
+
+target_include_directories(${TARGET}
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}
+ ${CMAKE_CURRENT_LIST_DIR}/inc
+ PUBLIC
+ $<INSTALL_INTERFACE:include>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
+)
+
+configure_file(${CMAKE_CURRENT_LIST_DIR}/${TARGET}_config.h.in "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY)
+
+target_link_libraries(${TARGET}
+ PUBLIC
+ Threads::Threads
+ m
+)
+
+set_target_properties(${TARGET} PROPERTIES VERSION ${lora_gateway_VERSION_SHORT})
+set_target_properties(${TARGET} PROPERTIES SOVERSION ${lora_gateway_VERSION_SHORT})
+set_target_properties(${TARGET} PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_BINARY_DIR}/config.h;${${TARGET}_PUBLIC_HEADERS}")
+
+# -- add the install targets
+install (TARGETS ${TARGET}
+ EXPORT ${TARGET}_targets
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${TARGET}
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${TARGET}
+)
+
+# -- add pkg config file
+configure_file ("${CMAKE_CURRENT_LIST_DIR}/${TARGET}.pc.in" "${PROJECT_BINARY_DIR}/${TARGET}.pc" @ONLY)
+install (FILES ${PROJECT_BINARY_DIR}/${TARGET}.pc DESTINATION lib/pkgconfig)
+
+# -- write cmake package config file
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${TARGET}-config-version.cmake"
+ VERSION ${lora_gateway_VERSION}
+ COMPATIBILITY AnyNewerVersion
+)
+
+export(EXPORT ${TARGET}_targets
+ FILE "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${TARGET}-targets.cmake"
+ NAMESPACE Semtech::
+)
+
+configure_file(${PROJECT_SOURCE_DIR}/cmake/${TARGET}-config.cmake
+ "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${TARGET}-config.cmake"
+ COPYONLY
+)
+
+set(ConfigPackageLocation lib/cmake/${TARGET})
+
+install(EXPORT ${TARGET}_targets
+ FILE ${TARGET}-targets.cmake
+ NAMESPACE Semtech::
+ DESTINATION ${ConfigPackageLocation}
+)
+
+install(
+ FILES ${PROJECT_SOURCE_DIR}/cmake/${TARGET}-config.cmake "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}/${TARGET}-config-version.cmake"
+ DESTINATION ${ConfigPackageLocation}
+ COMPONENT Devel
+)
+
+# -- add test programs
+foreach(TEST test_loragw_spi test_loragw_gps test_loragw_reg test_loragw_hal test_loragw_cal)
+ add_executable(${TEST} "")
+
+ target_sources(${TEST}
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/tst/${TEST}.c
+ )
+
+ target_include_directories(${TEST}
+ PRIVATE
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+ $<INSTALL_INTERFACE:include>
+ ${CMAKE_CURRENT_LIST_DIR}/inc
+ ${CMAKE_CURRENT_BINARY_DIR}
+ )
+
+ target_link_libraries(${TEST}
+ PRIVATE
+ loragw
+ )
+
+ install (
+ TARGETS ${TEST}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ )
+
+endforeach()
+
--- /dev/null
+++ b/libloragw/loragw.pc.in
@@ -0,0 +1,10 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=${prefix}/bin
+includedir=${prefix}/include/libloragw
+libdir=${prefix}/lib
+
+Name: LIBLORAGW
+Description: BLANK_TEXT
+Version: @lora_gateway_VERSION@
+Cflags: -I${includedir}
+Libs: -L${libdir} -lloragw
--- /dev/null
+++ b/libloragw/loragw_config.h.in
@@ -0,0 +1,14 @@
+#ifndef _LORAGW_CONFIGURATION_H
+#define _LORAGW_CONFIGURATION_H
+
+#define LIBLORAGW_VERSION "@lora_gateway_VERSION_SHORT@"
+
+#cmakedefine01 DEBUG_AUX
+#cmakedefine01 DEBUG_SPI
+#cmakedefine01 DEBUG_REG
+#cmakedefine01 DEBUG_HAL
+#cmakedefine01 DEBUG_GPS
+#cmakedefine01 DEBUG_GPIO
+#cmakedefine01 DEBUG_LBT
+
+#endif
--- /dev/null
+++ b/util_lbt_test/CMakeLists.txt
@@ -0,0 +1,23 @@
+
+add_executable(util_lbt_test "")
+target_sources(util_lbt_test
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/src/util_lbt_test.c
+)
+
+target_link_libraries(util_lbt_test
+ PUBLIC
+ loragw
+)
+
+set_target_properties(util_lbt_test PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+)
+
+# add the install targets
+install (
+ TARGETS util_lbt_test
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+)
--- /dev/null
+++ b/util_pkt_logger/CMakeLists.txt
@@ -0,0 +1,29 @@
+
+add_executable(util_pkt_logger "")
+target_sources(util_pkt_logger
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/src/util_pkt_logger.c
+ ${CMAKE_CURRENT_LIST_DIR}/src/parson.c
+)
+
+target_include_directories(util_pkt_logger
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/inc
+)
+
+target_link_libraries(util_pkt_logger
+ PUBLIC
+ loragw
+)
+
+set_target_properties(util_pkt_logger PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+)
+
+# add the install targets
+install (
+ TARGETS util_pkt_logger
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+)
--- /dev/null
+++ b/util_spectral_scan/CMakeLists.txt
@@ -0,0 +1,23 @@
+
+add_executable(util_spectral_scan "")
+target_sources(util_spectral_scan
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/src/util_spectral_scan.c
+)
+
+target_link_libraries(util_spectral_scan
+ PUBLIC
+ loragw
+)
+
+set_target_properties(util_spectral_scan PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+)
+
+# add the install targets
+install (
+ TARGETS util_spectral_scan
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+)
--- /dev/null
+++ b/util_spi_stress/CMakeLists.txt
@@ -0,0 +1,23 @@
+
+add_executable(util_spi_stress "")
+target_sources(util_spi_stress
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/src/util_spi_stress.c
+)
+
+target_link_libraries(util_spi_stress
+ PUBLIC
+ loragw
+)
+
+set_target_properties(util_spi_stress PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+)
+
+# add the install targets
+install (
+ TARGETS util_spi_stress
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+)
--- /dev/null
+++ b/util_tx_continuous/CMakeLists.txt
@@ -0,0 +1,23 @@
+
+add_executable(util_tx_continuous "")
+target_sources(util_tx_continuous
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/src/util_tx_continuous.c
+)
+
+target_link_libraries(util_tx_continuous
+ PUBLIC
+ loragw
+)
+
+set_target_properties(util_tx_continuous PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+)
+
+# add the install targets
+install (
+ TARGETS util_tx_continuous
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+)
--- /dev/null
+++ b/util_tx_test/CMakeLists.txt
@@ -0,0 +1,23 @@
+
+add_executable(util_tx_test "")
+target_sources(util_tx_test
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/src/util_tx_test.c
+)
+
+target_link_libraries(util_tx_test
+ PUBLIC
+ loragw
+)
+
+set_target_properties(util_tx_test PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+)
+
+# add the install targets
+install (
+ TARGETS util_tx_test
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+)
|