-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
264 lines (243 loc) · 10.1 KB
/
Copy pathCMakeLists.txt
File metadata and controls
264 lines (243 loc) · 10.1 KB
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
cmake_minimum_required(VERSION 3.16)
project(InmarScope C CXX)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "" FORCE)
endif()
# ---------------------------------------------------------------------------
# Dependencies
# ---------------------------------------------------------------------------
find_package(OpenGL REQUIRED)
find_package(PkgConfig)
find_package(glfw3 CONFIG QUIET)
if(NOT glfw3_FOUND)
if(NOT PkgConfig_FOUND)
find_package(PkgConfig REQUIRED)
endif()
pkg_check_modules(GLFW REQUIRED glfw3)
endif()
# RTL-SDR
if(PkgConfig_FOUND)
pkg_check_modules(RTLSDR QUIET librtlsdr)
endif()
if(NOT RTLSDR_FOUND)
find_library(RTLSDR_LIBRARIES NAMES rtlsdr librtlsdr REQUIRED)
find_path(RTLSDR_INCLUDE_DIRS NAMES rtl-sdr.h REQUIRED)
endif()
# HackRF (native source). The MSYS2 libhackrf.pc has a hardcoded build-machine
# libusb include path, so locate the header/library directly instead of via
# pkg-config. hackrf.h itself doesn't pull in libusb, so no extra include is
# needed for our wrapper.
find_path(HACKRF_INCLUDE_DIRS NAMES libhackrf/hackrf.h hackrf.h
PATH_SUFFIXES libhackrf REQUIRED)
find_library(HACKRF_LIBRARIES NAMES hackrf libhackrf REQUIRED)
# Airspy (native source, optional).
# Vendored headers always available; library detection is optional.
set(AIRSPY_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/third_party/airspy)
find_library(AIRSPY_LIBRARIES NAMES airspy libairspy)
set(AIRSPY_FOUND FALSE)
if(AIRSPY_LIBRARIES)
set(AIRSPY_FOUND TRUE)
message(STATUS "Airspy link library found: ${AIRSPY_LIBRARIES}")
endif()
set(IMGUI_DIR ${CMAKE_SOURCE_DIR}/third_party/imgui)
set(IMPLOT_DIR ${CMAKE_SOURCE_DIR}/third_party/implot)
# ---------------------------------------------------------------------------
# Dear ImGui + ImPlot (vendored) compiled as a static lib
# ---------------------------------------------------------------------------
add_library(imgui STATIC
${IMGUI_DIR}/imgui.cpp
${IMGUI_DIR}/imgui_draw.cpp
${IMGUI_DIR}/imgui_tables.cpp
${IMGUI_DIR}/imgui_widgets.cpp
${IMGUI_DIR}/imgui_demo.cpp
${IMGUI_DIR}/backends/imgui_impl_glfw.cpp
${IMGUI_DIR}/backends/imgui_impl_opengl3.cpp
${IMPLOT_DIR}/implot.cpp
${IMPLOT_DIR}/implot_items.cpp
)
target_include_directories(imgui PUBLIC
${IMGUI_DIR}
${IMGUI_DIR}/backends
${IMPLOT_DIR}
)
# implot_items.cpp is extremely template-heavy: ~5 min to compile at -O2.
# It is not performance-critical for us, so build it at -O1 (~1 min). The last
# -O flag wins in GCC, so this overrides the RelWithDebInfo -O2.
set_source_files_properties(${IMPLOT_DIR}/implot_items.cpp PROPERTIES COMPILE_OPTIONS "-O1")
target_link_libraries(imgui PUBLIC OpenGL::GL)
if(glfw3_FOUND)
target_link_libraries(imgui PUBLIC glfw)
else()
target_include_directories(imgui PUBLIC ${GLFW_INCLUDE_DIRS})
target_link_libraries(imgui PUBLIC ${GLFW_LIBRARIES})
target_link_directories(imgui PUBLIC ${GLFW_LIBRARY_DIRS})
endif()
# ---------------------------------------------------------------------------
# JAERO DSP (MSK/OQPSK demodulators + AeroL framing), Qt-stripped, plus the
# vendored libcorrect FEC. Built as a static lib with a plain C API.
# ---------------------------------------------------------------------------
set(JDSP ${CMAKE_SOURCE_DIR}/third_party/jaero_dsp)
file(GLOB LIBCORRECT_SOURCES
${JDSP}/libcorrect/src/convolutional/*.c
${JDSP}/libcorrect/src/reed-solomon/*.c
${JDSP}/libcorrect/src/fec_shim.c)
add_library(jaero_dsp STATIC
${JDSP}/DSP.cpp
${JDSP}/mskdemodulator.cpp
${JDSP}/oqpskdemodulator.cpp
${JDSP}/burstmskdemodulator.cpp
${JDSP}/burstoqpskdemodulator.cpp
${JDSP}/coarsefreqestimate.cpp
${JDSP}/fftwrapper.cpp
${JDSP}/fftrwrapper.cpp
${JDSP}/jfft.cpp
${JDSP}/jconvolutionalcodec.cpp
${JDSP}/aerol.cpp
${JDSP}/jaero_demod.cpp
${LIBCORRECT_SOURCES}
)
target_include_directories(jaero_dsp PUBLIC
${JDSP}
${JDSP}/libcorrect/include
)
target_compile_definitions(jaero_dsp PUBLIC _USE_MATH_DEFINES)
# ---------------------------------------------------------------------------
# mbelib (AMBE/IMBE voice codec, C) for Aero C-channel voice decoding.
# ---------------------------------------------------------------------------
file(GLOB MBELIB_SOURCES ${CMAKE_SOURCE_DIR}/third_party/mbelib/*.c)
add_library(mbelib STATIC ${MBELIB_SOURCES})
target_include_directories(mbelib PUBLIC ${CMAKE_SOURCE_DIR}/third_party/mbelib)
# ---------------------------------------------------------------------------
# libacars (vendored): decodes the ACARS application layer (CPDLC, ADS-C,
# MIAM, media-advisory). Built via its own CMake as the acars_static target.
# Examples are skipped (LA_BUILD_EXAMPLES off).
# ---------------------------------------------------------------------------
set(LA_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(third_party/libacars ${CMAKE_BINARY_DIR}/libacars EXCLUDE_FROM_ALL)
# ---------------------------------------------------------------------------
# InmarScope application
# ---------------------------------------------------------------------------
add_executable(InmarScope
src/main.cpp
src/signal/processing.cpp
src/voice/voice_ops.cpp
src/gui/gui_panels.cpp
src/session/session.cpp
src/state/config.cpp
src/sdr/rtl_sdr_source.cpp
src/sdr/hackrf_source.cpp
src/sdr/wav_file_source.cpp
src/sdr/sdrpp_server_source.cpp
src/sdr/iq_recorder.cpp
src/gui/waterfall.cpp
src/decode/decoder.cpp
src/decode/decoder_manager.cpp
src/decode/acars_apps.cpp
src/decode/icao_country.cpp
src/decode/band_plan.cpp
src/decode/json_mini.cpp
src/util/log.cpp
src/decode/egc/egc_decoder.cpp
src/voice/ambe_decoder.cpp
src/voice/wav_writer.cpp
src/audio/audio_output.cpp
src/audio/audio_player.cpp
src/audio/miniaudio_impl.cpp
src/web/web_server.cpp
src/store/message_store.cpp
src/output/message_feed.cpp
src/update/version_check.cpp
src/web/flight_map_webview.cpp
)
# Microsoft Edge WebView2 for the embedded Flight Map browser.
set(WEBVIEW2_ROOT ${CMAKE_SOURCE_DIR}/third_party/webview2/build/native)
find_library(WEBVIEW2_LIB WebView2Loader.dll PATHS ${WEBVIEW2_ROOT}/x64 NO_DEFAULT_PATH REQUIRED)
target_include_directories(InmarScope PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/mbelib
${CMAKE_SOURCE_DIR}/third_party/miniaudio
${CMAKE_SOURCE_DIR}/third_party/libacars
${WEBVIEW2_ROOT}/include
${RTLSDR_INCLUDE_DIRS}
${HACKRF_INCLUDE_DIRS}
)
target_compile_definitions(InmarScope PRIVATE _USE_MATH_DEFINES)
if(AIRSPY_FOUND)
target_sources(InmarScope PRIVATE src/sdr/airspy_source.cpp)
target_compile_definitions(InmarScope PRIVATE HAS_AIRSPY=1)
target_include_directories(InmarScope PRIVATE ${AIRSPY_INCLUDE_DIRS})
endif()
find_library(ZSTD_LIBRARIES NAMES zstd libzstd REQUIRED)
find_library(ZLIB_LIB NAMES z libz zlib REQUIRED)
find_library(SQLITE3_LIB NAMES sqlite3 libsqlite3 REQUIRED)
# libogg + libvorbis for OGG Vorbis voice recording.
if(PkgConfig_FOUND)
pkg_check_modules(OGG REQUIRED ogg)
pkg_check_modules(VORBIS REQUIRED vorbis)
pkg_check_modules(VORBISENC REQUIRED vorbisenc)
endif()
if(NOT OGG_FOUND OR NOT VORBIS_FOUND)
find_library(OGG_LIBRARIES NAMES ogg libogg REQUIRED)
find_library(VORBIS_LIBRARIES NAMES vorbis libvorbis REQUIRED)
find_library(VORBISENC_LIBRARIES NAMES vorbisenc libvorbisenc REQUIRED)
endif()
target_link_libraries(InmarScope PRIVATE imgui jaero_dsp mbelib acars_static ${ZLIB_LIB} ${RTLSDR_LIBRARIES} ${HACKRF_LIBRARIES} ${ZSTD_LIBRARIES} ${OGG_LIBRARIES} ${VORBIS_LIBRARIES} ${VORBISENC_LIBRARIES} ${WEBVIEW2_LIB} ${SQLITE3_LIB})
if(AIRSPY_FOUND)
target_link_libraries(InmarScope PRIVATE ${AIRSPY_LIBRARIES})
endif()
target_link_directories(InmarScope PRIVATE ${RTLSDR_LIBRARY_DIRS})
if(WIN32)
target_link_libraries(InmarScope PRIVATE opengl32 gdi32 comdlg32 ole32 winmm ws2_32 winhttp shell32)
# Build as a GUI-subsystem app so no console window opens alongside the GUI.
# MinGW provides a WinMain shim, so the existing int main() still works.
set_target_properties(InmarScope PROPERTIES WIN32_EXECUTABLE TRUE)
# Embed the application icon (icon.ico in the project root). Windows and
# GLFW both pick up the first icon resource for the exe and window.
if(EXISTS "${CMAKE_SOURCE_DIR}/icon.ico")
enable_language(RC)
set(FRAMESYNC_ICON "${CMAKE_SOURCE_DIR}/icon.ico")
configure_file("${CMAKE_SOURCE_DIR}/app.rc.in" "${CMAKE_BINARY_DIR}/app.rc" @ONLY)
target_sources(InmarScope PRIVATE "${CMAKE_BINARY_DIR}/app.rc")
endif()
# Copy MinGW runtime DLLs next to the executable so it runs standalone
# (PyCharm, double-click) without the MSYS2 bin dir on PATH.
get_filename_component(MINGW_BIN "${CMAKE_CXX_COMPILER}" DIRECTORY)
set(FRAMESYNC_RUNTIME_DLLS
libgcc_s_seh-1.dll
libwinpthread-1.dll
libstdc++-6.dll
glfw3.dll
librtlsdr.dll
libhackrf.dll
libusb-1.0.dll
libzstd.dll
zlib1.dll
libogg-0.dll
libvorbis-0.dll
libvorbisenc-2.dll
libsqlite3-0.dll
WebView2Loader.dll
)
if(AIRSPY_FOUND)
list(APPEND FRAMESYNC_RUNTIME_DLLS libairspy.dll)
endif()
foreach(dll ${FRAMESYNC_RUNTIME_DLLS})
if(EXISTS "${MINGW_BIN}/${dll}")
add_custom_command(TARGET InmarScope POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${MINGW_BIN}/${dll}" "$<TARGET_FILE_DIR:InmarScope>"
COMMENT "Copying ${dll}")
else()
message(WARNING "Runtime DLL not found: ${MINGW_BIN}/${dll}")
endif()
endforeach()
# WebView2Loader.dll is not in the MINGW bin dir — copy from vendored SDK.
add_custom_command(TARGET InmarScope POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${WEBVIEW2_ROOT}/x64/WebView2Loader.dll"
"$<TARGET_FILE_DIR:InmarScope>"
COMMENT "Copying WebView2Loader.dll")
endif()