From 6cd001436472af4371c73361f2831db8013446f4 Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Sat, 5 Mar 2022 13:01:13 +0100 Subject: [PATCH] Adapt build system to also support Qt6 --- src/wayland/autotests/CMakeLists.txt | 2 +- src/wayland/autotests/client/CMakeLists.txt | 16 ++- src/wayland/autotests/server/CMakeLists.txt | 132 ++++++++++++++------ src/wayland/tests/CMakeLists.txt | 6 +- 4 files changed, 107 insertions(+), 49 deletions(-) diff --git a/src/wayland/autotests/CMakeLists.txt b/src/wayland/autotests/CMakeLists.txt index 8d520ecfaa..842373f4ba 100644 --- a/src/wayland/autotests/CMakeLists.txt +++ b/src/wayland/autotests/CMakeLists.txt @@ -1,6 +1,6 @@ include(ECMMarkAsTest) -find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Test) +find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED Test) remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY) remove_definitions(-DQT_NO_CAST_FROM_ASCII) diff --git a/src/wayland/autotests/client/CMakeLists.txt b/src/wayland/autotests/client/CMakeLists.txt index 34df293ac2..64a52c2d99 100644 --- a/src/wayland/autotests/client/CMakeLists.txt +++ b/src/wayland/autotests/client/CMakeLists.txt @@ -23,14 +23,20 @@ ecm_mark_as_test(testWaylandSurface) ######################################################## # Test WaylandSeat ######################################################## +add_executable(testWaylandSeat) set( testWaylandSeat_SRCS test_wayland_seat.cpp ) -ecm_add_qtwayland_client_protocol(testWaylandSeat_SRCS - PROTOCOL ${WaylandProtocols_DATADIR}/unstable/pointer-gestures/pointer-gestures-unstable-v1.xml - BASENAME pointer-gestures-unstable-v1 -) -add_executable(testWaylandSeat ${testWaylandSeat_SRCS}) +if (QT_MAJOR_VERSION EQUAL "5") + ecm_add_qtwayland_client_protocol(testWaylandSeat_SRCS + PROTOCOL ${WaylandProtocols_DATADIR}/unstable/pointer-gestures/pointer-gestures-unstable-v1.xml + BASENAME pointer-gestures-unstable-v1 + ) +else() + qt6_generate_wayland_protocol_client_sources(testWaylandSeat FILES + ${WaylandProtocols_DATADIR}/unstable/pointer-gestures/pointer-gestures-unstable-v1.xml) +endif() +target_sources(testWaylandSeat PRIVATE ${testWaylandSeat_SRCS}) target_link_libraries( testWaylandSeat Qt::Test Qt::Gui KF5::WaylandClient Plasma::KWaylandServer Wayland::Client Wayland::Server) add_test(NAME kwayland-testWaylandSeat COMMAND testWaylandSeat) ecm_mark_as_test(testWaylandSeat) diff --git a/src/wayland/autotests/server/CMakeLists.txt b/src/wayland/autotests/server/CMakeLists.txt index bfb4ce14cc..95e05164f6 100644 --- a/src/wayland/autotests/server/CMakeLists.txt +++ b/src/wayland/autotests/server/CMakeLists.txt @@ -31,11 +31,17 @@ ecm_mark_as_test(testNoXdgRuntimeDir) ######################################################## # Test Tablet Interface ######################################################## -ecm_add_qtwayland_client_protocol(TABLET_SRCS - PROTOCOL ${WaylandProtocols_DATADIR}/unstable/tablet/tablet-unstable-v2.xml - BASENAME tablet-unstable-v2 -) -add_executable(testTabletInterface test_tablet_interface.cpp ${TABLET_SRCS}) +add_executable(testTabletInterface) +if (QT_MAJOR_VERSION EQUAL "5") + ecm_add_qtwayland_client_protocol(TABLET_SRCS + PROTOCOL ${WaylandProtocols_DATADIR}/unstable/tablet/tablet-unstable-v2.xml + BASENAME tablet-unstable-v2 + ) +else() + qt6_generate_wayland_protocol_client_sources(testTabletInterface FILES + ${WaylandProtocols_DATADIR}/unstable/tablet/tablet-unstable-v2.xml) +endif() +target_sources(testTabletInterface PRIVATE test_tablet_interface.cpp ${TABLET_SRCS}) target_link_libraries( testTabletInterface Qt::Test Plasma::KWaylandServer KF5::WaylandClient Wayland::Client) add_test(NAME kwayland-testTabletInterface COMMAND testTabletInterface) ecm_mark_as_test(testTabletInterface) @@ -43,11 +49,17 @@ ecm_mark_as_test(testTabletInterface) ######################################################## # Test DataControlInterface ######################################################## +add_executable(testDataControlInterface test_datacontrol_interface.cpp ${DATACONTROL_SRCS}) +if (QT_MAJOR_VERSION EQUAL "5") ecm_add_qtwayland_client_protocol(DATACONTROL_SRCS PROTOCOL ${PROJECT_SOURCE_DIR}/src/protocols/wlr-data-control-unstable-v1.xml BASENAME wlr-data-control-unstable-v1 ) -add_executable(testDataControlInterface test_datacontrol_interface.cpp ${DATACONTROL_SRCS}) +else() + qt6_generate_wayland_protocol_client_sources(testDataControlInterface FILES + ${PROJECT_SOURCE_DIR}/src/protocols/wlr-data-control-unstable-v1.xml) +endif() +target_sources(testDataControlInterface PRIVATE test_datacontrol_interface.cpp ${DATACONTROL_SRCS}) target_link_libraries( testDataControlInterface Qt::Test Plasma::KWaylandServer KF5::WaylandClient Wayland::Client) add_test(NAME kwayland-testDataControlInterface COMMAND testDataControlInterface) ecm_mark_as_test(testDataControlInterface) @@ -55,11 +67,17 @@ ecm_mark_as_test(testDataControlInterface) ######################################################## # Test Keyboard Shortcuts Inhibitor Interface ######################################################## -ecm_add_qtwayland_client_protocol(KEYBOARD_SHORTCUTS_INHIBITOR_SRCS - PROTOCOL ${WaylandProtocols_DATADIR}/unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml - BASENAME keyboard-shortcuts-inhibit-unstable-v1 +add_executable(testKeyboardShortcutsInhibitorInterface) +if (QT_MAJOR_VERSION EQUAL "5") + ecm_add_qtwayland_client_protocol(KEYBOARD_SHORTCUTS_INHIBITOR_SRCS + PROTOCOL ${WaylandProtocols_DATADIR}/unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml + BASENAME keyboard-shortcuts-inhibit-unstable-v1 ) -add_executable(testKeyboardShortcutsInhibitorInterface test_keyboard_shortcuts_inhibitor_interface.cpp ${KEYBOARD_SHORTCUTS_INHIBITOR_SRCS}) +else() + qt6_generate_wayland_protocol_client_sources(testKeyboardShortcutsInhibitorInterface FILES + ${WaylandProtocols_DATADIR}/unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml) +endif() +target_sources(testKeyboardShortcutsInhibitorInterface PRIVATE test_keyboard_shortcuts_inhibitor_interface.cpp ${KEYBOARD_SHORTCUTS_INHIBITOR_SRCS}) target_link_libraries(testKeyboardShortcutsInhibitorInterface Qt::Test Plasma::KWaylandServer KF5::WaylandClient Wayland::Client) add_test(NAME kwayland-testKeyboardShortcutsInhibitorInterface COMMAND testKeyboardShortcutsInhibitorInterface) ecm_mark_as_test(testKeyboardShortcutsInhibitorInterface) @@ -67,11 +85,17 @@ ecm_mark_as_test(testKeyboardShortcutsInhibitorInterface) ######################################################## # Test Viewporter Interface ######################################################## -ecm_add_qtwayland_client_protocol(VIEWPORTER_SRCS - PROTOCOL ${WaylandProtocols_DATADIR}/stable/viewporter/viewporter.xml - BASENAME viewporter +add_executable(testViewporterInterface) +if (QT_MAJOR_VERSION EQUAL "5") + ecm_add_qtwayland_client_protocol(VIEWPORTER_SRCS + PROTOCOL ${WaylandProtocols_DATADIR}/stable/viewporter/viewporter.xml + BASENAME viewporter ) -add_executable(testViewporterInterface test_viewporter_interface.cpp ${VIEWPORTER_SRCS}) +else() + qt6_generate_wayland_protocol_client_sources(testViewporterInterface FILES + ${WaylandProtocols_DATADIR}/stable/viewporter/viewporter.xml) +endif() +target_sources(testViewporterInterface PRIVATE test_viewporter_interface.cpp ${VIEWPORTER_SRCS}) target_link_libraries(testViewporterInterface Qt::Test Plasma::KWaylandServer KF5::WaylandClient Wayland::Client) add_test(NAME kwayland-testViewporterInterface COMMAND testViewporterInterface) ecm_mark_as_test(testViewporterInterface) @@ -79,11 +103,17 @@ ecm_mark_as_test(testViewporterInterface) ######################################################## # Test ScreencastV1Interface ######################################################## -ecm_add_qtwayland_client_protocol(SCREENCAST_SRCS - PROTOCOL PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/screencast.xml - BASENAME zkde-screencast-unstable-v1 -) -add_executable(testScreencastV1Interface test_screencast.cpp ${SCREENCAST_SRCS}) +add_executable(testScreencastV1Interface) +if (QT_MAJOR_VERSION EQUAL "5") + ecm_add_qtwayland_client_protocol(SCREENCAST_SRCS + PROTOCOL PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/screencast.xml + BASENAME zkde-screencast-unstable-v1 + ) +else() + qt6_generate_wayland_protocol_client_sources(testScreencastV1Interface FILES + ${PLASMA_WAYLAND_PROTOCOLS_DIR}/screencast.xml) +endif() +target_sources(testScreencastV1Interface PRIVATE test_screencast.cpp ${SCREENCAST_SRCS}) target_link_libraries(testScreencastV1Interface Qt::Test Plasma::KWaylandServer Wayland::Client KF5::WaylandClient) add_test(NAME kwayland-testScreencastV1Interface COMMAND testScreencastV1Interface) ecm_mark_as_test(testScreencastV1Interface) @@ -91,15 +121,23 @@ ecm_mark_as_test(testScreencastV1Interface) ######################################################## # Test InputMethod Interface ######################################################## -ecm_add_qtwayland_client_protocol(INPUTMETHOD_SRCS - PROTOCOL ${WaylandProtocols_DATADIR}/unstable/input-method/input-method-unstable-v1.xml - BASENAME input-method-unstable-v1 +add_executable(testInputMethodInterface) +if (QT_MAJOR_VERSION EQUAL "5") + ecm_add_qtwayland_client_protocol(INPUTMETHOD_SRCS + PROTOCOL ${WaylandProtocols_DATADIR}/unstable/input-method/input-method-unstable-v1.xml + BASENAME input-method-unstable-v1 ) -ecm_add_qtwayland_client_protocol(VIEWPORTER_SRCS - PROTOCOL ${WaylandProtocols_DATADIR}/unstable/text-input/text-input-unstable-v1.xml - BASENAME text-input-unstable-v1 + ecm_add_qtwayland_client_protocol(VIEWPORTER_SRCS + PROTOCOL ${WaylandProtocols_DATADIR}/unstable/text-input/text-input-unstable-v1.xml + BASENAME text-input-unstable-v1 ) -add_executable(testInputMethodInterface test_inputmethod_interface.cpp ${INPUTMETHOD_SRCS}) +else() + qt6_generate_wayland_protocol_client_sources(testInputMethodInterface FILES + ${WaylandProtocols_DATADIR}/unstable/input-method/input-method-unstable-v1.xml + ${WaylandProtocols_DATADIR}/unstable/text-input/text-input-unstable-v1.xml + ) +endif() +target_sources(testInputMethodInterface PRIVATE test_inputmethod_interface.cpp ${INPUTMETHOD_SRCS}) target_link_libraries(testInputMethodInterface Qt::Test Plasma::KWaylandServer KF5::WaylandClient Wayland::Client) add_test(NAME kwayland-testInputMethodInterface COMMAND testInputMethodInterface) ecm_mark_as_test(testInputMethodInterface) @@ -107,15 +145,23 @@ ecm_mark_as_test(testInputMethodInterface) ######################################################## # Test LayerShellV1 Interface ######################################################## -ecm_add_qtwayland_client_protocol(LAYERSHELLV1_SRCS - PROTOCOL ${PROJECT_SOURCE_DIR}/src/protocols/wlr-layer-shell-unstable-v1.xml - BASENAME wlr-layer-shell-unstable-v1 -) -ecm_add_qtwayland_client_protocol(LAYERSHELLV1_SRCS - PROTOCOL ${WaylandProtocols_DATADIR}/stable/xdg-shell/xdg-shell.xml - BASENAME xdg-shell -) -add_executable(testLayerShellV1Interface test_layershellv1_interface.cpp ${LAYERSHELLV1_SRCS}) +add_executable(testLayerShellV1Interface) +if (QT_MAJOR_VERSION EQUAL "5") + ecm_add_qtwayland_client_protocol(LAYERSHELLV1_SRCS + PROTOCOL ${PROJECT_SOURCE_DIR}/src/protocols/wlr-layer-shell-unstable-v1.xml + BASENAME wlr-layer-shell-unstable-v1 + ) + ecm_add_qtwayland_client_protocol(LAYERSHELLV1_SRCS + PROTOCOL ${WaylandProtocols_DATADIR}/stable/xdg-shell/xdg-shell.xml + BASENAME xdg-shell + ) +else() + qt6_generate_wayland_protocol_client_sources(testLayerShellV1Interface FILES + ${PROJECT_SOURCE_DIR}/src/protocols/wlr-layer-shell-unstable-v1.xml + ${WaylandProtocols_DATADIR}/stable/xdg-shell/xdg-shell.xml + ) +endif() +target_sources(testLayerShellV1Interface PRIVATE test_layershellv1_interface.cpp ${LAYERSHELLV1_SRCS}) target_link_libraries(testLayerShellV1Interface Qt::Test Plasma::KWaylandServer KF5::WaylandClient Wayland::Client) add_test(NAME kwayland-testLayerShellV1Interface COMMAND testLayerShellV1Interface) ecm_mark_as_test(testLayerShellV1Interface) @@ -124,11 +170,17 @@ ecm_mark_as_test(testLayerShellV1Interface) ######################################################## # Test TextInputV3 Interface ######################################################## -ecm_add_qtwayland_client_protocol(TEXTINPUTV3_SRCS - PROTOCOL ${WaylandProtocols_DATADIR}/unstable/text-input/text-input-unstable-v3.xml - BASENAME text-input-unstable-v3 -) -add_executable(testTextInputV3Interface test_textinputv3_interface.cpp ${TEXTINPUTV3_SRCS}) +add_executable(testTextInputV3Interface) +if (QT_MAJOR_VERSION EQUAL "5") + ecm_add_qtwayland_client_protocol(TEXTINPUTV3_SRCS + PROTOCOL ${WaylandProtocols_DATADIR}/unstable/text-input/text-input-unstable-v3.xml + BASENAME text-input-unstable-v3 + ) +else() + qt6_generate_wayland_protocol_client_sources(testTextInputV3Interface FILES + ${WaylandProtocols_DATADIR}/unstable/text-input/text-input-unstable-v3.xml) +endif() +target_sources(testTextInputV3Interface PRIVATE test_textinputv3_interface.cpp ${TEXTINPUTV3_SRCS}) target_link_libraries(testTextInputV3Interface Qt::Test Plasma::KWaylandServer KF5::WaylandClient Wayland::Client) add_test(NAME kwayland-testTextInputV3Interface COMMAND testTextInputV3Interface) ecm_mark_as_test(testTextInputV3Interface) diff --git a/src/wayland/tests/CMakeLists.txt b/src/wayland/tests/CMakeLists.txt index 638081d284..0d3f352bb8 100644 --- a/src/wayland/tests/CMakeLists.txt +++ b/src/wayland/tests/CMakeLists.txt @@ -9,8 +9,8 @@ add_executable(testServer ${testServer_SRCS}) target_link_libraries(testServer Plasma::KWaylandServer) ecm_mark_as_test(testServer) -find_package(Qt5Widgets ${QT_MIN_VERSION} CONFIG QUIET) -if (Qt5Widgets_FOUND) +find_package(Qt${QT_MAJOR_VERSION}Widgets ${QT_MIN_VERSION} CONFIG QUIET) +if (TARGET Qt::Widgets) set(testRenderingServer_SRCS renderingservertest.cpp ) @@ -43,7 +43,7 @@ target_link_libraries(shadowTest KF5::WaylandClient) ecm_mark_as_test(shadowTest) -if (Qt5Widgets_FOUND) +if (TARGET Qt::Widgets) add_executable(dpmsTest dpmstest.cpp) target_link_libraries(dpmsTest KF5::WaylandClient Qt::Widgets) ecm_mark_as_test(dpmsTest)