-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
456 lines (381 loc) · 13.9 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
cmake_minimum_required (VERSION 3.0.2)
# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
project (sdrdaemon)
##############################################################################
EXECUTE_PROCESS( COMMAND uname -m COMMAND tr -d '\n' OUTPUT_VARIABLE ARCHITECTURE )
message( STATUS "Architecture: ${ARCHITECTURE}" )
if (${ARCHITECTURE} MATCHES "x86_64|AMD64|x86")
EXECUTE_PROCESS( COMMAND grep flags /proc/cpuinfo OUTPUT_VARIABLE CPU_FLAGS )
# if (${CPU_FLAGS} MATCHES "avx2")
# set(HAS_AVX2 ON CACHE BOOL "Architecture has AVX2 SIMD enabled")
# if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
# set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx2" )
# message(STATUS "Use g++ AVX2 SIMD instructions")
# add_definitions(-DUSE_AVX2)
# endif()
# else()
# set(HAS_AVX2 OFF CACHE BOOL "Architecture does not have AVX2 SIMD enabled")
# endif()
if (${CPU_FLAGS} MATCHES "sse4_1")
set(HAS_SSE4_1 ON CACHE BOOL "Architecture has SSE 4.1 SIMD enabled")
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.1" )
message(STATUS "Use g++ SSE 4.1 SIMD instructions")
add_definitions(-DUSE_SSE4_1)
endif()
else()
set(HAS_SSE4_1 OFF CACHE BOOL "Architecture does not have SSE 4.1 SIMD enabled")
endif()
if (${CPU_FLAGS} MATCHES "ssse3")
set(HAS_SSSE3 ON CACHE BOOL "Architecture has SSSE3 SIMD enabled")
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mssse3" )
message(STATUS "Use g++ SSSE3 SIMD instructions")
add_definitions(-DUSE_SSSE3)
endif()
else()
set(HAS_SSSE3 OFF CACHE BOOL "Architecture does not have SSSE3 SIMD enabled")
endif()
elseif (${ARCHITECTURE} MATCHES "armv7l")
EXECUTE_PROCESS( COMMAND grep Features /proc/cpuinfo OUTPUT_VARIABLE CPU_FLAGS )
if (${CPU_FLAGS} MATCHES "neon")
set(HAS_NEON ON CACHE BOOL "Architecture has NEON SIMD enabled")
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mfpu=neon" )
message(STATUS "Use g++ NEON SIMD instructions")
add_definitions(-DUSE_NEON)
endif()
else()
set(HAS_NEON OFF CACHE BOOL "Architecture does not have NEON SIMD enabled")
endif()
endif()
##############################################################################
find_package(Threads)
find_package(PkgConfig)
find_package(Boost 1.47)
find_package(LZ4 131)
find_package(CM256cc)
# Find Airspy library.
pkg_check_modules(PKG_AIRSPY libairspy)
find_path(LIBAIRSPY_INCLUDE_DIR airspy.h
HINT ${PKG_LIBAIRSPY_INCLUDE_DIR})
find_library(LIBAIRSPY_LIBRARIES libairspy.so
HINT ${PKG_LIBAIRSPY_LIBRARIES_DIRS})
if(LIBAIRSPY_INCLUDE_DIR AND LIBAIRSPY_LIBRARIES)
set(LIBAIRSPY_FOUND TRUE CACHE INTERNAL "libairspy found")
message(STATUS "Found libairspy: ${LIBAIRSPY_INCLUDE_DIR}, ${LIBAIRSPY_LIBRARIES}")
else(LIBAIRSPY_INCLUDE_DIR AND LIBAIRSPY_LIBRARIES)
set(LIBAIRSPY_FOUND FALSE CACHE INTERNAL "libairspy found")
message(STATUS "libairspy not found")
endif(LIBAIRSPY_INCLUDE_DIR AND LIBAIRSPY_LIBRARIES)
# Find BladeRF library.
pkg_check_modules(PKG_BLADERF libbladerf)
find_path(LIBBLADERF_INCLUDE_DIR libbladeRF.h
HINT ${PKG_LIBBLADERF_INCLUDE_DIR})
find_library(LIBBLADERF_LIBRARIES libbladeRF.so
HINT ${PKG_LIBBLADERF_LIBRARIES_DIRS})
if(LIBBLADERF_INCLUDE_DIR AND LIBBLADERF_LIBRARIES)
set(LIBBLADERF_FOUND TRUE CACHE INTERNAL "libbladerf found")
message(STATUS "Found libbladerf: ${LIBBLADERF_INCLUDE_DIR}, ${LIBBLADERF_LIBRARIES}")
else(LIBBLADERF_INCLUDE_DIR AND LIBBLADERF_LIBRARIES)
set(LIBBLADERF_FOUND FALSE CACHE INTERNAL "libbladerf found")
message(STATUS "libbladerf not found")
endif(LIBBLADERF_INCLUDE_DIR AND LIBBLADERF_LIBRARIES)
# Find HackRF library.
pkg_check_modules(PKG_HACKRF libhackrf)
find_path(LIBHACKRF_INCLUDE_DIR hackrf.h
HINT ${PKG_LIBHACKRF_INCLUDE_DIRS})
find_library(LIBHACKRF_LIBRARIES libhackrf.so
HINT ${PKG_LIBHACKRF_LIBRARIES_DIRS})
if(LIBHACKRF_INCLUDE_DIR AND LIBHACKRF_LIBRARIES)
set(LIBHACKRF_FOUND TRUE CACHE INTERNAL "libhackrf found")
message(STATUS "Found libhackrf: ${LIBHACKRF_INCLUDE_DIR}, ${LIBHACKRF_LIBRARIES}")
else(LIBHACKRF_INCLUDE_DIR AND LIBHACKRF_LIBRARIES)
set(LIBHACKRF_FOUND FALSE CACHE INTERNAL "libhackrf found")
message(STATUS "libhackrf not found")
endif(LIBHACKRF_INCLUDE_DIR AND LIBHACKRF_LIBRARIES)
# Find RTL-SDR library.
pkg_check_modules(PKG_RTLSDR librtlsdr)
find_path(LIBRTLSDR_INCLUDE_DIR rtl-sdr.h
HINT ${PKG_LIBRTLSDR_INCLUDE_DIRS})
find_library(LIBRTLSDR_LIBRARIES librtlsdr.so
HINT ${PKG_LIBRTLSDR_LIBRARIES_DIRS})
if(LIBRTLSDR_INCLUDE_DIR AND LIBRTLSDR_LIBRARIES)
set(LIBRTLSDR_FOUND TRUE CACHE INTERNAL "librtlsdr found")
message(STATUS "Found librtlsdr: ${LIBRTLSDR_INCLUDE_DIR}, ${LIBRTLSDR_LIBRARIES}")
else(LIBRTLSDR_INCLUDE_DIR AND LIBRTLSDR_LIBRARIES)
set(LIBRTLSDR_FOUND FALSE CACHE INTERNAL "librtlsdr found")
message(STATUS "librtlsdr not found")
endif(LIBRTLSDR_INCLUDE_DIR AND LIBRTLSDR_LIBRARIES)
# Find libusb
pkg_check_modules(PKG_LIBUSB libusb-1.0)
find_path(LIBUSB_INCLUDE_DIR libusb.h
HINT ${PKG_LIBUSB_INCLUDE_DIRS}
PATH_SUFFIXES libusb-1.0)
find_library(LIBUSB_LIBRARY usb-1.0
HINT ${PKG_LIBUSB_LIBRARY_DIRS})
if(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARY)
set(LIBUSB_FOUND TRUE CACHE INTERNAL "libusb found")
message(STATUS "Found libusb: ${LIBUSB_INCLUDE_DIR}, ${LIBUSB_LIBRARY}")
else(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARY)
set(LIBRTLSDR_FOUND FALSE CACHE INTERNAL "libusb found")
message(STATUS "libusb not found")
endif(LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARY)
# Find nanomsg library.
pkg_check_modules(PKG_LIBNANOMSG libnanomsg)
find_path(LIBNANOMSG_INCLUDE_DIR nanomsg/nn.h
HINT ${PKG_LIBNANOMSG_INCLUDE_DIRS})
find_library(LIBNANOMSG_LIBRARIES libnanomsg.so
HINT ${PKG_LIBNANOMSG_LIBRARIES_DIRS})
if(LIBNANOMSG_INCLUDE_DIR AND LIBNANOMSG_LIBRARIES)
set(LIBNANOMSG_FOUND TRUE CACHE INTERNAL "libnanomsg found")
message(STATUS "Found libnanomsg: ${LIBNANOMSG_INCLUDE_DIR}, ${LIBNANOMSG_LIBRARIES}")
else(LIBNANOMSG_INCLUDE_DIR AND LIBNANOMSG_LIBRARIES)
set(LIBNANOMSG_FOUND FALSE CACHE INTERNAL "libnanomsg found")
message(FATAL_ERROR "libnanomsg is not found and is required. CMake will exit")
endif(LIBNANOMSG_INCLUDE_DIR AND LIBNANOMSG_LIBRARIES)
set(LIBAIRSPY_INCLUDE_DIRS ${LIBAIRSPY_INCLUDE_DIR} ${LIBUSB_INCLUDE_DIR} ${LIBNANOMSG_INCLUDE_DIR})
set(LIBAIRSPY_LIBRARIES ${LIBAIRSPY_LIBRARIES} ${LIBUSB_LIBRARY} ${LIBNANOMSG_LIBRARIES})
set(LIBBLADERF_INCLUDE_DIRS ${LIBBLADERF_INCLUDE_DIR} ${LIBUSB_INCLUDE_DIR} ${LIBNANOMSG_INCLUDE_DIR})
set(LIBBLADERF_LIBRARIES ${LIBBLADERF_LIBRARIES} ${LIBUSB_LIBRARY} ${LIBNANOMSG_LIBRARIES})
set(LIBHACKRF_INCLUDE_DIRS ${LIBHACKRF_INCLUDE_DIR} ${LIBUSB_INCLUDE_DIR} ${LIBNANOMSG_INCLUDE_DIR})
set(LIBHACKRF_LIBRARIES ${LIBHACKRF_LIBRARIES} ${LIBUSB_LIBRARY} ${LIBNANOMSG_LIBRARIES})
set(LIBRTLSDR_INCLUDE_DIRS ${LIBRTLSDR_INCLUDE_DIR} ${LIBUSB_INCLUDE_DIR} ${LIBNANOMSG_INCLUDE_DIR})
set(LIBRTLSDR_LIBRARIES ${LIBRTLSDR_LIBRARIES} ${LIBUSB_LIBRARY} ${LIBNANOMSG_LIBRARIES})
set(LIBTEST_INCLUDE_DIRS ${LIBNANOMSG_INCLUDE_DIR})
set(LIBTEST_LIBRARIES ${LIBNANOMSG_LIBRARIES})
# Compiler flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -O2 -ffast-math -ftree-vectorize ${EXTRA_FLAGS}")
set(sdmnbase_SOURCES
sdmnbase/CRC64.cpp
sdmnbase/Decimators.cpp
sdmnbase/Downsampler.cpp
sdmnbase/HBFilterTraits.cpp
sdmnbase/Source.cpp
sdmnbase/UDPSink.cpp
sdmnbase/UDPSinkUncompressed.cpp
sdmnbase/UDPSinkLZ4.cpp
sdmnbase/UDPSocket.cpp
)
set(sdmnbase_HEADERS
include/CRC64.h
include/DataBuffer.h
include/Decimators.h
include/Downsampler.h
include/HBFilterTraits.h
include/IntHalfbandFilter.h
include/parsekv.h
include/Source.h
include/UDPSink.h
include/UDPSinkUncompressed.h
include/UDPSinkLZ4.h
include/UDPSocket.h
include/util.h
)
set(sdmnfecbase_SOURCES
sdmnbase/CRC64.cpp
sdmnbase/Decimators.cpp
sdmnbase/Downsampler.cpp
sdmnbase/HBFilterTraits.cpp
sdmnbase/Source.cpp
sdmnbase/UDPSink.cpp
sdmnbase/UDPSinkFEC.cpp
sdmnbase/UDPSinkUncompressed.cpp
sdmnbase/UDPSinkLZ4.cpp
sdmnbase/UDPSocket.cpp
)
set(sdmnfecbase_HEADERS
include/CRC64.h
include/DataBuffer.h
include/Decimators.h
include/Downsampler.h
include/HBFilterTraits.h
include/IntHalfbandFilter.h
include/IntHalfbandFilterDB.h
include/IntHalfbandFilterEO1.h
include/IntHalfbandFilterEO1i.h
include/IntHalfbandFilterST.h
include/IntHalfbandFilterSTi.h
include/parsekv.h
include/Source.h
include/UDPSink.h
include/UDPSinkFEC.h
include/UDPSinkUncompressed.h
include/UDPSinkLZ4.h
include/UDPSocket.h
include/util.h
)
# Base sources
set(sdmnbase_SOURCES
${sdmnbase_SOURCES}
${sdmnbase_HEADERS}
)
set(sdmnfecbase_SOURCES
${sdmnfecbase_SOURCES}
${sdmnfecbase_HEADERS}
)
# Test sources
set(sdmntest_SOURCES
sdmnbase/TestSource.cpp
)
set(sdmntest_HEADERS
include/TestSource.h
)
# Libraries
add_library(sdmnbase STATIC
${sdmnbase_SOURCES}
)
add_library(sdmntest STATIC
${sdmntest_SOURCES}
)
add_executable(sdrdaemon
sdrdaemon.cpp
)
if((HAS_SSSE3 OR HAS_NEON) AND CM256CC_FOUND)
message(STATUS "SDRdaemonFEC with SIMD instructions enabled")
add_library(sdmnfecbase STATIC
${sdmnfecbase_SOURCES}
)
add_executable(sdrdaemonfec
sdrdaemonfec.cpp
)
endif()
add_executable(sdrdmnctl
sdrdmnctl.cpp
)
include_directories(
${CMAKE_SOURCE_DIR}/include
${LIBNANOMSG_INCLUDE_DIR}
${CM256CC_INCLUDE_DIR}
${EXTRA_INCLUDES}
)
set(DEVICE_LIBRARIES "")
set(DEVICE_TARGETS "")
if(LIBUSB_FOUND AND LIBAIRSPY_FOUND)
set(sdmnairspy_SOURCES
sdmnbase/AirspySource.cpp
)
set(sdmnairspy_HEADERS
include/AirspySource.h
)
add_library(sdmnairspy STATIC
${sdmnairspy_SOURCES}
)
target_include_directories(sdmnairspy PUBLIC
${LIBAIRSPY_INCLUDE_DIRS}
)
target_link_libraries(sdmnairspy
${LIBAIRSPY_LIBRARIES}
)
set(DEVICE_LIBRARIES ${DEVICE_LIBRARIES} sdmnairspy)
set(DEVICE_TARGETS ${DEVICE_TARGETS} sdmnairspy)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAS_AIRSPY")
endif(LIBUSB_FOUND AND LIBAIRSPY_FOUND)
if(LIBUSB_FOUND AND LIBBLADERF_FOUND)
set(sdmnbladerf_SOURCES
sdmnbase/BladeRFSource.cpp
)
set(sdmnbladerf_HEADERS
include/BladeRFSource.h
)
add_library(sdmnbladerf STATIC
${sdmnbladerf_SOURCES}
)
target_include_directories(sdmnbladerf PUBLIC
${LIBBLADERF_INCLUDE_DIRS}
)
target_link_libraries(sdmnbladerf
${LIBBLADERF_LIBRARIES}
)
set(DEVICE_LIBRARIES ${DEVICE_LIBRARIES} sdmnbladerf)
set(DEVICE_TARGETS ${DEVICE_TARGETS} sdmnbladerf)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAS_BLADERF")
endif(LIBUSB_FOUND AND LIBBLADERF_FOUND)
if(LIBUSB_FOUND AND LIBHACKRF_FOUND)
set(sdmnhackrf_SOURCES
sdmnbase/HackRFSource.cpp
)
set(sdmnhackrf_HEADERS
include/HackRFSource.h
)
add_library(sdmnhackrf STATIC
${sdmnhackrf_SOURCES}
)
target_include_directories(sdmnhackrf PUBLIC
${LIBHACKRF_INCLUDE_DIRS}
)
target_link_libraries(sdmnhackrf
${LIBHACKRF_LIBRARIES}
)
set(DEVICE_LIBRARIES ${DEVICE_LIBRARIES} sdmnhackrf)
set(DEVICE_TARGETS ${DEVICE_TARGETS} sdmnhackrf)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAS_HACKRF")
endif(LIBUSB_FOUND AND LIBHACKRF_FOUND)
if(LIBUSB_FOUND AND LIBRTLSDR_FOUND)
set(sdmnrtlsdr_SOURCES
sdmnbase/RtlSdrSource.cpp
)
set(sdmnrtlsdr_HEADERS
include/RtlSdrSource.h
)
add_library(sdmnrtlsdr STATIC
${sdmnrtlsdr_SOURCES}
)
target_include_directories(sdmnrtlsdr PUBLIC
${LIBRTLSDR_INCLUDE_DIRS}
)
target_link_libraries(sdmnrtlsdr
${LIBRTLSDR_LIBRARIES}
)
set(DEVICE_LIBRARIES ${DEVICE_LIBRARIES} sdmnrtlsdr)
set(DEVICE_TARGETS ${DEVICE_TARGETS} sdmnrtlsdr)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAS_RTLSDR")
endif(LIBUSB_FOUND AND LIBRTLSDR_FOUND)
target_include_directories(sdmntest PUBLIC
${LIBTEST_INCLUDE_DIRS}
)
target_link_libraries(sdmntest
${LIBTEST_LIBRARIES}
)
target_link_libraries(sdmnbase ${LZ4_LIBRARIES})
target_link_libraries(sdrdaemon
sdmnbase
${DEVICE_LIBRARIES}
sdmntest
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBS}
)
if((HAS_SSSE3 OR HAS_NEON) AND CM256CC_FOUND)
target_link_libraries(sdmnfecbase ${LZ4_LIBRARIES} ${CM256CC_LIBRARIES})
target_link_libraries(sdrdaemonfec
sdmnfecbase
${DEVICE_LIBRARIES}
sdmntest
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBS}
)
endif()
target_include_directories(sdrdmnctl PUBLIC
${LIBNANOMSG_INCLUDE_DIR}
)
target_link_libraries(sdrdmnctl
${LIBNANOMSG_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBS}
)
if((HAS_SSSE3 OR HAS_NEON) AND CM256CC_FOUND)
install(TARGETS sdrdaemon sdrdaemonfec sdrdmnctl DESTINATION bin)
install(TARGETS sdmnbase sdmnfecbase ${DEVICE_TARGETS} sdmntest DESTINATION lib)
else()
install(TARGETS sdrdaemon sdrdmnctl DESTINATION bin)
install(TARGETS sdmnbase ${DEVICE_TARGETS} sdmntest DESTINATION lib)
endif()