File: 0006-feat-sigmf-Only-compile-support-if-libsigmf-is-found.patch

package info (click to toggle)
inspectrum 0.2.3-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,312 kB
  • sloc: cpp: 2,675; makefile: 3
file content (99 lines) | stat: -rw-r--r-- 2,681 bytes parent folder | download
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
From acf8c1d1759da7f800e8a991587a2a304d6f67ce Mon Sep 17 00:00:00 2001
From: schneider <schneider@blinkenlichts.net>
Date: Sat, 20 Feb 2021 12:35:23 +0100
Subject: [PATCH 06/31] feat(sigmf): Only compile support if libsigmf is found

---
 CMakeLists.txt  | 14 ++++++++++++--
 inputsource.cpp | 11 +++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b8f7285..f03e61b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -60,7 +60,7 @@ find_package(Qt5Widgets REQUIRED)
 find_package(Qt5Concurrent REQUIRED)
 find_package(FFTW REQUIRED)
 find_package(Liquid REQUIRED)
-find_package(libsigmf REQUIRED)
+find_package(libsigmf QUIET)
 
 include_directories(
     ${FFTW_INCLUDES}
@@ -71,10 +71,20 @@ add_executable(inspectrum ${EXE_ARGS} ${inspectrum_sources})
 
 target_link_libraries(inspectrum
     Qt5::Core Qt5::Widgets Qt5::Concurrent
-    libsigmf::libsigmf
     ${FFTW_LIBRARIES}
     ${LIQUID_LIBRARIES}
 )
+
+if (libsigmf_FOUND)
+    message("-- libsigmf found. Enabling SigMF support")
+    target_link_libraries(inspectrum
+        libsigmf::libsigmf
+    )
+    add_definitions(-DENABLE_SIGMF)
+else()
+    message("-- libsigmf not found. Disabling SigMF support")
+endif()
+
 set(INSTALL_DEFAULT_BINDIR "bin" CACHE STRING "Appended to CMAKE_INSTALL_PREFIX")
 
 install(TARGETS inspectrum RUNTIME DESTINATION ${INSTALL_DEFAULT_BINDIR})
diff --git a/inputsource.cpp b/inputsource.cpp
index caae783..59abe38 100644
--- a/inputsource.cpp
+++ b/inputsource.cpp
@@ -29,7 +29,9 @@
 
 #include <QFileInfo>
 
+#if ENABLE_SIGMF
 #include <sigmf/sigmf.h>
+#endif
 
 #include <QElapsedTimer>
 #include <QPainter>
@@ -194,6 +196,7 @@ void InputSource::cleanup()
     }
 }
 
+#if ENABLE_SIGMF
 void InputSource::readMetaData(const QString &filename)
 {
     QFile datafile(filename);
@@ -249,6 +252,7 @@ void InputSource::readMetaData(const QString &filename)
         annotationList.append(a);
     }
 }
+#endif
 
 
 void InputSource::openFile(const char *filename)
@@ -289,6 +293,8 @@ void InputSource::openFile(const char *filename)
     }
 
     QString dataFilename;
+
+#if ENABLE_SIGMF
     QString metaFilename;
 
     if (suffix == "sigmf-meta") {
@@ -304,6 +310,11 @@ void InputSource::openFile(const char *filename)
     else if (suffix == "sigmf") {
         throw std::runtime_error("SigMF archives are not supported. Consider extracting a recording.");
     }
+#else
+    if (suffix == "sigmf-meta" || suffix == "sigmf-data" || suffix == "sigmf") {
+        throw std::runtime_error("Support for SigMF recordings is not enabled");
+    }
+#endif
     else {
         dataFilename = filename;
     }
-- 
2.35.1