From e4dbfb219c0dbb6d3d6b888a8a0d964da50595e8 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 20 Apr 2022 14:36:39 +0300 Subject: Allow ecm_add_wayland_{client,server}_protocol take targets Allows us to avoid using source variables. --- find-modules/FindWaylandScanner.cmake | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'find-modules/FindWaylandScanner.cmake') diff --git a/find-modules/FindWaylandScanner.cmake b/find-modules/FindWaylandScanner.cmake index 7b493d81..f8495800 100644 --- a/find-modules/FindWaylandScanner.cmake +++ b/find-modules/FindWaylandScanner.cmake @@ -34,23 +34,31 @@ implementations: :: + ecm_add_wayland_client_protocol( + PROTOCOL + BASENAME ) + ecm_add_wayland_client_protocol( PROTOCOL BASENAME ) Generate Wayland client protocol files from ```` XML definition for the ```` interface and append those files -to ````. +to ```` or ````. :: + ecm_add_wayland_server_protocol( + PROTOCOL + BASENAME ) + ecm_add_wayland_server_protocol( PROTOCOL BASENAME ) Generate Wayland server protocol files from ```` XML definition for the ```` interface and append those files -to ````. +to ```` or ````. Since 1.4.0. #]=======================================================================] @@ -88,7 +96,7 @@ set_package_properties(WaylandScanner PROPERTIES include(CMakeParseArguments) -function(ecm_add_wayland_client_protocol out_var) +function(ecm_add_wayland_client_protocol target_or_sources_var) # Parse arguments set(oneValueArgs PROTOCOL BASENAME) cmake_parse_arguments(ARGS "" "${oneValueArgs}" "" ${ARGN}) @@ -113,12 +121,16 @@ function(ecm_add_wayland_client_protocol out_var) COMMAND ${WaylandScanner_EXECUTABLE} public-code ${_infile} ${_code} DEPENDS ${_infile} ${_client_header} VERBATIM) - list(APPEND ${out_var} "${_client_header}" "${_code}") - set(${out_var} ${${out_var}} PARENT_SCOPE) + if (TARGET ${target_or_sources_var}) + target_sources(${target_or_sources_var} PRIVATE "${_client_header}" "${_code}") + else() + list(APPEND ${target_or_sources_var} "${_client_header}" "${_code}") + set(${target_or_sources_var} ${${target_or_sources_var}} PARENT_SCOPE) + endif() endfunction() -function(ecm_add_wayland_server_protocol out_var) +function(ecm_add_wayland_server_protocol target_or_sources_var) # Parse arguments set(oneValueArgs PROTOCOL BASENAME) cmake_parse_arguments(ARGS "" "${oneValueArgs}" "" ${ARGN}) @@ -127,7 +139,7 @@ function(ecm_add_wayland_server_protocol out_var) message(FATAL_ERROR "Unknown keywords given to ecm_add_wayland_server_protocol(): \"${ARGS_UNPARSED_ARGUMENTS}\"") endif() - ecm_add_wayland_client_protocol(${out_var} + ecm_add_wayland_client_protocol(${target_or_sources_var} PROTOCOL ${ARGS_PROTOCOL} BASENAME ${ARGS_BASENAME}) @@ -141,6 +153,10 @@ function(ecm_add_wayland_server_protocol out_var) COMMAND ${WaylandScanner_EXECUTABLE} server-header ${_infile} ${_server_header} DEPENDS ${_infile} VERBATIM) - list(APPEND ${out_var} "${_server_header}") - set(${out_var} ${${out_var}} PARENT_SCOPE) + if (TARGET ${target_or_sources_var}) + target_sources(${target_or_sources_var} PRIVATE "${_server_header}") + else() + list(APPEND ${target_or_sources_var} "${_server_header}") + set(${target_or_sources_var} ${${target_or_sources_var}} PARENT_SCOPE) + endif() endfunction() -- cgit v1.2.1