From 0d57cc39ca41555d6b0a065661fe3fbf59f27c0c Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Mon, 10 Feb 2025 13:33:11 +0100 Subject: [PATCH] add cmake switch to force recursive plugin loading --- CMakeLists.txt | 16 ++++++++-------- src/librssguard/CMakeLists.txt | 7 +++++++ src/librssguard/miscellaneous/pluginfactory.cpp | 4 ++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f78d07dd..33c183bbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,14 +110,6 @@ if(APPLE) add_link_options(-stdlib=libc++) endif() -if(FORCE_COLORED_OUTPUT) - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - add_compile_options(-fdiagnostics-color=always) - elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - add_compile_options(-fcolor-diagnostics) - endif() -endif() - # Global compilation switches. option(BUILD_WITH_QT6 "Build application with Qt 6." ON) option(BUILD_MSYS2 "Build application for MSYS2 ecosystem." OFF) @@ -125,6 +117,7 @@ option(USE_SYSTEM_SQLITE "Use system-wide SQLite3 library." ON) option(NO_LITE "Enable QtWebEngine and other more demanding components." ON) option(UPDATE_TRANSLATIONS "Call lupdate to update translation files from source (Qt 6 only)." OFF) option(FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GCC/Clang only)." OFF) +option(LOAD_PLUGINS_FROM_PARENT "Force loading of plugin libraries from parent folder." OFF) option(REVISION_FROM_GIT "Get revision using `git rev-parse`." ON) option(NO_UPDATE_CHECK "Disable automatic checking for new application updates." OFF) option(IS_FLATPAK_BUILD "Set to 'ON' when building RSS Guard with Flatpak." OFF) @@ -163,6 +156,13 @@ if(MINGW AND NO_LITE) set(NO_LITE OFF) endif() +if(FORCE_COLORED_OUTPUT) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + add_compile_options(-fdiagnostics-color=always) + elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + add_compile_options(-fcolor-diagnostics) + endif() +endif() if(ENABLE_MEDIAPLAYER_QTMULTIMEDIA AND ENABLE_MEDIAPLAYER_LIBMPV) message(FATAL_ERROR "You can only enable 1 media player backend.") diff --git a/src/librssguard/CMakeLists.txt b/src/librssguard/CMakeLists.txt index 09318ca92..ee9b9cb67 100644 --- a/src/librssguard/CMakeLists.txt +++ b/src/librssguard/CMakeLists.txt @@ -656,6 +656,13 @@ target_compile_definitions(rssguard RSSGUARD_LIBDIR="${CMAKE_INSTALL_LIBDIR}" ) +if(LOAD_PLUGINS_FROM_PARENT) + target_compile_definitions(rssguard + PRIVATE + LOAD_PLUGINS_FROM_PARENT + ) +endif() + # Install public headers. set(HEADERS_ROOT "${PROJECT_SOURCE_DIR}/src/librssguard") file(GLOB_RECURSE HEADER_FILES RELATIVE ${HEADERS_ROOT} "*.h") diff --git a/src/librssguard/miscellaneous/pluginfactory.cpp b/src/librssguard/miscellaneous/pluginfactory.cpp index be4c1f596..2f32dd816 100644 --- a/src/librssguard/miscellaneous/pluginfactory.cpp +++ b/src/librssguard/miscellaneous/pluginfactory.cpp @@ -24,7 +24,7 @@ QList PluginFactory::loadPlugins() const { QDirIterator dir_iter(plugin_folder, {plugin_name_wildcard}, QDir::Filter::Files, -#if !defined(NDEBUG) +#if !defined(NDEBUG) || defined(LOAD_PLUGINS_FROM_PARENT) QDirIterator::IteratorFlag::Subdirectories); #else QDirIterator::IteratorFlag::NoIteratorFlags); @@ -82,7 +82,7 @@ QStringList PluginFactory::pluginPaths() const { paths << QCoreApplication::applicationDirPath(); #endif -#if !defined(NDEBUG) +#if !defined(NDEBUG) || defined(LOAD_PLUGINS_FROM_PARENT) paths << QCoreApplication::applicationDirPath() + QDir::separator() + QL1S("..") + QDir::separator(); #endif