[plasma/plasma-integration] /: Use explicit WITH_X11 build option instead of relying on HAVE_X11 automagic
Andreas Sturmlechner <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 2799cfcb275c2ffd580e50a525ca78d3d269bd2a by Andreas Sturmlechner. Committed on 24/07/2026 at 17:31. Pushed by asturmlechner into branch 'master'. Use explicit WITH_X11 build option instead of relying on HAVE_X11 automagic - Make XCB dependency and platformtheme x11integration conditional on WITH_X11 - Move finding X11 dependency to root CMakeLists.txt WITH_X11 conditional - Signal that we are specifically looking for libXcursor here - Cleanup duplicate XCB findings in platformtheme subdirs - Move WITH_X11-conditional finding Qt5X11Extras to qt5 subfolder - Fix tests to respect the same conditionals as in platformtheme subfolder Signed-off-by: Andreas Sturmlechner <[email protected]> M +19 -7 CMakeLists.txt M +7 -3 qt5/CMakeLists.txt M +9 -3 qt5/autotests/CMakeLists.txt M +0 -3 qt5/autotests/kdeplatformtheme_unittest.cpp M +8 -18 qt5/src/platformtheme/CMakeLists.txt M +1 -1 qt5/src/platformtheme/config-platformtheme.h.cmake M +1 -1 qt5/src/platformtheme/kdeplatformtheme.cpp M +2 -6 qt5/src/platformtheme/khintssettings.cpp M +5 -14 qt6/CMakeLists.txt M +9 -2 qt6/autotests/CMakeLists.txt M +0 -3 qt6/autotests/kdeplatformtheme_unittest.cpp M +8 -17 qt6/src/platformtheme/CMakeLists.txt M +1 -1 qt6/src/platformtheme/config-platformtheme.h.cmake M +1 -1 qt6/src/platformtheme/kdeplatformtheme.cpp M +2 -6 qt6/src/platformtheme/khintssettings.cpp https://invent.kde.org/plasma/plasma-integration/-/commit/2799cfcb275c2ffd580e50a525ca78d3d269bd2a diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c89160a..6bb7d89e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,13 +53,25 @@ elseif($ENV{CI_JOB_NAME_SLUG} MATCHES "qt6") set(BUILD_QT6 ON) endif() -find_package(XCB COMPONENTS XCB) -set_package_properties(XCB PROPERTIES - DESCRIPTION "X protocol C-language Binding" - URL "https://xcb.freedesktop.org" - TYPE REQUIRED - PURPOSE "Required to pass style properties to native Windows on X11 Platform" -) +option(WITH_X11 "Build platformtheme with X11 (and XWayland) support" ON) + +if (WITH_X11) + find_package(XCB COMPONENTS XCB) + set_package_properties(XCB PROPERTIES + DESCRIPTION "X protocol C-language Binding" + URL "https://xcb.freedesktop.org" + TYPE REQUIRED + PURPOSE "Required to pass style properties to native Windows on X11 Platform" + ) + find_package(X11) + set_package_properties(X11 PROPERTIES DESCRIPTION "Required for updating the Cursor theme on X11" + URL "https://www.x.org" + TYPE REQUIRED + ) + if (NOT TARGET X11::Xcursor) + message(SEND_ERROR "Required component Xcursor of X11 was not found") + endif() +endif() find_package(FontNotoSans) set_package_properties(FontNotoSans PROPERTIES diff --git a/qt5/CMakeLists.txt b/qt5/CMakeLists.txt index 7b8aaf92..7ad9eda1 100644 --- a/qt5/CMakeLists.txt +++ b/qt5/CMakeLists.txt @@ -5,7 +5,11 @@ include(KDECMakeSettings) find_package(Qt5 ${QT5_MIN_VERSION} CONFIG REQUIRED Widgets DBus QuickControls2 WaylandClient) find_package(Qt5Gui ${QT5_MIN_VERSION} CONFIG REQUIRED Private) -find_package(Qt5 ${QT5_MIN_VERSION} CONFIG REQUIRED X11Extras) + +# platformtheme +if(WITH_X11) + find_package(Qt5X11Extras ${QT5_MIN_VERSION} CONFIG REQUIRED) +endif() # https://bugreports.qt.io/browse/QTBUG-114706 add_library(Qt::Core ALIAS Qt5::Core) @@ -13,8 +17,8 @@ add_library(Qt::Network ALIAS Qt5::Network) add_library(Qt::Gui ALIAS Qt5::Gui) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS - Config I18n IconThemes KIO Notifications - WindowSystem Wayland GuiAddons + Config GuiAddons I18n IconThemes KIO + Notifications Wayland WindowSystem ) find_package(QtWaylandScanner ${QT5_MIN_VERSION} REQUIRED) diff --git a/qt5/autotests/CMakeLists.txt b/qt5/autotests/CMakeLists.txt index 572dd218..f10a0711 100644 --- a/qt5/autotests/CMakeLists.txt +++ b/qt5/autotests/CMakeLists.txt @@ -43,11 +43,12 @@ macro(FRAMEWORKINTEGRATION_TESTS _testname) KF5::WindowSystem KF5::GuiAddons Qt5::WaylandClient - XCB::XCB Wayland::Client KF5::WaylandClient - Qt5::X11Extras ) + if(WITH_X11) + target_link_libraries(${_testname}5 Qt5::X11Extras X11::Xcursor XCB::XCB) + endif() endmacro() set(dbus_interface) @@ -75,7 +76,6 @@ target_sources(kdeplatformtheme_unittest5 PRIVATE ../src/platformtheme/kdeplatformfiledialogbase.cpp ../src/platformtheme/kdeplatformsystemtrayicon.cpp ../src/platformtheme/kdeplatformsystemtrayicon.h ../src/platformtheme/kwaylandintegration.cpp ../src/platformtheme/kwaylandintegration.h - ../src/platformtheme/x11integration.cpp ../src/platformtheme/x11integration.h ../src/platformtheme/qxdgdesktopportalfiledialog.cpp ${dbus_interface} ${wayland_interfaces} @@ -84,6 +84,12 @@ target_sources(kdeplatformtheme_unittest5 PRIVATE ../src/platformtheme/qdbusmenubar.cpp # fork of Qt's qdbusmenubar with some added setters for our convenience ) +if(WITH_X11) + target_sources(kdeplatformtheme_unittest5 PRIVATE + ../src/platformtheme/x11integration.cpp ../src/platformtheme/x11integration.h + ) +endif() + frameworkintegration_tests( kfontsettingsdata_unittest ../src/platformtheme/kfontsettingsdata.cpp ../src/platformtheme/kfontsettingsdata.h diff --git a/qt5/autotests/kdeplatformtheme_unittest.cpp b/qt5/autotests/kdeplatformtheme_unittest.cpp index d4cd6dec..4911a6f9 100644 --- a/qt5/autotests/kdeplatformtheme_unittest.cpp +++ b/qt5/autotests/kdeplatformtheme_unittest.cpp @@ -7,9 +7,6 @@ #include "../src/platformtheme/kdeplatformtheme.h" #include "../src/platformtheme/khintssettings.h" #include "kdeplatformtheme_config.h" -#include <config-platformtheme.h> -#undef HAVE_X11 -#define HAVE_X11 0 #include <QApplication> #include <QDialogButtonBox> diff --git a/qt5/src/platformtheme/CMakeLists.txt b/qt5/src/platformtheme/CMakeLists.txt index b35fcf8a..dceb184e 100644 --- a/qt5/src/platformtheme/CMakeLists.txt +++ b/qt5/src/platformtheme/CMakeLists.txt @@ -1,16 +1,3 @@ -find_package(X11) -set_package_properties(X11 PROPERTIES DESCRIPTION "Required for updating the Cursor theme on X11" - URL "https://www.x.org" - TYPE REQUIRED - ) -set(HAVE_X11 ${X11_FOUND}) -if(HAVE_X11) - find_package(Qt5 ${QT5_MIN_VERSION} CONFIG REQUIRED X11Extras) - - find_package(XCB COMPONENTS XCB) - set_package_properties(XCB PROPERTIES TYPE REQUIRED) -endif() - configure_file(config-platformtheme.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-platformtheme.h ) # qdbusmenubar uses them @@ -24,13 +11,18 @@ set(platformtheme_SRCS kdeplatformfiledialogbase.cpp kdeplatformsystemtrayicon.cpp kdeplatformsystemtrayicon.h kwaylandintegration.cpp kwaylandintegration.h - x11integration.cpp x11integration.h main.cpp qxdgdesktopportalfiledialog.cpp qtquickrenderersettings.cpp ) list(APPEND platformtheme_SRCS qdbusmenubar.cpp) # fork of Qt's qdbusmenubar with some added setters for our convenience +if(WITH_X11) + list(APPEND platformtheme_SRCS + x11integration.cpp x11integration.h + ) +endif() + qt5_add_dbus_interface(platformtheme_SRCS org.kde.StatusNotifierWatcher.xml statusnotifierwatcher_interface) kconfig_add_kcfg_files(platformtheme_SRCS renderersettings.kcfgc) add_library(KDEPlasmaPlatformTheme5 MODULE) @@ -59,17 +51,15 @@ target_link_libraries(KDEPlasmaPlatformTheme5 KF5::Notifications KF5::WindowSystem KF5::GuiAddons - XCB::XCB ${QT5PLATFORMSUPPORT_LIBS} Qt5::WaylandClient Qt5::GuiPrivate Wayland::Client KF5::WaylandClient ) -target_link_libraries(KDEPlasmaPlatformTheme5 PRIVATE Qt5::X11Extras) -if(HAVE_X11) - target_link_libraries(KDEPlasmaPlatformTheme5 PRIVATE ${X11_Xcursor_LIB} ${XCB_XCB_LIBRARY}) +if(WITH_X11) + target_link_libraries(KDEPlasmaPlatformTheme5 PRIVATE Qt5::X11Extras X11::Xcursor XCB::XCB) endif() set_target_properties(KDEPlasmaPlatformTheme5 PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/platformthemes/") diff --git a/qt5/src/platformtheme/config-platformtheme.h.cmake b/qt5/src/platformtheme/config-platformtheme.h.cmake index 89858d17..03550c09 100644 --- a/qt5/src/platformtheme/config-platformtheme.h.cmake +++ b/qt5/src/platformtheme/config-platformtheme.h.cmake @@ -1 +1 @@ -#cmakedefine01 HAVE_X11 +#cmakedefine01 WITH_X11 diff --git a/qt5/src/platformtheme/kdeplatformtheme.cpp b/qt5/src/platformtheme/kdeplatformtheme.cpp index 4ade3856..61fcba39 100644 --- a/qt5/src/platformtheme/kdeplatformtheme.cpp +++ b/qt5/src/platformtheme/kdeplatformtheme.cpp @@ -287,7 +287,7 @@ KdePlatformTheme::KdePlatformTheme() m_kwaylandIntegration.reset(new KWaylandIntegration(this)); } -#if HAVE_X11 +#if WITH_X11 if (KWindowSystem::isPlatformX11()) { m_x11Integration.reset(new X11Integration(this)); m_x11Integration->init(); diff --git a/qt5/src/platformtheme/khintssettings.cpp b/qt5/src/platformtheme/khintssettings.cpp index 5efe9ef5..48905f63 100644 --- a/qt5/src/platformtheme/khintssettings.cpp +++ b/qt5/src/platformtheme/khintssettings.cpp @@ -34,11 +34,7 @@ #include <kiconloader.h> #include <config-platformtheme.h> -#ifdef UNIT_TEST -#undef HAVE_X11 -#define HAVE_X11 0 -#endif -#if HAVE_X11 +#if WITH_X11 #include <QX11Info> #include <X11/Xcursor/Xcursor.h> #endif @@ -457,7 +453,7 @@ void KHintsSettings::updateCursorTheme() void KHintsSettings::updateX11CursorTheme() { -#if HAVE_X11 +#if WITH_X11 if (QX11Info::isPlatformX11()) { KConfig config(QStringLiteral("kcminputrc")); KConfigGroup g(&config, "Mouse"); diff --git a/qt6/CMakeLists.txt b/qt6/CMakeLists.txt index 5083755c..fbdb635b 100644 --- a/qt6/CMakeLists.txt +++ b/qt6/CMakeLists.txt @@ -5,34 +5,25 @@ include(KDECMakeSettings) find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED Widgets DBus QuickControls2 WaylandClient) -if (Qt6Gui_VERSION VERSION_GREATER_EQUAL "6.10.0") - find_package(Qt6GuiPrivate ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE) -else() - find_package(Qt6Gui ${QT_MIN_VERSION} CONFIG REQUIRED Private) -endif() +find_package(Qt6GuiPrivate ${QT_MIN_VERSION} REQUIRED NO_MODULE) # https://bugreports.qt.io/browse/QTBUG-114706 add_library(Qt::Core ALIAS Qt6::Core) add_library(Qt::Network ALIAS Qt6::Network) add_library(Qt::OpenGL ALIAS Qt6::OpenGL) add_library(Qt::Gui ALIAS Qt6::Gui) -if(Qt6_VERSION_MINOR GREATER 6) - add_library(Qt::PlatformModuleInternal ALIAS Qt6::PlatformModuleInternal) -endif() +add_library(Qt::PlatformModuleInternal ALIAS Qt6::PlatformModuleInternal) find_package(KF6 ${KF6_MIN_VERSION} REQUIRED COMPONENTS - Config I18n IconThemes KIO Notifications - WindowSystem GuiAddons - StatusNotifierItem + ColorScheme Config GuiAddons I18n IconThemes + KIO Notifications StatusNotifierItem + WindowSystem ) -find_package(KF6ColorScheme ${KF6_MIN_VERSION} REQUIRED CONFIG) - ecm_set_disabled_deprecation_versions(QT 5.15.2 KF 5.101 ) -find_package(KF6I18n CONFIG REQUIRED) ki18n_install(../po) add_subdirectory(src) diff --git a/qt6/autotests/CMakeLists.txt b/qt6/autotests/CMakeLists.txt index 9dc509f8..b4993242 100644 --- a/qt6/autotests/CMakeLists.txt +++ b/qt6/autotests/CMakeLists.txt @@ -44,10 +44,12 @@ macro(FRAMEWORKINTEGRATION_TESTS _testname) KF6::WindowSystem KF6::GuiAddons Qt6::WaylandClient - XCB::XCB Wayland::Client KF6::ColorScheme ) + if(WITH_X11) + target_link_libraries(${_testname}6 X11::Xcursor XCB::XCB) + endif() endmacro() set(dbus_interface) @@ -74,7 +76,6 @@ target_sources(kdeplatformtheme_unittest6 PRIVATE ../src/platformtheme/kdeplatformfiledialogbase.cpp ../src/platformtheme/kdeplatformsystemtrayicon.cpp ../src/platformtheme/kdeplatformsystemtrayicon.h ../src/platformtheme/kwaylandintegration.cpp ../src/platformtheme/kwaylandintegration.h - ../src/platformtheme/x11integration.cpp ../src/platformtheme/x11integration.h ../src/platformtheme/qxdgdesktopportalfiledialog.cpp ../src/platformtheme/qdbusmenubarwrapper.h ../src/platformtheme/kiodelegate.cpp @@ -86,6 +87,12 @@ target_sources(kdeplatformtheme_unittest6 PRIVATE # TODO KF6 Port D-Bus menu support target_compile_definitions(kdeplatformtheme_unittest6 PRIVATE -DKF6_TODO_DBUS_MENUBAR) +if(WITH_X11) + target_sources(kdeplatformtheme_unittest6 PRIVATE + ../src/platformtheme/x11integration.cpp ../src/platformtheme/x11integration.h + ) +endif() + frameworkintegration_tests( kfontsettingsdata_unittest ../src/platformtheme/kfontsettingsdata.cpp ../src/platformtheme/kfontsettingsdata.h diff --git a/qt6/autotests/kdeplatformtheme_unittest.cpp b/qt6/autotests/kdeplatformtheme_unittest.cpp index f75b8258..379cc602 100644 --- a/qt6/autotests/kdeplatformtheme_unittest.cpp +++ b/qt6/autotests/kdeplatformtheme_unittest.cpp @@ -7,9 +7,6 @@ #include "../src/platformtheme/kdeplatformtheme.h" #include "../src/platformtheme/khintssettings.h" #include "kdeplatformtheme_config.h" -#include <config-platformtheme.h> -#undef HAVE_X11 -#define HAVE_X11 0 #include <QApplication> #include <QDialogButtonBox> diff --git a/qt6/src/platformtheme/CMakeLists.txt b/qt6/src/platformtheme/CMakeLists.txt index 3096a1ad..c6272597 100644 --- a/qt6/src/platformtheme/CMakeLists.txt +++ b/qt6/src/platformtheme/CMakeLists.txt @@ -1,15 +1,3 @@ -find_package(X11) -set_package_properties(X11 PROPERTIES DESCRIPTION "Required for updating the Cursor theme on X11" - URL "https://www.x.org" - TYPE REQUIRED - ) -set(HAVE_X11 ${X11_FOUND}) -if(HAVE_X11) - - find_package(XCB COMPONENTS XCB) - set_package_properties(XCB PROPERTIES TYPE REQUIRED) -endif() - configure_file(config-platformtheme.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-platformtheme.h ) set(platformtheme_SRCS @@ -22,7 +10,6 @@ set(platformtheme_SRCS kdeplatformcolordialoghelper.cpp kdeplatformcolordialoghelper.h kdeplatformsystemtrayicon.cpp kdeplatformsystemtrayicon.h kwaylandintegration.cpp kwaylandintegration.h - x11integration.cpp x11integration.h main.cpp qxdgdesktopportalfiledialog.cpp qtquickrenderersettings.cpp @@ -32,6 +19,12 @@ set(platformtheme_SRCS kioopenwithxdp.cpp ) +if(WITH_X11) + list(APPEND platformtheme_SRCS + x11integration.cpp x11integration.h + ) +endif() + qt6_add_dbus_interface(platformtheme_SRCS org.kde.StatusNotifierWatcher.xml statusnotifierwatcher_interface) kconfig_add_kcfg_files(platformtheme_SRCS renderersettings.kcfgc) add_library(KDEPlasmaPlatformTheme6 MODULE) @@ -65,16 +58,14 @@ target_link_libraries(KDEPlasmaPlatformTheme6 KF6::Notifications KF6::WindowSystem KF6::GuiAddons - XCB::XCB Qt6::WaylandClient - Qt6::GuiPrivate Wayland::Client ) target_link_libraries(KDEPlasmaPlatformTheme6 PRIVATE KF6::ColorScheme) -if(HAVE_X11) - target_link_libraries(KDEPlasmaPlatformTheme6 PRIVATE ${X11_Xcursor_LIB} ${XCB_XCB_LIBRARY}) +if(WITH_X11) + target_link_libraries(KDEPlasmaPlatformTheme6 PRIVATE X11::Xcursor XCB::XCB) endif() set_target_properties(KDEPlasmaPlatformTheme6 PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/platformthemes/") diff --git a/qt6/src/platformtheme/config-platformtheme.h.cmake b/qt6/src/platformtheme/config-platformtheme.h.cmake index 89858d17..03550c09 100644 --- a/qt6/src/platformtheme/config-platformtheme.h.cmake +++ b/qt6/src/platformtheme/config-platformtheme.h.cmake @@ -1 +1 @@ -#cmakedefine01 HAVE_X11 +#cmakedefine01 WITH_X11 diff --git a/qt6/src/platformtheme/kdeplatformtheme.cpp b/qt6/src/platformtheme/kdeplatformtheme.cpp index 3b7c6fae..04311105 100644 --- a/qt6/src/platformtheme/kdeplatformtheme.cpp +++ b/qt6/src/platformtheme/kdeplatformtheme.cpp @@ -57,7 +57,7 @@ KdePlatformTheme::KdePlatformTheme() m_kwaylandIntegration.reset(new KWaylandIntegration(this)); } -#if HAVE_X11 +#if WITH_X11 if (KWindowSystem::isPlatformX11()) { m_x11Integration.reset(new X11Integration(this)); m_x11Integration->init(); diff --git a/qt6/src/platformtheme/khintssettings.cpp b/qt6/src/platformtheme/khintssettings.cpp index c515a70d..988ebae3 100644 --- a/qt6/src/platformtheme/khintssettings.cpp +++ b/qt6/src/platformtheme/khintssettings.cpp @@ -37,11 +37,7 @@ #include <kiconloader.h> #include <config-platformtheme.h> -#ifdef UNIT_TEST -#undef HAVE_X11 -#define HAVE_X11 0 -#endif -#if HAVE_X11 +#if WITH_X11 #include <X11/Xcursor/Xcursor.h> #include <private/qtx11extras_p.h> #endif @@ -510,7 +506,7 @@ void KHintsSettings::updateCursorTheme() void KHintsSettings::updateX11CursorTheme() { -#if HAVE_X11 +#if WITH_X11 if (QX11Info::isPlatformX11()) { KConfig config(QStringLiteral("kcminputrc")); KConfigGroup g(&config, "Mouse");