From 29e57cfddc9d710f479184c08a0e1a1905a15672 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Thu, 7 Mar 2019 10:58:40 +0100 Subject: [PATCH] Add PLUGINDIR cmake setting and define #7027 By default, plugins are only searched next to the binary or next to the other Qt plugins. This optional build variable allows another path to be configured. The idea is that on linux the oC packaging probably wants the binary in something like /opt/owncloud/bin and the plugins in /opt/owncloud/lib/plugins. Similarly, distribution packagers probably don't want the plugins next to the binary or next to the other Qt plugins. This flag allows them to configure another path that the executable will look in. --- CMakeLists.txt | 1 + config.h.in | 1 + src/gui/application.cpp | 11 +++++++++++ src/libsync/vfs/suffix/CMakeLists.txt | 4 ++-- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52c5be6938d..7d136703d52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,7 @@ if(WIN32) set(DATADIR "share") endif(WIN32) set(SHAREDIR ${DATADIR}) +set(PLUGINDIR "${CMAKE_INSTALL_FULL_LIBDIR}/${APPLICATION_SHORTNAME}/plugins" CACHE STRING "Extra path to look for Qt plugins like for VFS. May be relative to binary.") ##### ## handle BUILD_OWNCLOUD_OSX_BUNDLE diff --git a/config.h.in b/config.h.in index 68143d94357..2cddd8f6c0f 100644 --- a/config.h.in +++ b/config.h.in @@ -25,5 +25,6 @@ #cmakedefine SYSCONFDIR "@SYSCONFDIR@" #cmakedefine SHAREDIR "@SHAREDIR@" +#cmakedefine PLUGINDIR "@PLUGINDIR@" #endif diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 91d44dc4666..913eff61eb8 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -253,6 +253,17 @@ Application::Application(int &argc, char **argv) if (!AbstractNetworkJob::httpTimeout) AbstractNetworkJob::httpTimeout = cfg.timeout(); +#ifdef PLUGINDIR + // Setup extra plugin search path + QString extraPluginPath = QStringLiteral(PLUGINDIR); + if (!extraPluginPath.isEmpty()) { + if (QDir::isRelativePath(extraPluginPath)) + extraPluginPath = QDir(QApplication::applicationDirPath()).filePath(extraPluginPath); + qCInfo(lcApplication) << "Adding extra plugin search path:" << extraPluginPath; + addLibraryPath(extraPluginPath); + } +#endif + // Check vfs plugins if (Theme::instance()->showVirtualFilesOption() && bestAvailableVfsMode() == Vfs::Off) { qCWarning(lcApplication) << "Theme wants to show vfs mode, but no vfs plugins are available"; diff --git a/src/libsync/vfs/suffix/CMakeLists.txt b/src/libsync/vfs/suffix/CMakeLists.txt index d98347d5043..28699dccfab 100644 --- a/src/libsync/vfs/suffix/CMakeLists.txt +++ b/src/libsync/vfs/suffix/CMakeLists.txt @@ -14,7 +14,7 @@ set_target_properties("${synclib_NAME}_vfs_suffix" PROPERTIES ) INSTALL(TARGETS "${synclib_NAME}_vfs_suffix" - LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/plugins" - RUNTIME DESTINATION "${CMAKE_INSTALL_LIBDIR}/plugins" + LIBRARY DESTINATION "${PLUGINDIR}" + RUNTIME DESTINATION "${PLUGINDIR}" )