Skip to content

Commit

Permalink
Plugins: Add a relative plugin search path on Linux
Browse files Browse the repository at this point in the history
This fixes installations where the client is not installed in the same prefix as Qt

Fixes: owncloud#7801
  • Loading branch information
TheOneRing committed Apr 23, 2020
1 parent 66d6375 commit 5cce3ea
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ include(KDECompilerSettings NO_POLICY_SCOPE)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

find_package(Qt5 REQUIRED COMPONENTS Core)

if(UNIT_TESTING)
message(DEPRECATION "Setting UNIT_TESTING is deprecated please use BUILD_TESTING")
set(BUILD_TESTING TRUE)
endif()
include(CTest)


include(OCConfigPluginDir)
include("${CMAKE_CURRENT_LIST_DIR}/THEME.cmake")

set(synclib_NAME "${APPLICATION_EXECUTABLE}sync")
Expand Down
35 changes: 35 additions & 0 deletions cmake/modules/OCConfigPluginDir.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
function(IS_SUBDIR ROOT CHILD OUT)
file(RELATIVE_PATH REL_PATH "${ROOT}" "${CHILD}")
string(REGEX MATCH "^\.\./" NOT_SUBDIR "${REL_PATH}")
if (NOT_SUBDIR)
set(${OUT} FALSE PARENT_SCOPE)
else()
set(${OUT} TRUE PARENT_SCOPE)
endif()
endfunction()


if (UNIX AND NOT APPLE)
set(OC_PLUGIN_DIR ${KDE_INSTALL_FULL_PLUGINDIR})
IS_SUBDIR("${CMAKE_INSTALL_PREFIX}" "${OC_PLUGIN_DIR}" _is_subdir)
if (NOT _is_subdir)
if (KDE_INSTALL_USE_QT_SYS_PATHS)
message(FATAL_ERROR "Using KDE_INSTALL_USE_QT_SYS_PATHS with a non bundled Qt is not supported.")
else()
message(FATAL_ERROR "KDE_INSTALL_PLUGINDIR must be located in CMAKE_INSTALL_PREFIX")
endif()
endif()

include(ECMQueryQmake)
query_qmake(_qt_plugin_dir QT_INSTALL_PLUGINS TRY)
# any sub dir of _qt_plugin_dir is sufficient
IS_SUBDIR("${_qt_plugin_dir}" "${OC_PLUGIN_DIR}" _is_subdir)
if (_is_subdir)
# no need to add a additional plugin dir
unset(OC_PLUGIN_DIR)
else()
# set plugin dir to a path relative to the binary
file(RELATIVE_PATH OC_PLUGIN_DIR "${CMAKE_INSTALL_FULL_BINDIR}" "${OC_PLUGIN_DIR}")
message(STATUS "Adding additional plugin path: ${OC_PLUGIN_DIR}")
endif()
endif()
1 change: 1 addition & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#cmakedefine SYSCONFDIR "@SYSCONFDIR@"
#cmakedefine SHAREDIR "@SHAREDIR@"
#cmakedefine OC_PLUGIN_DIR "@OC_PLUGIN_DIR@"

#cmakedefine01 GUI_TESTING

Expand Down
6 changes: 6 additions & 0 deletions src/gui/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ Application::Application(int &argc, char **argv)
if (!AbstractNetworkJob::httpTimeout)
AbstractNetworkJob::httpTimeout = cfg.timeout();

#if defined(OC_PLUGIN_DIR) && defined(Q_OS_LINUX)
const QString extraPluginDir = QDir(QApplication::applicationDirPath()).filePath(QStringLiteral(OC_PLUGIN_DIR));
qCInfo(lcApplication) << "Adding extra plugin search path:" << extraPluginDir;
this->addLibraryPath(extraPluginDir);
#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";
Expand Down

0 comments on commit 5cce3ea

Please sign in to comment.