Adapt build system to also support Qt6

This commit is contained in:
Volker Krause 2022-03-05 13:01:13 +01:00
parent 09624c5a9b
commit 6cd0014364
4 changed files with 107 additions and 49 deletions

View file

@ -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)

View file

@ -23,14 +23,20 @@ ecm_mark_as_test(testWaylandSurface)
########################################################
# Test WaylandSeat
########################################################
add_executable(testWaylandSeat)
set( testWaylandSeat_SRCS
test_wayland_seat.cpp
)
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
)
add_executable(testWaylandSeat ${testWaylandSeat_SRCS})
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)

View file

@ -31,11 +31,17 @@ ecm_mark_as_test(testNoXdgRuntimeDir)
########################################################
# Test Tablet Interface
########################################################
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
)
add_executable(testTabletInterface test_tablet_interface.cpp ${TABLET_SRCS})
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
########################################################
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
########################################################
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
########################################################
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
)
add_executable(testScreencastV1Interface test_screencast.cpp ${SCREENCAST_SRCS})
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,6 +121,8 @@ ecm_mark_as_test(testScreencastV1Interface)
########################################################
# Test InputMethod Interface
########################################################
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
@ -99,7 +131,13 @@ 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,6 +145,8 @@ ecm_mark_as_test(testInputMethodInterface)
########################################################
# Test LayerShellV1 Interface
########################################################
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
@ -115,7 +155,13 @@ 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})
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
########################################################
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
)
add_executable(testTextInputV3Interface test_textinputv3_interface.cpp ${TEXTINPUTV3_SRCS})
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)

View file

@ -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)