From 6fd9e4f5bcd1574b206cfe46e35ccc8e19707b33 Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 24 Feb 2016 11:51:36 +0100 Subject: [PATCH] cmake: added install and uninstall targets --- CMakeLists.txt | 34 +++++++++++++++++++ cmake_uninstall.cmake.in | 21 ++++++++++++ fcdhid/CMakeLists.txt | 2 ++ fcdlib/CMakeLists.txt | 2 ++ plugins/channel/am/CMakeLists.txt | 4 ++- plugins/channel/bfm/CMakeLists.txt | 4 ++- plugins/channel/chanalyzer/CMakeLists.txt | 2 ++ plugins/channel/lora/CMakeLists.txt | 2 ++ plugins/channel/nfm/CMakeLists.txt | 4 ++- plugins/channel/ssb/CMakeLists.txt | 2 ++ plugins/channel/tcpsrc/CMakeLists.txt | 2 ++ plugins/channel/udpsrc/CMakeLists.txt | 2 ++ plugins/channel/wfm/CMakeLists.txt | 4 ++- plugins/samplesource/airspy/CMakeLists.txt | 2 ++ plugins/samplesource/bladerf/CMakeLists.txt | 2 ++ plugins/samplesource/fcdpro/CMakeLists.txt | 2 ++ .../samplesource/fcdproplus/CMakeLists.txt | 2 ++ .../samplesource/filesource/CMakeLists.txt | 2 ++ plugins/samplesource/hackrf/CMakeLists.txt | 2 ++ plugins/samplesource/rtlsdr/CMakeLists.txt | 2 ++ plugins/samplesource/sdrdaemon/CMakeLists.txt | 2 ++ sdrbase/plugin/pluginmanager.cpp | 10 ++++-- 22 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 cmake_uninstall.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f5d9b1b2..7e09d655f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,23 @@ cmake_minimum_required(VERSION 3.0.2) cmake_policy(SET CMP0043 OLD) +# 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) + +# the RPATH to be used when installing, but only if it's not a system directory +list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) +if("${isSystemDir}" STREQUAL "-1") + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") +endif("${isSystemDir}" STREQUAL "-1") + +# 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) + option(V4L-RTL "Use Linux Kernel RTL-SDR Source." OFF) option(V4L-MSI "Use Linux Kernel MSI2500 Source." OFF) option(BUILD_TYPE "Build type (RELEASE, RELEASEWITHDBGINFO, DEBUG" RELEASE) @@ -357,3 +374,20 @@ if(LIBUSB_FOUND AND UNIX) add_subdirectory(fcdhid) add_subdirectory(fcdlib) endif(LIBUSB_FOUND AND UNIX) + +############################################################################## + +#install targets +install(TARGETS sdrangel DESTINATION bin) +install(TARGETS sdrbase DESTINATION lib) + +############################################################################## + +# uninstall target +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/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) diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in new file mode 100644 index 000000000..2c34c8199 --- /dev/null +++ b/cmake_uninstall.cmake.in @@ -0,0 +1,21 @@ +if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") +endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") + +file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) +string(REGEX REPLACE "\n" ";" files "${files}") +foreach(file ${files}) + message(STATUS "Uninstalling $ENV{DESTDIR}${file}") + if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + exec_program( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + if(NOT "${rm_retval}" STREQUAL 0) + message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") + endif(NOT "${rm_retval}" STREQUAL 0) + else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File $ENV{DESTDIR}${file} does not exist.") + endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") +endforeach(file) \ No newline at end of file diff --git a/fcdhid/CMakeLists.txt b/fcdhid/CMakeLists.txt index 45fb37102..f1d820cde 100644 --- a/fcdhid/CMakeLists.txt +++ b/fcdhid/CMakeLists.txt @@ -28,3 +28,5 @@ add_library(fcdhid SHARED target_link_libraries(fcdhid ${LIBUSB_LIBRARIES} ) + +install(TARGETS fcdhid DESTINATION lib) \ No newline at end of file diff --git a/fcdlib/CMakeLists.txt b/fcdlib/CMakeLists.txt index 487afb96a..d313bf85c 100644 --- a/fcdlib/CMakeLists.txt +++ b/fcdlib/CMakeLists.txt @@ -27,3 +27,5 @@ add_library(fcdlib SHARED ) target_link_libraries(fcdlib) + +install(TARGETS fcdlib DESTINATION lib) \ No newline at end of file diff --git a/plugins/channel/am/CMakeLists.txt b/plugins/channel/am/CMakeLists.txt index 77bbbdfd5..983d5d215 100644 --- a/plugins/channel/am/CMakeLists.txt +++ b/plugins/channel/am/CMakeLists.txt @@ -44,4 +44,6 @@ target_link_libraries(demodam sdrbase ) -qt5_use_modules(demodam Core Widgets OpenGL Multimedia) \ No newline at end of file +qt5_use_modules(demodam Core Widgets OpenGL Multimedia) + +install(TARGETS demodam DESTINATION lib/plugins/channel) \ No newline at end of file diff --git a/plugins/channel/bfm/CMakeLists.txt b/plugins/channel/bfm/CMakeLists.txt index fd78a8cc7..cfd0e3f28 100644 --- a/plugins/channel/bfm/CMakeLists.txt +++ b/plugins/channel/bfm/CMakeLists.txt @@ -51,4 +51,6 @@ target_link_libraries(demodbfm sdrbase ) -qt5_use_modules(demodbfm Core Widgets OpenGL Multimedia) \ No newline at end of file +qt5_use_modules(demodbfm Core Widgets OpenGL Multimedia) + +install(TARGETS demodbfm DESTINATION lib/plugins/channel) \ No newline at end of file diff --git a/plugins/channel/chanalyzer/CMakeLists.txt b/plugins/channel/chanalyzer/CMakeLists.txt index b25d28121..743bb3fbd 100644 --- a/plugins/channel/chanalyzer/CMakeLists.txt +++ b/plugins/channel/chanalyzer/CMakeLists.txt @@ -45,3 +45,5 @@ target_link_libraries(chanalyzer ) qt5_use_modules(chanalyzer Core Widgets OpenGL Multimedia) + +install(TARGETS chanalyzer DESTINATION lib/plugins/channel) diff --git a/plugins/channel/lora/CMakeLists.txt b/plugins/channel/lora/CMakeLists.txt index 209874b0b..149652655 100644 --- a/plugins/channel/lora/CMakeLists.txt +++ b/plugins/channel/lora/CMakeLists.txt @@ -45,3 +45,5 @@ target_link_libraries(demodlora ) qt5_use_modules(demodlora Core Widgets OpenGL Multimedia) + +install(TARGETS demodlora DESTINATION lib/plugins/channel) diff --git a/plugins/channel/nfm/CMakeLists.txt b/plugins/channel/nfm/CMakeLists.txt index feeb89116..75cf0b338 100644 --- a/plugins/channel/nfm/CMakeLists.txt +++ b/plugins/channel/nfm/CMakeLists.txt @@ -44,4 +44,6 @@ target_link_libraries(demodnfm sdrbase ) -qt5_use_modules(demodnfm Core Widgets OpenGL Multimedia) \ No newline at end of file +qt5_use_modules(demodnfm Core Widgets OpenGL Multimedia) + +install(TARGETS demodnfm DESTINATION lib/plugins/channel) \ No newline at end of file diff --git a/plugins/channel/ssb/CMakeLists.txt b/plugins/channel/ssb/CMakeLists.txt index e50d4ae5a..8ff93d773 100644 --- a/plugins/channel/ssb/CMakeLists.txt +++ b/plugins/channel/ssb/CMakeLists.txt @@ -45,3 +45,5 @@ target_link_libraries(demodssb ) qt5_use_modules(demodssb Core Widgets OpenGL Multimedia) + +install(TARGETS demodssb DESTINATION lib/plugins/channel) diff --git a/plugins/channel/tcpsrc/CMakeLists.txt b/plugins/channel/tcpsrc/CMakeLists.txt index df7c4d4da..fcf8c1e79 100644 --- a/plugins/channel/tcpsrc/CMakeLists.txt +++ b/plugins/channel/tcpsrc/CMakeLists.txt @@ -45,3 +45,5 @@ target_link_libraries(demodtcpsrc ) qt5_use_modules(demodtcpsrc Core Widgets OpenGL Network) + +install(TARGETS demodtcpsrc DESTINATION lib/plugins/channel) diff --git a/plugins/channel/udpsrc/CMakeLists.txt b/plugins/channel/udpsrc/CMakeLists.txt index c5a79b75f..938a05671 100644 --- a/plugins/channel/udpsrc/CMakeLists.txt +++ b/plugins/channel/udpsrc/CMakeLists.txt @@ -45,3 +45,5 @@ target_link_libraries(demodudpsrc ) qt5_use_modules(demodudpsrc Core Widgets OpenGL Network) + +install(TARGETS demodudpsrc DESTINATION lib/plugins/channel) diff --git a/plugins/channel/wfm/CMakeLists.txt b/plugins/channel/wfm/CMakeLists.txt index 552a129c4..8e11cb338 100644 --- a/plugins/channel/wfm/CMakeLists.txt +++ b/plugins/channel/wfm/CMakeLists.txt @@ -44,4 +44,6 @@ target_link_libraries(demodwfm sdrbase ) -qt5_use_modules(demodwfm Core Widgets OpenGL Multimedia) \ No newline at end of file +qt5_use_modules(demodwfm Core Widgets OpenGL Multimedia) + +install(TARGETS demodwfm DESTINATION lib/plugins/channel) \ No newline at end of file diff --git a/plugins/samplesource/airspy/CMakeLists.txt b/plugins/samplesource/airspy/CMakeLists.txt index b734742df..d49c18f1a 100644 --- a/plugins/samplesource/airspy/CMakeLists.txt +++ b/plugins/samplesource/airspy/CMakeLists.txt @@ -51,3 +51,5 @@ target_link_libraries(inputairspy ) qt5_use_modules(inputairspy Core Widgets OpenGL Multimedia) + +install(TARGETS inputairspy DESTINATION lib/plugins/samplesource) diff --git a/plugins/samplesource/bladerf/CMakeLists.txt b/plugins/samplesource/bladerf/CMakeLists.txt index ce61f68fb..406a7f256 100644 --- a/plugins/samplesource/bladerf/CMakeLists.txt +++ b/plugins/samplesource/bladerf/CMakeLists.txt @@ -50,3 +50,5 @@ target_link_libraries(inputbladerf ) qt5_use_modules(inputbladerf Core Widgets OpenGL Multimedia) + +install(TARGETS inputbladerf DESTINATION lib/plugins/samplesource) diff --git a/plugins/samplesource/fcdpro/CMakeLists.txt b/plugins/samplesource/fcdpro/CMakeLists.txt index b29faaf00..4f70e502d 100644 --- a/plugins/samplesource/fcdpro/CMakeLists.txt +++ b/plugins/samplesource/fcdpro/CMakeLists.txt @@ -53,3 +53,5 @@ target_link_libraries(inputfcdpro ) qt5_use_modules(inputfcdpro Core Widgets OpenGL Multimedia) + +install(TARGETS inputfcdpro DESTINATION lib/plugins/samplesource) \ No newline at end of file diff --git a/plugins/samplesource/fcdproplus/CMakeLists.txt b/plugins/samplesource/fcdproplus/CMakeLists.txt index 85ff6cbaf..c23702ba1 100644 --- a/plugins/samplesource/fcdproplus/CMakeLists.txt +++ b/plugins/samplesource/fcdproplus/CMakeLists.txt @@ -53,3 +53,5 @@ target_link_libraries(inputfcdproplus ) qt5_use_modules(inputfcdproplus Core Widgets OpenGL Multimedia) + +install(TARGETS inputfcdproplus DESTINATION lib/plugins/samplesource) diff --git a/plugins/samplesource/filesource/CMakeLists.txt b/plugins/samplesource/filesource/CMakeLists.txt index c94ac1a0b..248dc0a7a 100644 --- a/plugins/samplesource/filesource/CMakeLists.txt +++ b/plugins/samplesource/filesource/CMakeLists.txt @@ -45,3 +45,5 @@ target_link_libraries(inputfilesource ) qt5_use_modules(inputfilesource Core Widgets OpenGL Multimedia) + +install(TARGETS inputfilesource DESTINATION lib/plugins/samplesource) diff --git a/plugins/samplesource/hackrf/CMakeLists.txt b/plugins/samplesource/hackrf/CMakeLists.txt index c366e6d68..116acceec 100644 --- a/plugins/samplesource/hackrf/CMakeLists.txt +++ b/plugins/samplesource/hackrf/CMakeLists.txt @@ -51,3 +51,5 @@ target_link_libraries(inputhackrf ) qt5_use_modules(inputhackrf Core Widgets OpenGL Multimedia) + +install(TARGETS inputhackrf DESTINATION lib/plugins/samplesource) diff --git a/plugins/samplesource/rtlsdr/CMakeLists.txt b/plugins/samplesource/rtlsdr/CMakeLists.txt index 58b2f910f..e28775ebc 100644 --- a/plugins/samplesource/rtlsdr/CMakeLists.txt +++ b/plugins/samplesource/rtlsdr/CMakeLists.txt @@ -50,3 +50,5 @@ target_link_libraries(inputrtlsdr ) qt5_use_modules(inputrtlsdr Core Widgets OpenGL Multimedia) + +install(TARGETS inputrtlsdr DESTINATION lib/plugins/samplesource) diff --git a/plugins/samplesource/sdrdaemon/CMakeLists.txt b/plugins/samplesource/sdrdaemon/CMakeLists.txt index a191fe0f7..f69e8bf90 100644 --- a/plugins/samplesource/sdrdaemon/CMakeLists.txt +++ b/plugins/samplesource/sdrdaemon/CMakeLists.txt @@ -54,3 +54,5 @@ target_link_libraries(inputsdrdaemon ) qt5_use_modules(inputsdrdaemon Core Widgets OpenGL Multimedia) + +install(TARGETS inputsdrdaemon DESTINATION lib/plugins/samplesource) diff --git a/sdrbase/plugin/pluginmanager.cpp b/sdrbase/plugin/pluginmanager.cpp index bd660f7f3..988afcc0d 100644 --- a/sdrbase/plugin/pluginmanager.cpp +++ b/sdrbase/plugin/pluginmanager.cpp @@ -30,11 +30,15 @@ PluginManager::~PluginManager() void PluginManager::loadPlugins() { - qDebug() << "PluginManager::loadPlugins: " << qPrintable(QApplication::instance()->applicationDirPath()); + QString applicationDirPath = QApplication::instance()->applicationDirPath(); + QString applicationLibPath = applicationDirPath + "/../lib"; + qDebug() << "PluginManager::loadPlugins: " << qPrintable(applicationDirPath) << ", " << qPrintable(applicationLibPath); - QDir pluginsDir = QDir(QApplication::instance()->applicationDirPath()); + QDir pluginsBinDir = QDir(applicationDirPath); + QDir pluginsLibDir = QDir(applicationLibPath); - loadPlugins(pluginsDir); + loadPlugins(pluginsBinDir); + loadPlugins(pluginsLibDir); qSort(m_plugins);