forked from JvanKatwijk/channel-scanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·466 lines (399 loc) · 13 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
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
461
462
463
464
465
466
cmake_minimum_required( VERSION 2.8.11 )
set (objectName dab_channelScanner)
#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -flto")
#set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -g")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -g")
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX "/usr/local/bin" CACHE PATH "default install path" FORCE )
endif()
#set (CMAKE_INSTALL_PREFIX /usr/local/bin)
if(MINGW)
add_definitions ( -municode)
endif()
########################################################################
# select the release build type by default to get optimization flags
########################################################################
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
message(STATUS "Build type not specified: defaulting to release.")
endif(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "")
### make sure our local CMake Modules path comes first
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules)
######################################################################
#
########################################################################
OPTION(SDRPLAY "Input: SDRPLAY" OFF)
OPTION(PLUTO "Input: PLUTO" OFF)
OPTION(PLUTO "Input: RTLSDR" OFF)
OPTION(AIRSPY "Input: AIRSPY" OFF)
OPTION(HACKRF "Input: HACKRF" OFF)
OPTION(LIMESDR "Input: LIMESDR" OFF)
OPTION(X64_DEFINED "optimize for x64/SSE" OFF)
OPTION(RPI_DEFINED "optimize for ARM/NEON" OFF)
if ( (NOT SDRPLAY) AND (NOT PLUTO) AND (NOT RTLSDR) AND (NOT AIRSPY) AND
(NOT HACKRF) AND (NOT LIMESDR))
message("None of the Input Options selected. Using default SDRPLAY")
set(SDRPLAY ON)
endif ()
set (objectName "")
if(SDRPLAY)
if (objectName STREQUAL "")
set(SDRPLAY_V2 ON)
set(objectName sdrplay-channelScanner)
else ()
message ("Ignoring second option")
endif ()
endif ()
if(RTLSDR)
if (objectName STREQUAL "")
set(RTLSDR ON)
set(objectName rtlsdr-channelScanner)
else ()
message ("Ignoring second option")
endif ()
endif ()
if(PLUTO)
if (objectName STREQUAL "")
set(PLUTOSDR ON)
set(objectName pluto-channelScanner)
else ()
message ("Ignoring second option")
endif ()
endif ()
if(AIRSPY)
if (objectName STREQUAL "")
set(AIRSPY ON)
set(objectName airspy-channelScanner)
else ()
message ("Ignoring second option")
endif ()
endif ()
if(HACKRF)
if (objectName STREQUAL "")
set(HACKRF ON)
set(objectName hackrf-channelScanner)
else ()
message ("Ignoring second option")
endif ()
endif ()
if(LIMESDR)
if (objectName STREQUAL "")
set(LIMESDR ON)
set(objectName limesdr-channelScanner)
else ()
message ("Ignoring second option")
endif ()
endif ()
#########################################################################
find_package (PkgConfig)
find_package(FFTW3f)
if (NOT FFTW3F_FOUND)
message(FATAL_ERROR "please install FFTW3")
endif ()
find_package(Faad)
if (NOT FAAD_FOUND )
message(FATAL_ERROR "please install libfaad")
endif ()
find_package(LibSndFile)
if (NOT LIBSNDFILE_FOUND)
message(FATAL_ERROR "please install libsndfile")
endif ()
list(APPEND extraLibs ${LIBSNDFILE_LIBRARY})
find_package(LibSampleRate)
if (NOT LIBSAMPLERATE_FOUND)
message(FATAL_ERROR "please install libsamplerate")
endif ()
list(APPEND extraLibs ${LIBSAMPLERATE_LIBRARY})
#########################################################################
find_package (PkgConfig)
##########################################################################
# The devices
#
if (SDRPLAY_V2)
find_path (SDRPLAYLIB_INCLUDE_DIR
NAMES mirsdrapi-rsp.h
PATHS
/usr/local/include/
)
include_directories (${SDRPLAYLIB_INCLUDE_DIR})
find_library (SDRPLAYLIB mirsdrapi-rsp)
if(NOT(SDRPLAYLIB))
message(FATAL_ERROR "please install -lmirsdrapi-rsp")
else(NOT(SDRPLAYLIB))
list (APPEND extraLibs ${SDRPLAYLIB})
endif(NOT(SDRPLAYLIB))
include_directories (
./devices/sdrplay-handler
)
set ($(objectName)_HDRS
${${objectName}_HDRS}
./devices/sdrplay-handler/sdrplay-handler.h
)
set (${objectName}_SRCS
${${objectName}_SRCS}
./devices/sdrplay-handler/sdrplay-handler.cpp
)
add_definitions (-DHAVE_SDRPLAY_V2)
endif (SDRPLAY_V2)
if (RTLSDR)
find_package(LibRTLSDR)
if (NOT LIBRTLSDR_FOUND)
message(FATAL_ERROR "please install librtlsdr")
endif ()
###include_directories (${RTLSDR_INCLUDE_DIR})
include_directories (
./devices/rtlsdr-handler/
)
set (${objectName}_HDRS
${${objectName}_HDRS}
./devices/rtlsdr-handler/rtlsdr-handler.h
)
set (${objectName}_SRCS
${${objectName}_SRCS}
./devices/rtlsdr-handler/rtlsdr-handler.cpp
)
add_definitions (-DHAVE_RTLSDR)
endif()
if (PLUTOSDR)
find_library (PLUTOLIB iio)
if(NOT(PLUTOLIB))
message(FATAL_ERROR "please install libiio")
else(NOT(PLUTOLIB))
list (APPEND extraLibs ${PLUTOLIB})
endif(NOT(PLUTOLIB))
find_library (AD9361LIB ad9361)
if (NOT(AD9361LIB))
message (FATAL_ERROR "please installed libad9361")
else(NOT(LIBAD9361))
list (APPEND extraLibs ${AD9361LIB})
endif(NOT(AD9361LIB))
include_directories (
./devices/pluto-handler
)
set ($(objectName)_HDRS
${${objectName}_HDRS}
./devices/pluto-handler/pluto-handler.h
)
set (${objectName}_SRCS
${${objectName}_SRCS}
./devices/pluto-handler/pluto-handler.cpp
)
add_definitions (-DHAVE_PLUTO)
endif (PLUTOSDR)
if (AIRSPY)
find_package(LibAIRSPY)
if (NOT LIBAIRSPY_FOUND)
message(FATAL_ERROR "please install airspy library")
endif ()
### include_directories (${AIRSPYLIB_INCLUDE_DIR})
list(APPEND extraLibs ${LIBAIRSPY_LIBRARIES})
include_directories (
./devices/airspy-handler
)
set ($(objectName)_HDRS
${${objectName}_HDRS}
./devices/airspy-handler/airspy-handler.h
)
set (${objectName}_SRCS
${${objectName}_SRCS}
./devices/airspy-handler/airspy-handler.cpp
)
add_definitions (-DHAVE_AIRSPY)
endif (AIRSPY)
if (HACKRF)
find_path (HACKLIB_INCLUDE_DIR
NAMES hackrf.h
PATHS
./devices/hackrf-handler/libhackrf/
/usr/local/include/
)
include_directories (${HACKLIB_INCLUDE_DIR})
find_library (HACKLIB hackrf)
if(NOT(HACKLIB))
message(FATAL_ERROR "please install -lhackrf")
else(NOT(HACKLIB))
list (APPEND extraLibs ${HACKLIB})
endif(NOT(HACKLIB))
include_directories (
./devices/hackrf-handler
)
set ($(objectName)_HDRS
${${objectName}_HDRS}
./devices/hackrf-handler/hackrf-handler.h
)
set (${objectName}_SRCS
${${objectName}_SRCS}
./devices/hackrf-handler/hackrf-handler.cpp
)
add_definitions (-DHAVE_HACKRF)
endif (HACKRF)
if (LIMESDR)
find_library (LIMELIB LimeSuite)
if(NOT(LIMELIB))
message(FATAL_ERROR "please install LimeSuite")
else(NOT(LIMELIB))
list (APPEND extraLibs ${LIMELIB})
endif(NOT(LIMELIB))
include_directories (
./devices/lime-handler
)
set ($(objectName)_HDRS
${${objectName}_HDRS}
./devices/lime-handler/LMS7002M_parameters.h
./devices/lime-handler/LimeSuite.h
./devices/lime-handler/lime-handler.h
)
set (${objectName}_SRCS
${${objectName}_SRCS}
./devices/lime-handler/lime-handler.cpp
)
add_definitions (-DHAVE_LIMESDR)
endif (LIMESDR)
find_package(zlib)
if (NOT ZLIB_FOUND)
message(FATAL_ERROR "please install libz")
endif ()
list(APPEND extraLibs ${ZLIB_LIBRARY})
find_library (PTHREADS pthread)
if (NOT(PTHREADS))
message (FATAL_ERROR "please install libpthread")
else (NOT(PTHREADS))
set (extraLibs ${extraLibs} ${PTHREADS})
endif (NOT(PTHREADS))
#######################################################################
#
# Here we really start
include_directories (
${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
.
./
./devices
./dab-streamer
./ofdm
./support
./support/viterbi-spiral
/usr/include/
)
set (${objectName}_HDRS
${${objectName}_HDRS}
./dab-constants.h
./dab-api.h
./service-printer.h
./dab_tables.h
./devices/device-handler.h
./devices/xml-filewriter.h
./dab-processor.h
./ofdm/phasereference.h
./ofdm/phasetable.h
./ofdm/freq-interleaver.h
./ofdm/timesyncer.h
./ofdm/fic-handler.h
./ofdm/fib-processor.cpp
./ofdm/sample-reader.h
./ofdm/tii_detector.h
./support/ringbuffer.h
./support/band-handler.h
./support/protTables.h
./support/protection.h
./support/uep-protection.h
./support/eep-protection.h
./support/fft_handler.h
./support/dab-params.h
./support/charsets.h
./support/viterbi-spiral/viterbi-spiral.h
)
set (${objectName}_SRCS
${${objectName}_SRCS}
./main.cpp
./service-printer.cpp
./dab_tables.cpp
./devices/device-handler.cpp
./devices/xml-filewriter.cpp
./dab-processor.cpp
./ofdm/ofdm-decoder.cpp
./ofdm/phasereference.cpp
./ofdm/phasetable.cpp
./ofdm/freq-interleaver.cpp
./ofdm/timesyncer.cpp
./ofdm/sample-reader.cpp
./ofdm/fib-processor.cpp
./ofdm/fic-handler.cpp
./ofdm/tii_detector.cpp
./support/band-handler.cpp
# ./support/viterbi-handler.cpp
./support/protTables.cpp
./support/protection.cpp
./support/eep-protection.cpp
./support/uep-protection.cpp
./support/fft_handler.cpp
./support/dab-params.cpp
./support/charsets.cpp
./support/viterbi-spiral/viterbi-spiral.cpp
)
if (X64_DEFINED)
set (${objectName}_SRCS
${${objectName}_SRCS}
./support/viterbi-spiral/spiral-sse.c
)
set (${objectName}_HDRS
${${objectName}_HDRS}
./support/viterbi-spiral/spiral-sse.h
)
add_definitions (-DSSE_AVAILABLE)
elseif (RPI_DEFINED)
set (${objectName}_SRCS
${${objectName}_SRCS}
./support/viterbi-spiral/spiral-neon.c
)
set (${objectName}_HDRS
${${objectName}_HDRS}
./support/viterbi-spiral/spiral-neon.h
)
add_definitions (-DNEON_AVAILABLE)
# compiler options moved below add_executable .. and target specific
#set (CMAKE_CXX_FLAGS "${CMAKE_XCC_FLAGS} -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=neon-vfpv4")
#set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=neon-vfpv4")
else (X64_DEFINED)
set (${objectName}_SRCS
${${objectName}_SRCS}
./support/viterbi-spiral/spiral-no-sse.c
)
set (${objectName}_HDRS
${${objectName}_HDRS}
./support/viterbi-spiral/spiral-no-sse.h
)
endif (X64_DEFINED)
#
include_directories (
${FFTW_INCLUDE_DIRS}
${PORTAUDIO_INCLUDE_DIRS}
${FAAD_INCLUDE_DIRS}
${SNDFILES_INCLUDE_DIRS}
)
#####################################################################
add_executable (${objectName}
${${objectName}_SRCS}
)
if (RPI_DEFINED)
# compiler options seem changed with gcc versions. gcc 8.3.0 on Raspbian didn't accept -mcpu ..
# test options with "make VERBOSE=1"
target_compile_options(${objectName} PRIVATE -march=armv7-a -mfloat-abi=hard -mfpu=neon-vfpv4 )
endif()
target_link_libraries (${objectName}
${FFTW3F_LIBRARIES}
${extraLibs}
${FAAD_LIBRARIES}
${CMAKE_DL_LIBS}
)
INSTALL (TARGETS ${objectName} DESTINATION .)
########################################################################
# Create uninstall target
########################################################################
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)