[PATCH] Make sdrangelove friendly for packaging

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/osmocom-sdr@lists.osmocom.org/.

Dave Olsthoorn dave at bewaar.me
Thu Apr 26 18:52:56 UTC 2018


This patch makes sdrangelove able to install through 'make install' and
also makes the plugin manager able to load from a specific directory
like /usr/lib64/sdrangelove/plugins while sdrangelove is inside /usr/bin.

To load plugins from a specific directory start cmake with
'-DSDRANGELOVE_PLUGIN_DIR:PATH=/path/to/plugin/directory' and compile,
to make installing even more easy 'make install' installs the plugins
in the specified directory.

Signed-off-by: Dave Olsthoorn <dave at bewaar.me>
---
 CMakeLists.txt                               | 24 ++++++++++++++++++++++++
 plugins/channel/nfm/CMakeLists.txt           |  6 +++++-
 plugins/channel/tcpsrc/CMakeLists.txt        |  5 +++++
 plugins/channel/tetra/CMakeLists.txt         |  4 ++++
 plugins/samplesource/gnuradio/CMakeLists.txt |  4 ++++
 plugins/samplesource/osmosdr/CMakeLists.txt  |  4 ++++
 plugins/samplesource/rtlsdr/CMakeLists.txt   |  4 ++++
 sdrbase/plugin/pluginmanager.cpp             | 13 ++++++++++++-
 8 files changed, 62 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 72ce30e..b0d38d5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,6 +21,10 @@ find_package(PkgConfig)
 find_package(FFTW3F)
 find_package(FFTS)
 
