From 31c069ebf334501384c8fcc395b02f02ce5cd99b Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 22 Apr 2022 13:47:09 +0300 Subject: [PATCH] wayland: Let ecm_add_qtwayland_server_protocol_kde() work with targets Makes CMakeLists.txt code a bit safer. --- src/wayland/CMakeLists.txt | 95 ++++++++++++++++---------------- src/wayland/tools/CMakeLists.txt | 7 +-- 2 files changed, 50 insertions(+), 52 deletions(-) diff --git a/src/wayland/CMakeLists.txt b/src/wayland/CMakeLists.txt index 55358e2b8c..c15e8b434d 100644 --- a/src/wayland/CMakeLists.txt +++ b/src/wayland/CMakeLists.txt @@ -5,178 +5,177 @@ if (BUILD_TESTING) add_subdirectory(tests) endif() -set(WaylandProtocols_xml_SOURCES) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +# CMake has a known bug where target_source() doesn't work as expected with files generated +# in a directory other than the one where the target is defined. It should be fixed in 3.20. +add_library(WaylandProtocols_xml OBJECT) +target_link_libraries(WaylandProtocols_xml Qt::Core Wayland::Server) +target_link_libraries(kwin WaylandProtocols_xml) + +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${Wayland_DATADIR}/wayland.xml BASENAME wayland ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-output-device-v2.xml BASENAME kde-output-device-v2 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-primary-output-v1.xml BASENAME kde-primary-output-v1 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/kde-output-management-v2.xml BASENAME kde-output-management-v2 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/plasma-shell.xml BASENAME plasma-shell ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/plasma-virtual-desktop.xml BASENAME org-kde-plasma-virtual-desktop ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/plasma-window-management.xml BASENAME plasma-window-management ) -ecm_add_wayland_server_protocol(WaylandProtocols_xml_SOURCES +ecm_add_wayland_server_protocol(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/surface-extension.xml BASENAME qt-surface-extension ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/idle.xml BASENAME idle ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/fake-input.xml BASENAME fake-input ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/shadow.xml BASENAME shadow ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/dpms.xml BASENAME dpms ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/blur.xml BASENAME blur ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/contrast.xml BASENAME contrast ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${WaylandProtocols_DATADIR}/unstable/relative-pointer/relative-pointer-unstable-v1.xml BASENAME relative-pointer-unstable-v1 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/slide.xml BASENAME slide ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/server-decoration.xml BASENAME server-decoration ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${WaylandProtocols_DATADIR}/unstable/text-input/text-input-unstable-v1.xml BASENAME text-input-unstable-v1 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/text-input-unstable-v2.xml BASENAME text-input-unstable-v2 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${WaylandProtocols_DATADIR}/unstable/text-input/text-input-unstable-v3.xml BASENAME text-input-unstable-v3 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${WaylandProtocols_DATADIR}/unstable/pointer-gestures/pointer-gestures-unstable-v1.xml BASENAME pointer-gestures-unstable-v1 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${WaylandProtocols_DATADIR}/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml BASENAME pointer-constraints-unstable-v1 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${WaylandProtocols_DATADIR}/unstable/xdg-foreign/xdg-foreign-unstable-v2.xml BASENAME xdg-foreign-unstable-v2 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${WaylandProtocols_DATADIR}/unstable/idle-inhibit/idle-inhibit-unstable-v1.xml BASENAME idle-inhibit-unstable-v1 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/appmenu.xml BASENAME appmenu ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/server-decoration-palette.xml BASENAME server-decoration-palette ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${WaylandProtocols_DATADIR}/unstable/xdg-output/xdg-output-unstable-v1.xml BASENAME xdg-output-unstable-v1 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${WaylandProtocols_DATADIR}/stable/xdg-shell/xdg-shell.xml BASENAME xdg-shell ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${WaylandProtocols_DATADIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml BASENAME xdg-decoration-unstable-v1 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/keystate.xml BASENAME keystate ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${WaylandProtocols_DATADIR}/unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml BASENAME linux-dmabuf-unstable-v1 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${WaylandProtocols_DATADIR}/unstable/tablet/tablet-unstable-v2.xml BASENAME tablet-unstable-v2 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PROJECT_SOURCE_DIR}/src/wayland/protocols/wlr-data-control-unstable-v1.xml BASENAME wlr-data-control-unstable-v1 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PROJECT_SOURCE_DIR}/src/wayland/protocols/wlr-layer-shell-unstable-v1.xml BASENAME wlr-layer-shell-unstable-v1 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${WaylandProtocols_DATADIR}/unstable/keyboard-shortcuts-inhibit/keyboard-shortcuts-inhibit-unstable-v1.xml BASENAME keyboard-shortcuts-inhibit-unstable-v1 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${WaylandProtocols_DATADIR}/stable/viewporter/viewporter.xml BASENAME viewporter ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${WaylandProtocols_DATADIR}/unstable/primary-selection/primary-selection-unstable-v1.xml BASENAME wp-primary-selection-unstable-v1 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${PLASMA_WAYLAND_PROTOCOLS_DIR}/screencast.xml BASENAME zkde-screencast-unstable-v1 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${WaylandProtocols_DATADIR}/unstable/input-method/input-method-unstable-v1.xml BASENAME input-method-unstable-v1 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${WaylandProtocols_DATADIR}/staging/xdg-activation/xdg-activation-v1.xml BASENAME xdg-activation-v1 ) -ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml_SOURCES +ecm_add_qtwayland_server_protocol_kde(WaylandProtocols_xml PROTOCOL ${WaylandProtocols_DATADIR}/staging/drm-lease/drm-lease-v1.xml BASENAME drm-lease-v1 ) -# CMake has a known bug where target_source() doesn't work as expected with files generated -# in a directory other than the one where the target is defined. It should be fixed in 3.20. -add_library(WaylandProtocols_xml OBJECT ${WaylandProtocols_xml_SOURCES}) -target_link_libraries(WaylandProtocols_xml Qt::Core Wayland::Server) -target_link_libraries(kwin WaylandProtocols_xml) - target_sources(kwin PRIVATE abstract_data_source.cpp abstract_drop_handler.cpp diff --git a/src/wayland/tools/CMakeLists.txt b/src/wayland/tools/CMakeLists.txt index 5eea6e49b6..c7c6850a5d 100644 --- a/src/wayland/tools/CMakeLists.txt +++ b/src/wayland/tools/CMakeLists.txt @@ -2,7 +2,7 @@ remove_definitions(-DQT_NO_CAST_FROM_ASCII) add_executable(qtwaylandscanner_kde qtwaylandscanner.cpp) target_link_libraries(qtwaylandscanner_kde Qt::Core) -function(ecm_add_qtwayland_server_protocol_kde out_var) +function(ecm_add_qtwayland_server_protocol_kde target) # Parse arguments set(oneValueArgs PROTOCOL BASENAME PREFIX) cmake_parse_arguments(ARGS "" "${oneValueArgs}" "" ${ARGN}) @@ -15,7 +15,7 @@ function(ecm_add_qtwayland_server_protocol_kde out_var) find_package(WaylandScanner REQUIRED QUIET) - ecm_add_wayland_server_protocol(${out_var} + ecm_add_wayland_server_protocol(${target} PROTOCOL ${ARGS_PROTOCOL} BASENAME ${ARGS_BASENAME}) @@ -35,6 +35,5 @@ function(ecm_add_qtwayland_server_protocol_kde out_var) set_property(SOURCE ${_header} ${_code} PROPERTY SKIP_AUTOMOC ON) - list(APPEND ${out_var} "${_code}") - set(${out_var} ${${out_var}} PARENT_SCOPE) + target_sources(${target} PRIVATE "${_code}") endfunction()