From ae883df5b119c99d672c380f9585710d339dd187 Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Sat, 5 Mar 2022 11:29:55 +0100 Subject: [PATCH] Build with Qt6 --- .gitlab-ci.yml | 1 + CMakeLists.txt | 10 ++++++---- LayerShellQtConfig.cmake.in | 2 +- src/CMakeLists.txt | 26 ++++++++++++++++++++------ src/qwaylandlayershellintegration.cpp | 2 ++ 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f9680a1..2fa3f3a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,3 +4,4 @@ include: - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/linux.yml - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/freebsd.yml + - https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/linux-qt6.yml diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bab586..90bce47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,14 +10,12 @@ set(PROJECT_VERSION_MAJOR 5) set(CMAKE_C_STANDARD 99) set(QT_MIN_VERSION "5.15.0") -set(KF5_MIN_VERSION "5.86") +set(KF5_MIN_VERSION "5.91") set(KDE_COMPILERSETTINGS_LEVEL "5.82") set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS WaylandClient Qml) -find_package(Qt5XkbCommonSupport REQUIRED PRIVATE) find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${ECM_MODULE_PATH}) @@ -32,8 +30,12 @@ include(GenerateExportHeader) include(KDEClangFormat) include(ECMQtDeclareLoggingCategory) +find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS WaylandClient Qml) +if (QT_MAJOR_VERSION EQUAL "5") + find_package(Qt5XkbCommonSupport REQUIRED PRIVATE) + find_package(QtWaylandScanner) +endif() find_package(WaylandScanner) -find_package(QtWaylandScanner) find_package(Wayland 1.3 COMPONENTS Client Server) find_package(WaylandProtocols) find_package(PkgConfig REQUIRED) diff --git a/LayerShellQtConfig.cmake.in b/LayerShellQtConfig.cmake.in index fdaa09c..01043f9 100644 --- a/LayerShellQtConfig.cmake.in +++ b/LayerShellQtConfig.cmake.in @@ -4,6 +4,6 @@ @PACKAGE_INIT@ include(CMakeFindDependencyMacro) -find_dependency(Qt5Gui "@QT_MIN_VERSION@") +find_dependency(Qt@QT_MAJOR_VERSION@Gui "@QT_MIN_VERSION@") include("${CMAKE_CURRENT_LIST_DIR}/LayerShellQtTargets.cmake") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d1a761d..176fa52 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,8 +3,16 @@ remove_definitions(-DQT_NO_SIGNALS_SLOTS_KEYWORDS) -ecm_add_qtwayland_client_protocol(LAYER_SHELL_SOURCES PROTOCOL ${WaylandProtocols_DATADIR}/stable/xdg-shell/xdg-shell.xml BASENAME xdg-shell) -ecm_add_qtwayland_client_protocol(LAYER_SHELL_SOURCES PROTOCOL wlr-layer-shell-unstable-v1.xml BASENAME wlr-layer-shell-unstable-v1) +add_library(LayerShellQtInterface) +if (QT_MAJOR_VERSION EQUAL "5") + ecm_add_qtwayland_client_protocol(LAYER_SHELL_SOURCES PROTOCOL ${WaylandProtocols_DATADIR}/stable/xdg-shell/xdg-shell.xml BASENAME xdg-shell) + ecm_add_qtwayland_client_protocol(LAYER_SHELL_SOURCES PROTOCOL wlr-layer-shell-unstable-v1.xml BASENAME wlr-layer-shell-unstable-v1) +else() + qt6_generate_wayland_protocol_client_sources(LayerShellQtInterface FILES + ${WaylandProtocols_DATADIR}/stable/xdg-shell/xdg-shell.xml + ${CMAKE_CURRENT_SOURCE_DIR}/wlr-layer-shell-unstable-v1.xml + ) +endif() ecm_qt_declare_logging_category(LAYER_SHELL_SOURCES HEADER @@ -15,8 +23,11 @@ ecm_qt_declare_logging_category(LAYER_SHELL_SOURCES layershellqt ) -add_library(LayerShellQtInterface SHARED qwaylandlayersurface.cpp interfaces/window.cpp interfaces/shell.cpp qwaylandlayershellintegration.cpp qwaylandlayershell.cpp ${LAYER_SHELL_SOURCES}) -target_link_libraries(LayerShellQtInterface PRIVATE Qt::Gui Qt::WaylandClientPrivate Qt::XkbCommonSupportPrivate Wayland::Client PkgConfig::XKBCOMMON) +target_sources(LayerShellQtInterface PRIVATE qwaylandlayersurface.cpp interfaces/window.cpp interfaces/shell.cpp qwaylandlayershellintegration.cpp qwaylandlayershell.cpp ${LAYER_SHELL_SOURCES}) +target_link_libraries(LayerShellQtInterface PRIVATE Qt::Gui Qt::WaylandClientPrivate Wayland::Client PkgConfig::XKBCOMMON) +if (TARGET Qt::XkbCommonSupportPrivate) + target_link_libraries(LayerShellQtInterface PRIVATE Qt::XkbCommonSupportPrivate) +endif() target_include_directories(LayerShellQtInterface PUBLIC "$" INTERFACE "$" ) @@ -27,7 +38,10 @@ set_target_properties(LayerShellQtInterface PROPERTIES VERSION ${LAYERSHELLQT_ ) add_library(layer-shell SHARED qwaylandlayershellintegrationplugin.cpp) -target_link_libraries(layer-shell LayerShellQtInterface Qt::WaylandClient Qt::WaylandClientPrivate Qt::XkbCommonSupportPrivate Wayland::Client PkgConfig::XKBCOMMON) +target_link_libraries(layer-shell LayerShellQtInterface Qt::WaylandClient Qt::WaylandClientPrivate Wayland::Client PkgConfig::XKBCOMMON) +if (TARGET Qt::XkbCommonSupportPrivate) + target_link_libraries(layer-shell Qt::XkbCommonSupportPrivate) +endif() ecm_generate_headers(LayerShellQt_HEADERS HEADER_NAMES @@ -45,7 +59,7 @@ generate_export_header(LayerShellQtInterface ) install(TARGETS layer-shell - LIBRARY DESTINATION ${QT_PLUGIN_INSTALL_DIR}/wayland-shell-integration) + LIBRARY DESTINATION ${KDE_INSTALL_QTPLUGINDIR}/wayland-shell-integration) install(TARGETS LayerShellQtInterface EXPORT LayerShellQtTargets ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/src/qwaylandlayershellintegration.cpp b/src/qwaylandlayershellintegration.cpp index 230f3be..ada426f 100644 --- a/src/qwaylandlayershellintegration.cpp +++ b/src/qwaylandlayershellintegration.cpp @@ -24,7 +24,9 @@ QWaylandLayerShellIntegration::~QWaylandLayerShellIntegration() bool QWaylandLayerShellIntegration::initialize(QtWaylandClient::QWaylandDisplay *display) { +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QWaylandShellIntegration::initialize(display); +#endif display->addRegistryListener(registryLayer, this); return m_layerShell != nullptr; }