From a8006e8b0b449e16fa627e8f795a20509bf5f5e8 Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Sun, 6 Mar 2022 20:22:07 +0100 Subject: [PATCH] Adapt build system to also support building against Qt6 --- CMakeLists.txt | 28 +++++++----- appmenu/CMakeLists.txt | 4 +- kcms/formats/CMakeLists.txt | 4 +- kcms/kfontinst/dbus/CMakeLists.txt | 3 ++ kcms/kfontinst/lib/CMakeLists.txt | 3 ++ kcms/lookandfeel/CMakeLists.txt | 2 +- libtaskmanager/declarative/CMakeLists.txt | 13 ++++-- phonon/platform_kde/CMakeLists.txt | 2 +- runners/bookmarks/CMakeLists.txt | 2 +- shell/CMakeLists.txt | 19 ++++++--- shell/autotests/mockserver/CMakeLists.txt | 52 ++++++++++++++--------- shell/tests/CMakeLists.txt | 10 ++++- 12 files changed, 93 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 68e4c64eb..a3ee7c7a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,6 @@ option(INSTALL_SDDM_WAYLAND_SESSION OFF) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Svg Widgets Quick QuickWidgets Concurrent Test Network) find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) @@ -36,6 +35,7 @@ include(ECMGenerateDBusServiceFile) include(ECMFindQmlModule) include(ECMGenerateExportHeader) +find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Svg Widgets Quick QuickWidgets Concurrent Test Network) find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Plasma Runner Notifications NotifyConfig NewStuff Wallet IdleTime Declarative I18n KCMUtils TextWidgets Crash GlobalAccel DBusAddons Wayland @@ -89,8 +89,8 @@ set_package_properties(KF5Holidays PROPERTIES DESCRIPTION "Holidays provider for PURPOSE "Needed to for holidays plugin for Plasma Calendar." ) -find_package(Phonon4Qt5 4.6.60 REQUIRED NO_MODULE) -set_package_properties(Phonon4Qt5 PROPERTIES +find_package(Phonon4Qt${QT_MAJOR_VERSION} 4.6.60 REQUIRED NO_MODULE) +set_package_properties(Phonon4Qt${QT_MAJOR_VERSION} PROPERTIES DESCRIPTION "Qt-based audio library" TYPE REQUIRED) @@ -127,15 +127,19 @@ if(PipeWire_FOUND) find_package(Libdrm REQUIRED) endif() -find_package(QtWaylandScanner REQUIRED) -find_package(Qt5WaylandClient) -find_package(Qt5XkbCommonSupport) +if(QT_MAJOR_VERSION EQUAL "5") + find_package(QtWaylandScanner REQUIRED) + find_package(Qt5XkbCommonSupport) +else() + find_package(Qt6 REQUIRED CONFIG COMPONENTS WaylandCompositor) +endif() +find_package(Qt${QT_MAJOR_VERSION}WaylandClient) find_package(PlasmaWaylandProtocols 1.6 REQUIRED) find_package(Wayland REQUIRED COMPONENTS Client Server) # Server is used in autotests if(FONTCONFIG_FOUND) # kfontinst - find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS PrintSupport) + find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS PrintSupport) endif() if(X11_FOUND) @@ -145,7 +149,9 @@ if(X11_FOUND) message(FATAL_ERROR "\nThe X11 Session Management (SM) development package could not be found.\nPlease install libSM.\n") endif(NOT X11_SM_FOUND) - find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS X11Extras) + if (QT_MAJOR_VERSION EQUAL "5") + find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS X11Extras) + endif() endif() if(X11_FOUND AND XCB_XCB_FOUND) @@ -161,13 +167,13 @@ if(${AppStreamQt_FOUND}) set(HAVE_APPSTREAMQT true) endif() -find_package(PackageKitQt5) -set_package_properties(PackageKitQt5 +find_package(PackageKitQt${QT_MAJOR_VERSION}) +set_package_properties(PackageKitQt${QT_MAJOR_VERSION} PROPERTIES DESCRIPTION "Software Manager integration" TYPE OPTIONAL PURPOSE "Used to install additional language packages on demand" ) -if(PackageKitQt5_FOUND) +if(PackageKitQt${QT_MAJOR_VERSION}_FOUND) set(HAVE_PACKAGEKIT TRUE) endif() diff --git a/appmenu/CMakeLists.txt b/appmenu/CMakeLists.txt index 738f6e6d9..d6a62e7be 100644 --- a/appmenu/CMakeLists.txt +++ b/appmenu/CMakeLists.txt @@ -20,7 +20,6 @@ pkg_check_modules(XKBCommon REQUIRED IMPORTED_TARGET xkbcommon) target_link_libraries(appmenu Qt::DBus Qt::WaylandClientPrivate - Qt::XkbCommonSupportPrivate KF5::DBusAddons KF5::KIOCore KF5::WaylandClient @@ -29,6 +28,9 @@ target_link_libraries(appmenu PkgConfig::XKBCommon dbusmenuqt ) +if (QT_MAJOR_VERSION EQUAL "5") + target_link_libraries(appmenu Qt::XkbCommonSupportPrivate) +endif() if (HAVE_X11) target_link_libraries(appmenu Qt::X11Extras XCB::XCB) diff --git a/kcms/formats/CMakeLists.txt b/kcms/formats/CMakeLists.txt index b7a9f13f4..ac6e7ec98 100644 --- a/kcms/formats/CMakeLists.txt +++ b/kcms/formats/CMakeLists.txt @@ -20,7 +20,9 @@ target_link_libraries(kcm_formats KF5::CoreAddons KF5::I18n KF5::QuickAddons) - +if (QT_MAJOR_VERSION EQUAL "6") + target_link_libraries(kcm_formats Qt::Core5Compat) # for QTextCodec +endif() ########### install files ############### install(TARGETS kcm_formats DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/kcms/systemsettings) diff --git a/kcms/kfontinst/dbus/CMakeLists.txt b/kcms/kfontinst/dbus/CMakeLists.txt index 1008f49c0..fb770d17f 100644 --- a/kcms/kfontinst/dbus/CMakeLists.txt +++ b/kcms/kfontinst/dbus/CMakeLists.txt @@ -15,6 +15,9 @@ target_link_libraries(fontinst_bin set_target_properties(fontinst_helper PROPERTIES OUTPUT_NAME fontinst_helper) target_link_libraries(fontinst_helper Qt::DBus Qt::Xml KF5::AuthCore KF5::KIOCore kfontinst) +if (QT_MAJOR_VERSION EQUAL "6") + target_link_libraries(fontinst_helper Qt::Core5Compat) # for QTextCodec +endif() ecm_qt_declare_logging_category(fontinst_bin HEADER kfontinst_debug.h diff --git a/kcms/kfontinst/lib/CMakeLists.txt b/kcms/kfontinst/lib/CMakeLists.txt index dfcb10c3e..2104846a7 100644 --- a/kcms/kfontinst/lib/CMakeLists.txt +++ b/kcms/kfontinst/lib/CMakeLists.txt @@ -14,6 +14,9 @@ target_link_libraries(kfontinst Qt::Gui XCB::IMAGE ) +if (QT_MAJOR_VERSION EQUAL "6") + target_link_libraries(kfontinst PRIVATE Qt::Core5Compat) # for QTextCodec +endif() set_target_properties(kfontinst PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} ) diff --git a/kcms/lookandfeel/CMakeLists.txt b/kcms/lookandfeel/CMakeLists.txt index 4d268ff10..bfeaa10f0 100644 --- a/kcms/lookandfeel/CMakeLists.txt +++ b/kcms/lookandfeel/CMakeLists.txt @@ -78,7 +78,7 @@ install(FILES kcm_lookandfeel.desktop DESTINATION ${KDE_INSTALL_APPDIR}) install(FILES lookandfeel.knsrc DESTINATION ${KDE_INSTALL_KNSRCDIR}) if(BUILD_TESTING) - find_package(Qt5Test ${QT_MIN_VERSION} CONFIG REQUIRED) + find_package(Qt${QT_MAJOR_VERSION}Test ${QT_MIN_VERSION} CONFIG REQUIRED) add_subdirectory(autotests) endif() diff --git a/libtaskmanager/declarative/CMakeLists.txt b/libtaskmanager/declarative/CMakeLists.txt index a04a71096..433237b06 100644 --- a/libtaskmanager/declarative/CMakeLists.txt +++ b/libtaskmanager/declarative/CMakeLists.txt @@ -20,10 +20,15 @@ if(TARGET PkgConfig::PipeWire) DESTINATION "${KDE_INSTALL_LOGGINGCATEGORIESDIR}" ) - ecm_add_qtwayland_client_protocol(SRCS - PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/screencast.xml - BASENAME zkde-screencast-unstable-v1 - ) + if (QT_MAJOR_VERSION EQUAL "5") + ecm_add_qtwayland_client_protocol(SRCS + PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/screencast.xml + BASENAME zkde-screencast-unstable-v1 + ) + else() + qt6_generate_wayland_protocol_client_sources(taskmanagerplugin FILES + ${PLASMA_WAYLAND_PROTOCOLS_DIR}/screencast.xml) + endif() target_include_directories(taskmanagerplugin PRIVATE ${Libdrm_INCLUDE_DIR}) target_compile_definitions(taskmanagerplugin PRIVATE -DWITH_PIPEWIRE) diff --git a/phonon/platform_kde/CMakeLists.txt b/phonon/platform_kde/CMakeLists.txt index c71014b63..841c60734 100644 --- a/phonon/platform_kde/CMakeLists.txt +++ b/phonon/platform_kde/CMakeLists.txt @@ -5,7 +5,7 @@ set(kde_PART_SRCS ) kcoreaddons_add_plugin(kde SOURCES ${kde_PART_SRCS} INSTALL_NAMESPACE "phonon_platform") -target_link_libraries(kde ${PHONON_LIBRARY} KF5::CoreAddons KF5::ConfigCore KF5::WidgetsAddons KF5::I18n KF5::KIOCore KF5::Notifications) +target_link_libraries(kde Phonon::phonon4qt${QT_MAJOR_VERSION} KF5::CoreAddons KF5::ConfigCore KF5::WidgetsAddons KF5::I18n KF5::KIOCore KF5::Notifications) install(FILES phonon.notifyrc DESTINATION ${KDE_INSTALL_KNOTIFYRCDIR}) install(FILES phononbackend.desktop DESTINATION ${KDE_INSTALL_KSERVICETYPESDIR}) diff --git a/runners/bookmarks/CMakeLists.txt b/runners/bookmarks/CMakeLists.txt index 4ec99c736..7f0774bdd 100644 --- a/runners/bookmarks/CMakeLists.txt +++ b/runners/bookmarks/CMakeLists.txt @@ -3,7 +3,7 @@ add_definitions(-DTRANSLATION_DOMAIN=\"plasma_runner_bookmarksrunner\") -find_package(Qt5 CONFIG REQUIRED COMPONENTS Sql) +find_package(Qt${QT_MAJOR_VERSION} CONFIG REQUIRED COMPONENTS Sql) set(krunner_bookmarks_common_SRCS bookmarkmatch.cpp diff --git a/shell/CMakeLists.txt b/shell/CMakeLists.txt index d91818e46..d6e76bac0 100644 --- a/shell/CMakeLists.txt +++ b/shell/CMakeLists.txt @@ -57,18 +57,23 @@ if (TARGET KUserFeedbackCore) ) endif() -ecm_add_qtwayland_client_protocol(plasma_shell_SRCS - PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-primary-output-v1.xml - BASENAME kde-primary-output-v1 -) +add_executable(plasmashell) +if (QT_MAJOR_VERSION EQUAL "5") + ecm_add_qtwayland_client_protocol(plasma_shell_SRCS + PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-primary-output-v1.xml + BASENAME kde-primary-output-v1 + ) +else() + qt6_generate_wayland_protocol_client_sources(plasmashell FILES + ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-primary-output-v1.xml + ) +endif() set(krunner_xml ${plasma-workspace_SOURCE_DIR}/krunner/dbus/org.kde.krunner.App.xml) qt_add_dbus_interface(plasma_shell_SRCS ${krunner_xml} krunner_interface) -add_executable(plasmashell - ${plasma_shell_SRCS} -) +target_sources(plasmashell PRIVATE ${plasma_shell_SRCS}) target_link_libraries(plasmashell Qt::Quick diff --git a/shell/autotests/mockserver/CMakeLists.txt b/shell/autotests/mockserver/CMakeLists.txt index b01661b6a..9cedd8dd9 100644 --- a/shell/autotests/mockserver/CMakeLists.txt +++ b/shell/autotests/mockserver/CMakeLists.txt @@ -14,26 +14,38 @@ set(SharedClientTest_LIB_SRCS primaryoutput.cpp primaryoutput.h ) -ecm_add_qtwayland_server_protocol(SharedClientTest_LIB_SRCS - PROTOCOL ${Wayland_DATADIR}/wayland.xml - BASENAME wayland -) - -ecm_add_qtwayland_server_protocol(SharedClientTest_LIB_SRCS - PROTOCOL ${WaylandProtocols_DATADIR}/unstable/xdg-output/xdg-output-unstable-v1.xml - BASENAME xdg-output-unstable-v1 -) - -ecm_add_qtwayland_client_protocol(SharedClientTest_LIB_SRCS - PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-primary-output-v1.xml - BASENAME kde-primary-output-v1 -) -ecm_add_qtwayland_server_protocol(SharedClientTest_LIB_SRCS - PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-primary-output-v1.xml - BASENAME kde-primary-output-v1 -) - -add_library(SharedClientTest OBJECT ${SharedClientTest_LIB_SRCS}) +add_library(SharedClientTest OBJECT) +if (QT_MAJOR_VERSION EQUAL "5") + ecm_add_qtwayland_server_protocol(SharedClientTest_LIB_SRCS + PROTOCOL ${Wayland_DATADIR}/wayland.xml + BASENAME wayland + ) + + ecm_add_qtwayland_server_protocol(SharedClientTest_LIB_SRCS + PROTOCOL ${WaylandProtocols_DATADIR}/unstable/xdg-output/xdg-output-unstable-v1.xml + BASENAME xdg-output-unstable-v1 + ) + + ecm_add_qtwayland_client_protocol(SharedClientTest_LIB_SRCS + PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-primary-output-v1.xml + BASENAME kde-primary-output-v1 + ) + ecm_add_qtwayland_server_protocol(SharedClientTest_LIB_SRCS + PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-primary-output-v1.xml + BASENAME kde-primary-output-v1 + ) +else() + qt6_generate_wayland_protocol_client_sources(SharedClientTest FILES + ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-primary-output-v1.xml + ) + qt6_generate_wayland_protocol_server_sources(SharedClientTest FILES + ${Wayland_DATADIR}/wayland.xml + ${WaylandProtocols_DATADIR}/unstable/xdg-output/xdg-output-unstable-v1.xml + ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-primary-output-v1.xml + ) +endif() + +target_sources(SharedClientTest PRIVATE ${SharedClientTest_LIB_SRCS}) target_link_libraries(SharedClientTest PUBLIC diff --git a/shell/tests/CMakeLists.txt b/shell/tests/CMakeLists.txt index 1d6940fb4..71b58dcc8 100644 --- a/shell/tests/CMakeLists.txt +++ b/shell/tests/CMakeLists.txt @@ -7,11 +7,17 @@ set(screenpoolmanualtest_SRCS ${CMAKE_CURRENT_BINARY_DIR}/../screenpool-debug.cpp ../primaryoutputwatcher.cpp ) -ecm_add_qtwayland_client_protocol(screenpoolmanualtest_SRCS +add_executable(screenpoolmanualtest) +if (QT_MAJOR_VERSION EQUAL "5") + ecm_add_qtwayland_client_protocol(screenpoolmanualtest_SRCS PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-primary-output-v1.xml BASENAME kde-primary-output-v1 ) -add_executable(screenpoolmanualtest ${screenpoolmanualtest_SRCS}) +else() + qt6_generate_wayland_protocol_client_sources(screenpoolmanualtest FILES + ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-primary-output-v1.xml) +endif() +target_sources(screenpoolmanualtest PRIVATE ${screenpoolmanualtest_SRCS}) target_link_libraries(screenpoolmanualtest Qt::Test Qt::Gui