forked from AlbrechtL/welle.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
328 lines (278 loc) · 10.4 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
cmake_minimum_required(VERSION 3.2)
project(Welle.Io VERSION 0.0.0 LANGUAGES C CXX)
if(NOT WELLE-IO_VERSION)
set(WELLE-IO_VERSION ${PROJECT_VERSION})
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
option(BUILD_WELLE_IO "Build Welle.io" ON )
option(BUILD_WELLE_CLI "Build welle-cli" ON )
option(WITH_APP_BUNDLE "Enable Application Bundle for macOS" ON )
option(KISS_FFT "KISS FFT instead of FFTW" OFF )
option(PROFILING "Enable profiling (see README.md)" OFF )
option(AIRSPY "Compile with Airspy support" OFF )
option(RTLSDR "Compile with RTL-SDR support" OFF )
option(SOAPYSDR "Compile with SoapySDR support" OFF )
add_definitions(-Wall)
add_definitions(-g)
add_definitions(-DDABLIN_AAC_FAAD2)
if(MINGW)
add_definitions(-municode)
endif()
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 "")
#enable_testing()
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/Modules)
if(APPLE AND WITH_APP_BUNDLE)
if(NOT DEFINED BUNDLE_INSTALL_DIR)
set(BUNDLE_INSTALL_DIR "/Applications")
endif()
set(GUI_INSTALL_DIR "${BUNDLE_INSTALL_DIR}")
else()
include(GNUInstallDirs)
set(GUI_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}")
endif()
if(BUILD_WELLE_IO)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5 COMPONENTS Widgets Quick QuickControls2 Multimedia Charts Qml DBus REQUIRED)
endif()
if(PROFILING)
add_definitions(-DWITH_PROFILING)
endif()
find_package(ALSA)
if(ALSA_FOUND)
add_definitions(-DHAVE_ALSA)
endif()
if(KISS_FFT)
add_definitions(-DKISSFFT)
set(fft_sources src/libs/kiss_fft/kiss_fft.c)
set(KISS_INCLUDE_DIRS src/libs/kiss_fft)
else()
find_package(FFTW3f REQUIRED)
set(fft_sources "")
set(KISS_INCLUDE_DIRS "")
endif()
if(BUILD_WELLE_CLI)
find_package(Lame REQUIRED)
endif()
find_package(Threads REQUIRED)
find_package(Faad REQUIRED)
find_package(MPG123 REQUIRED)
if (RTLSDR)
find_package(LibRTLSDR REQUIRED)
endif()
if (AIRSPY)
find_package(LibAIRSPY REQUIRED)
endif()
if (SOAPYSDR)
find_package(SoapySDR NO_MODULE REQUIRED)
# Note: SoapySDRConfig.cmake sets C++11 standard so it needs to be reset to C++14
set(CMAKE_CXX_STANDARD 14)
endif()
include_directories(
src
src/backend
src/output
src/various
src/input
src/gui
src/libs/fec
${FFTW3F_INCLUDE_DIRS}
${KISS_INCLUDE_DIRS}
${FAAD_INCLUDE_DIRS}
${LIBRTLSDR_INCLUDE_DIRS}
${SoapySDR_INCLUDE_DIRS}
)
set(backend_sources
src/backend/dab-audio.cpp
src/backend/decoder_adapter.cpp
src/backend/dab_decoder.cpp
src/backend/dabplus_decoder.cpp
src/backend/charsets.cpp
src/backend/dab-constants.cpp
src/backend/mot_manager.cpp
src/backend/pad_decoder.cpp
src/backend/eep-protection.cpp
src/backend/fib-processor.cpp
src/backend/fic-handler.cpp
src/backend/msc-handler.cpp
src/backend/freq-interleaver.cpp
src/backend/ofdm-decoder.cpp
src/backend/ofdm-processor.cpp
src/backend/phasereference.cpp
src/backend/phasetable.cpp
src/backend/tii-decoder.cpp
src/backend/protTables.cpp
src/backend/radio-receiver.cpp
src/backend/tools.cpp
src/backend/uep-protection.cpp
src/backend/viterbi.cpp
src/various/Socket.cpp
src/various/Xtan2.cpp
src/various/channels.cpp
src/various/fft.cpp
src/various/profiling.cpp
src/various/wavfile.c
src/libs/fec/decode_rs_char.c
src/libs/fec/encode_rs_char.c
src/libs/fec/init_rs_char.c
)
set(welle_io_sources
src/welle-gui/main.cpp
src/welle-gui/audio_output.cpp
src/welle-gui/mot_image_provider.cpp
src/welle-gui/gui_helper.cpp
src/welle-gui/radio_controller.cpp
src/welle-gui/mpris/mpris.cpp
src/welle-gui/mpris/mpris_mp2.cpp
src/welle-gui/mpris/mpris_mp2_player.cpp
src/welle-gui/debug_output.cpp
src/welle-gui/waterfallitem.cpp
)
set(welle_cli_sources
src/welle-cli/welle-cli.cpp
src/welle-cli/alsa-output.cpp
src/welle-cli/webradiointerface.cpp
src/welle-cli/jsonconvert.cpp
src/welle-cli/webprogrammehandler.cpp
src/welle-cli/tests.cpp
)
set(input_sources
src/input/input_factory.cpp
src/input/null_device.cpp
src/input/raw_file.cpp
src/input/rtl_tcp.cpp
)
if(LIBRTLSDR_FOUND)
add_definitions (-DHAVE_RTLSDR)
set(input_sources ${input_sources} src/input/rtl_sdr.cpp)
endif()
if(LIBAIRSPY_FOUND)
add_definitions (-DHAVE_AIRSPY)
set(input_sources ${input_sources} src/input/airspy_sdr.cpp)
endif()
if(SoapySDR_FOUND)
add_definitions (-DHAVE_SOAPYSDR)
set(input_sources ${input_sources} src/input/soapy_sdr.cpp)
endif()
if(NOT GIT_COMMIT_HASH)
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
if(GIT_COMMIT_HASH)
add_definitions("-DGITHASH=\"${GIT_COMMIT_HASH}\"")
endif()
if(NOT GIT_DESCRIBE)
execute_process(
COMMAND git describe --tags --long
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_DESCRIBE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
if(GIT_DESCRIBE)
add_definitions("-DGITDESCRIBE=\"${GIT_DESCRIBE}\"")
endif()
STRING(TIMESTAMP BUILD_DATE "%s" UTC)
add_definitions("-DBUILD_DATE=\"${BUILD_DATE}\"")
if(BUILD_WELLE_IO)
set(executableName welle-io)
add_executable (${executableName} ${welle_io_sources} ${backend_sources} ${input_sources} ${fft_sources} ${EXTRA_MOCS} src/welle-gui/resources.qrc)
target_link_libraries (${executableName}
${LIBRTLSDR_LIBRARIES}
${LIBAIRSPY_LIBRARIES}
${FFTW3F_LIBRARIES}
${FAAD_LIBRARIES}
${SoapySDR_LIBRARIES}
${MPG123_LIBRARIES}
Threads::Threads
Qt5::Core Qt5::Widgets Qt5::Multimedia Qt5::Charts Qt5::Qml Qt5::Quick Qt5::QuickControls2 Qt5::DBus
)
if(APPLE AND WITH_APP_BUNDLE)
set(macOsIcon ${CMAKE_CURRENT_SOURCE_DIR}/src/welle-gui/icons/icon.icns)
set_source_files_properties(${macOsIcon} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
target_sources(${executableName} PRIVATE ${macOsIcon})
set(SHORT_VERSION "${WELLE-IO_VERSION}")
set(EXECUTABLE "${executableName}")
set(TYPEINFO "io.welle.welle")
set(PRODUCT_BUNDLE_IDENTIFIER "io.welle.welle")
set_target_properties("${executableName}" PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/welle-io.plist
)
INSTALL (TARGETS ${executableName} BUNDLE DESTINATION ${GUI_INSTALL_DIR})
else()
INSTALL (TARGETS ${executableName} RUNTIME DESTINATION ${GUI_INSTALL_DIR})
INSTALL (FILES src/welle-gui/doc/man/welle-io.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1/)
if(UNIX AND NOT APPLE)
INSTALL (FILES ${PROJECT_SOURCE_DIR}/welle-io.desktop DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
INSTALL (FILES ${PROJECT_SOURCE_DIR}/src/welle-gui/icons/16x16/welle-io.png DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/16x16/apps)
INSTALL (FILES ${PROJECT_SOURCE_DIR}/src/welle-gui/icons/24x24/welle-io.png DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/24x24/apps)
INSTALL (FILES ${PROJECT_SOURCE_DIR}/src/welle-gui/icons/32x32/welle-io.png DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/32x32/apps)
INSTALL (FILES ${PROJECT_SOURCE_DIR}/src/welle-gui/icons/48x48/welle-io.png DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps)
INSTALL (FILES ${PROJECT_SOURCE_DIR}/src/welle-gui/icons/128x128/welle-io.png DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/128x128/apps)
INSTALL (FILES ${PROJECT_SOURCE_DIR}/src/welle-gui/icons/256x256/welle-io.png DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/256x256/apps)
endif()
endif()
endif()
if(BUILD_WELLE_CLI)
set(cliExecutableName welle-cli)
add_executable (${cliExecutableName} ${welle_cli_sources} ${backend_sources} ${input_sources} ${fft_sources})
if(CMAKE_BUILD_TYPE MATCHES Debug)
SET_TARGET_PROPERTIES(${cliExecutableName} PROPERTIES COMPILE_FLAGS "-O2 -fno-omit-frame-pointer -fsanitize=address")
SET_TARGET_PROPERTIES(${cliExecutableName} PROPERTIES LINK_FLAGS "-fno-omit-frame-pointer -fsanitize=address")
endif(CMAKE_BUILD_TYPE MATCHES Debug)
target_link_libraries (${cliExecutableName}
${LIBRTLSDR_LIBRARIES}
${LIBAIRSPY_LIBRARIES}
${FFTW3F_LIBRARIES}
${FAAD_LIBRARIES}
${ALSA_LIBRARIES}
${LAME_LIBRARIES}
${SoapySDR_LIBRARIES}
${MPG123_LIBRARIES}
Threads::Threads
)
add_custom_command(
TARGET ${cliExecutableName} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/src/welle-cli/index.html
${CMAKE_CURRENT_BINARY_DIR}/index.html)
add_custom_command(
TARGET ${cliExecutableName} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_SOURCE_DIR}/src/welle-cli/index.js
${CMAKE_CURRENT_BINARY_DIR}/index.js)
if(APPLE AND WITH_APP_BUNDLE)
INSTALL (TARGETS ${cliExecutableName} RUNTIME DESTINATION ${GUI_INSTALL_DIR}/${executableName}.app/Contents/MacOS)
INSTALL (
FILES
${PROJECT_SOURCE_DIR}/src/welle-cli/index.html
${PROJECT_SOURCE_DIR}/src/welle-cli/index.js
DESTINATION ${GUI_INSTALL_DIR}/${executableName}.app/Contents/Resources/welle-cli
)
elseif(UNIX)
INSTALL (TARGETS ${cliExecutableName} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
INSTALL (FILES src/welle-cli/doc/man/welle-cli.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1/)
INSTALL (
FILES
${PROJECT_SOURCE_DIR}/src/welle-cli/index.html
${PROJECT_SOURCE_DIR}/src/welle-cli/index.js
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/welle-io/html/
)
endif()
endif()
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)