+IF(DEFINED SDRANGELOVE_PLUGIN_DIR)
+	add_definitions( -DSDRANGELOVE_PLUGIN_DIR=\"${SDRANGELOVE_PLUGIN_DIR}\")
+ENDIF()
+
 
 IF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|AMD64|x86")
  SET(USE_SIMD "SSE2" CACHE STRING "Use SIMD instructions")
@@ -250,6 +254,19 @@ target_link_libraries(sdrbase
 	${LIBUSB_LIBRARIES}
 )
 
+if(UNIX)
+# we only the version the library under unix systems
+set_target_properties(sdrbase PROPERTIES
+	VERSION 0.0.0
+	SOVERSION 0
+)
+
+# and only install in lib or lib64 under unix systems
+install(TARGETS sdrbase
+	LIBRARY DESTINATION lib${LIB_SUFFIX}
+)
+endif(UNIX)
+
 if(LIBFFTS_FOUND)
 	target_link_libraries(sdrbase ${LIBFFTS_LIBRARIES})
 else(LIBFFTS_FOUND)
@@ -308,6 +325,13 @@ target_link_libraries(sdrangelove
 	${OPENGL_LIBRARIES}
 )
 
+if(UNIX)
+# only install in bin when we are on unix
+install(TARGETS sdrangelove
+	RUNTIME DESTINATION bin
+)
+endif(UNIX)
+
 if(WIN32)
 	set_target_properties(sdrangelove PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
 	set_target_properties(sdrangelove PROPERTIES COMPILE_DEFINITIONS_DEBUG "_CONSOLE")
diff --git a/plugins/channel/nfm/CMakeLists.txt b/plugins/channel/nfm/CMakeLists.txt
index feeb891..7abfe56 100644
--- a/plugins/channel/nfm/CMakeLists.txt
+++ b/plugins/channel/nfm/CMakeLists.txt
@@ -44,4 +44,8 @@ target_link_libraries(demodnfm
 	sdrbase
 )
 
-qt5_use_modules(demodnfm Core Widgets OpenGL Multimedia)
\ No newline at end of file
+if(DEFINED SDRANGELOVE_PLUGIN_DIR)
+	install(TARGETS demodnfm DESTINATION ${SDRANGELOVE_PLUGIN_DIR})
+endif()
+
+qt5_use_modules(demodnfm Core Widgets OpenGL Multimedia)
diff --git a/plugins/channel/tcpsrc/CMakeLists.txt b/plugins/channel/tcpsrc/CMakeLists.txt
index df7c4d4..6ea431b 100644
--- a/plugins/channel/tcpsrc/CMakeLists.txt
+++ b/plugins/channel/tcpsrc/CMakeLists.txt
@@ -44,4 +44,9 @@ target_link_libraries(demodtcpsrc
 	sdrbase
 )
 
+if(DEFINED SDRANGELOVE_PLUGIN_DIR)
+        install(TARGETS demodtcpsrc DESTINATION ${SDRANGELOVE_PLUGIN_DIR})
+endif()
+
+
 qt5_use_modules(demodtcpsrc Core Widgets OpenGL Network)
diff --git a/plugins/channel/tetra/CMakeLists.txt b/plugins/channel/tetra/CMakeLists.txt
index f46c2bb..6cec401 100644
--- a/plugins/channel/tetra/CMakeLists.txt
+++ b/plugins/channel/tetra/CMakeLists.txt
@@ -44,4 +44,8 @@ target_link_libraries(demodtetra
 	sdrbase
 )
 
+if(DEFINED SDRANGELOVE_PLUGIN_DIR)
+        install(TARGETS demodtetra DESTINATION ${SDRANGELOVE_PLUGIN_DIR})
+endif()
+
 qt5_use_modules(demodtetra Core Widgets OpenGL Multimedia)
diff --git a/plugins/samplesource/gnuradio/CMakeLists.txt b/plugins/samplesource/gnuradio/CMakeLists.txt
index 0e08608..7dfa2dd 100644
--- a/plugins/samplesource/gnuradio/CMakeLists.txt
+++ b/plugins/samplesource/gnuradio/CMakeLists.txt
@@ -82,6 +82,10 @@ target_link_libraries(inputgnuradio
 	sdrbase
 )
 
+if(DEFINED SDRANGELOVE_PLUGIN_DIR)
+        install(TARGETS inputgnuradio DESTINATION ${SDRANGELOVE_PLUGIN_DIR})
+endif()
+
 qt5_use_modules(inputgnuradio Core Widgets OpenGL Multimedia)
 
 endif(Boost_FOUND AND GNURADIO_RUNTIME_FOUND AND GNURADIO_OSMOSDR_FOUND)
diff --git a/plugins/samplesource/osmosdr/CMakeLists.txt b/plugins/samplesource/osmosdr/CMakeLists.txt
index 9dc9705..5648277 100644
--- a/plugins/samplesource/osmosdr/CMakeLists.txt
+++ b/plugins/samplesource/osmosdr/CMakeLists.txt
@@ -51,4 +51,8 @@ target_link_libraries(inputosmosdr
 	sdrbase
 )
 
+if(DEFINED SDRANGELOVE_PLUGIN_DIR)
+        install(TARGETS inputosmosdr DESTINATION ${SDRANGELOVE_PLUGIN_DIR})
+endif()
+
 qt5_use_modules(inputosmosdr Core Widgets OpenGL Multimedia)
diff --git a/plugins/samplesource/rtlsdr/CMakeLists.txt b/plugins/samplesource/rtlsdr/CMakeLists.txt
index 35c4081..d7c78c6 100644
--- a/plugins/samplesource/rtlsdr/CMakeLists.txt
+++ b/plugins/samplesource/rtlsdr/CMakeLists.txt
@@ -47,4 +47,8 @@ target_link_libraries(inputrtlsdr
 	sdrbase
 )
 
+if(DEFINED SDRANGELOVE_PLUGIN_DIR)
+        install(TARGETS inputrtlsdr DESTINATION ${SDRANGELOVE_PLUGIN_DIR})
+endif()
+
 qt5_use_modules(inputrtlsdr Core Widgets OpenGL Multimedia)
diff --git a/sdrbase/plugin/pluginmanager.cpp b/sdrbase/plugin/pluginmanager.cpp
index 325fb8b..1c19388 100644
--- a/sdrbase/plugin/pluginmanager.cpp
+++ b/sdrbase/plugin/pluginmanager.cpp
@@ -8,6 +8,17 @@
 #include "dsp/dspengine.h"
 #include "dsp/samplesource/samplesource.h"
 
+/**
+ * Binaries are often placed in /usr/bin and plugins in /usr/lib* somewhere
+ *
+ * This ifdef and define is for packaging purposes so we can override the plugin directory
+ * since the plugins are not in the directory or the higher directories than where the binary
+ * exists. The original configuration is still the fallback.
+ */
+#ifndef SDRANGELOVE_PLUGIN_DIR
+#define SDRANGELOVE_PLUGIN_DIR QApplication::instance()->applicationDirPath()
+#endif
+
 PluginManager::PluginManager(MainWindow* mainWindow, DSPEngine* dspEngine, QObject* parent) :
 	QObject(parent),
 	m_pluginAPI(this, mainWindow, dspEngine),
@@ -25,7 +36,7 @@ PluginManager::~PluginManager()
 
 void PluginManager::loadPlugins()
 {
-	QDir pluginsDir = QDir(QApplication::instance()->applicationDirPath());
+	QDir pluginsDir = QDir(SDRANGELOVE_PLUGIN_DIR);
 
 	loadPlugins(pluginsDir);
 
-- 
2.14.3




More information about the osmocom-sdr mailing list