Skip to content

Commit

Permalink
new cmake build option tailored for msys2 flavor of rssguard
Browse files Browse the repository at this point in the history
  • Loading branch information
martinrotter committed Nov 27, 2024
1 parent cc674a3 commit 8b5f7ec
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 28 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#
# Variables:
# BUILD_WITH_QT6 - Build either with Qt 6 or Qt 5.
# BUILD_MSYS2 - Build RSS Guard for MSYS2 distribution, this particularly
# enables relevant MSYS2 FHS tweaks.
# USE_SYSTEM_SQLITE - Use system-wide SQLite3 library and header file. Defaults to "ON".
# NO_UPDATE_CHECK - Disable automatic checking for new application updates.
# IS_FLATPAK_BUILD - Set to "ON" when building RSS Guard with Flatpak.
Expand Down Expand Up @@ -118,6 +120,7 @@ endif()

# Global compilation switches.
option(BUILD_WITH_QT6 "Build application with Qt 6." ON)
option(BUILD_MSYS2 "Build application for MSYS2 ecosystem." OFF)
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)
Expand Down Expand Up @@ -288,6 +291,10 @@ if(IS_FLATPAK_BUILD)
add_compile_definitions(IS_FLATPAK_BUILD)
endif()

if(BUILD_MSYS2)
add_compile_definitions(BUILD_MSYS2)
endif()

# Configure and copy some needed files.
if(WIN32)
configure_file(
Expand Down
8 changes: 2 additions & 6 deletions src/cmake_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,9 @@ function(prepare_rssguard_plugin plugin_target_name)
${LIBRSSGUARD_SOURCE_PATH}
)

if(MSVC OR OS2)
if((WIN32 AND NOT BUILD_MSYS2) OR OS2)
install(TARGETS ${plugin_target_name} DESTINATION plugins)
elseif(MINGW)
include (GNUInstallDirs)
install(TARGETS ${plugin_target_name}
DESTINATION ${CMAKE_INSTALL_DATADIR}/rssguard/plugins)
elseif(UNIX AND NOT APPLE AND NOT ANDROID)
elseif((MINGW AND BUILD_MSYS2) OR (UNIX AND NOT APPLE AND NOT ANDROID))
include (GNUInstallDirs)
install(TARGETS ${plugin_target_name}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/rssguard
Expand Down
4 changes: 2 additions & 2 deletions src/librssguard/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -628,10 +628,10 @@ elseif(WIN32)
)
endif()

