From 997bd09f326e065cff6fa58c081f14c1d7aee6e5 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 20 Apr 2022 14:42:41 +0300 Subject: Allow ecm_add_qtwayland_{client,server}_protocol take targets Allows us to avoid using source variables. --- find-modules/FindQtWaylandScanner.cmake | 38 ++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-) (limited to 'find-modules/FindQtWaylandScanner.cmake') diff --git a/find-modules/FindQtWaylandScanner.cmake b/find-modules/FindQtWaylandScanner.cmake index ffe53b22..d80fd9ef 100644 --- a/find-modules/FindQtWaylandScanner.cmake +++ b/find-modules/FindQtWaylandScanner.cmake @@ -34,6 +34,11 @@ implementations: :: + ecm_add_qtwayland_client_protocol( + PROTOCOL + BASENAME + [PREFIX ]) + ecm_add_qtwayland_client_protocol( PROTOCOL BASENAME @@ -41,13 +46,18 @@ implementations: Generate C++ wrapper to Wayland client protocol files from ```` XML definition for the ```` interface and append those files -to ````. Pass the ```` argument if the interface +to ```` or ````. Pass the ```` argument if the interface names don't start with ``qt_`` or ``wl_``. WaylandScanner is required and will be searched for. :: + ecm_add_qtwayland_server_protocol( + PROTOCOL + BASENAME + [PREFIX ]) + ecm_add_qtwayland_server_protocol( PROTOCOL BASENAME @@ -55,7 +65,7 @@ WaylandScanner is required and will be searched for. Generate C++ wrapper to Wayland server protocol files from ```` XML definition for the ```` interface and append those files -to ````. Pass the ```` argument if the interface +to ```` or ````. Pass the ```` argument if the interface names don't start with ``qt_`` or ``wl_``. WaylandScanner is required and will be searched for. @@ -99,7 +109,7 @@ set_package_properties(QtWaylandScanner PROPERTIES include(CMakeParseArguments) -function(ecm_add_qtwayland_client_protocol out_var) +function(ecm_add_qtwayland_client_protocol target_or_sources_var) # Parse arguments set(oneValueArgs PROTOCOL BASENAME PREFIX) cmake_parse_arguments(ARGS "" "${oneValueArgs}" "" ${ARGN}) @@ -111,7 +121,7 @@ function(ecm_add_qtwayland_client_protocol out_var) set(_prefix "${ARGS_PREFIX}") find_package(WaylandScanner REQUIRED QUIET) - ecm_add_wayland_client_protocol(${out_var} + ecm_add_wayland_client_protocol(${target_or_sources_var} PROTOCOL ${ARGS_PROTOCOL} BASENAME ${ARGS_BASENAME}) @@ -131,12 +141,16 @@ function(ecm_add_qtwayland_client_protocol out_var) set_property(SOURCE ${_header} ${_code} PROPERTY SKIP_AUTOMOC ON) - list(APPEND ${out_var} "${_code}") - set(${out_var} ${${out_var}} PARENT_SCOPE) + if (TARGET ${target_or_sources_var}) + target_sources(${target_or_sources_var} PRIVATE "${_code}") + else() + list(APPEND ${target_or_sources_var} "${_code}") + set(${target_or_sources_var} ${${target_or_sources_var}} PARENT_SCOPE) + endif() endfunction() -function(ecm_add_qtwayland_server_protocol out_var) +function(ecm_add_qtwayland_server_protocol target_or_sources_var) # Parse arguments set(oneValueArgs PROTOCOL BASENAME PREFIX) cmake_parse_arguments(ARGS "" "${oneValueArgs}" "" ${ARGN}) @@ -148,7 +162,7 @@ function(ecm_add_qtwayland_server_protocol out_var) set(_prefix "${ARGS_PREFIX}") find_package(WaylandScanner REQUIRED QUIET) - ecm_add_wayland_server_protocol(${out_var} + ecm_add_wayland_server_protocol(${target_or_sources_var} PROTOCOL ${ARGS_PROTOCOL} BASENAME ${ARGS_BASENAME}) @@ -168,6 +182,10 @@ function(ecm_add_qtwayland_server_protocol out_var) set_property(SOURCE ${_header} ${_code} PROPERTY SKIP_AUTOMOC ON) - list(APPEND ${out_var} "${_code}") - set(${out_var} ${${out_var}} PARENT_SCOPE) + if (TARGET ${target_or_sources_var}) + target_sources(${target_or_sources_var} PRIVATE "${_code}") + else() + list(APPEND ${target_or_sources_var} "${_code}") + set(${target_or_sources_var} ${${target_or_sources_var}} PARENT_SCOPE) + endif() endfunction() -- cgit v1.2.1