Add PLUGINDIR cmake setting and define #7027
authorChristian Kamm <mail@ckamm.de>
Thu, 7 Mar 2019 09:58:40 +0000 (10:58 +0100)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:58:43 +0000 (10:58 +0100)
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
config.h.in
src/gui/application.cpp
src/libsync/vfs/suffix/CMakeLists.txt

index 7da9f36deeabe3630df729bbcf3e4a86300b5b45..be6b4319a814d4c973dc02ea599da6cac523b2e0 100644 (file)
@@ -105,6 +105,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
index c645c0be6f3926b4cede34a677806f5b6cf9ca99..2dcf2d6f1a461425dc73029735fa3ecb1b2e736c 100644 (file)
@@ -33,5 +33,6 @@
 
 #cmakedefine SYSCONFDIR "@SYSCONFDIR@"
 #cmakedefine SHAREDIR "@SHAREDIR@"
+#cmakedefine PLUGINDIR "@PLUGINDIR@"
 
 #endif
index 90f81d45d69cd7cccd552dee0352955060805e89..fed5c6388ef2f39c3a41d23a78eeae6a0959992a 100644 (file)
@@ -269,6 +269,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";
index d98347d5043e779a435835deec08227e8901629b..28699dccfabe025c02e69f6fe2ced3834da1dd55 100644 (file)
@@ -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}"
 )