if(MSVC OR OS2)
if((WIN32 AND NOT BUILD_MSYS2) OR OS2)
install(TARGETS rssguard DESTINATION .)
set(HEADERS_FOLDER "include/librssguard")
elseif(MINGW)
elseif(MINGW AND BUILD_MSYS2)
include (GNUInstallDirs)
install(TARGETS rssguard
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand Down
5 changes: 0 additions & 5 deletions src/librssguard/miscellaneous/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,12 +579,7 @@ QString Application::userDataAppFolder() const {

// In "app" folder, we would like to separate all user data into own subfolder,
// therefore stick to "data" folder in this mode.
#ifdef _MSC_VER
return QDir::toNativeSeparators(applicationDirPath() + QDir::separator() + QSL("data%1").arg(major_version));
#else
return QDir::toNativeSeparators(applicationDirPath() + QDir::separator() + QSL("..") + QDir::separator() +
QSL("share") + QDir::separator() + QSL(APP_LOW_NAME) + QDir::separator() + QSL("data%1").arg(major_version));
#endif
}

QString Application::userDataFolder() {
Expand Down
7 changes: 1 addition & 6 deletions src/librssguard/miscellaneous/pluginfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,11 @@ QList<ServiceEntryPoint*> PluginFactory::loadPlugins() const {
QStringList PluginFactory::pluginPaths() const {
QStringList paths;

#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD) || defined(BUILD_MSYS2)
paths << QCoreApplication::applicationDirPath() + QDir::separator() + QL1S("..") + QDir::separator() +
QL1S(RSSGUARD_LIBDIR) + QDir::separator() + QL1S(APP_LOW_NAME);
#elif defined(Q_OS_WIN)
#ifdef _MSC_VER
paths << QCoreApplication::applicationDirPath() + QDir::separator() + QL1S("plugins");
#else
paths << QCoreApplication::applicationDirPath() + QDir::separator() + QL1S("..") + QDir::separator() +
QL1S("share") + QDir::separator() + QL1S(APP_LOW_NAME) + QDir::separator() + QL1S("plugins");
#endif
#else
paths << QCoreApplication::applicationDirPath();
#endif
Expand Down
11 changes: 6 additions & 5 deletions src/librssguard/miscellaneous/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ DKEY Node::ID = "nodejs";

DKEY Node::NodeJsExecutable = QSL("nodejs_executable_") + OS_ID;

#if (defined(Q_OS_WIN) && defined(_MSC_VER)) || defined(Q_OS_OS2)
#if (defined(Q_OS_WIN) && !defined(BUILD_MSYS2)) || defined(Q_OS_OS2)
DVALUE(QString) Node::NodeJsExecutableDef = "node.exe";
#else
DVALUE(QString) Node::NodeJsExecutableDef = "node";
#endif

DKEY Node::NpmExecutable = QSL("npm_executable_") + OS_ID;

#if defined(Q_OS_WIN) && defined(_MSC_VER)
#if defined(Q_OS_WIN) && !defined(BUILD_MSYS2)
DVALUE(QString) Node::NpmExecutableDef = "npm.cmd";
#elif defined(Q_OS_OS2)
DVALUE(QString) Node::NpmExecutableDef = "npm.exe";
Expand Down Expand Up @@ -620,6 +620,7 @@ SettingsProperties Settings::determineProperties() {
SettingsProperties properties;

properties.m_settingsSuffix = QDir::separator() + QSL(APP_CFG_PATH) + QDir::separator() + QSL(APP_CFG_FILE);

const QString app_path = qApp->userDataAppFolder();
const QString home_path = qApp->userDataHomeFolder();
const QString custom_path = qApp->customDataFolder();
Expand All @@ -630,10 +631,10 @@ SettingsProperties Settings::determineProperties() {
properties.m_baseDirectory = custom_path;
}
else {
// We will use PORTABLE settings only and only if it is available and NON-PORTABLE
// We will use PORTABLE settings only if it is available and NON-PORTABLE
// settings was not initialized before.
#if defined(Q_OS_UNIX)
// DO NOT use portable settings for *nix, it is really not used on that platform.
#if defined(Q_OS_UNIX) || defined(BUILD_MSYS2)
// DO NOT use portable settings for *nix or MSYS2, it is really not used on those platforms.
const bool will_we_use_portable_settings = false;
#else
const QString exe_path = qApp->applicationDirPath();
Expand Down
6 changes: 2 additions & 4 deletions src/rssguard/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ elseif(WIN32)
)
endif()

if(MSVC)
if(WIN32 AND NOT BUILD_MSYS2)
install(TARGETS app DESTINATION .)
install(FILES ${CMAKE_SOURCE_DIR}/resources/graphics/${CMAKE_PROJECT_NAME}.ico
DESTINATION .
Expand All @@ -55,9 +55,7 @@ if(MSVC)
)
elseif(OS2)
install(TARGETS app DESTINATION .)
elseif(MINGW)
install(TARGETS app DESTINATION ${CMAKE_INSTALL_BINDIR})
elseif(UNIX AND NOT APPLE AND NOT ANDROID)
elseif((MINGW AND BUILD_MSYS2) OR (UNIX AND NOT APPLE AND NOT ANDROID))
include (GNUInstallDirs)
install(TARGETS app
DESTINATION ${CMAKE_INSTALL_BINDIR}
Expand Down

0 comments on commit 8b5f7ec

Please sign in to comment.