Warning, /frameworks/extra-cmake-modules/find-modules/FindQtWaylandScanner.cmake is written in an unsupported language. File is not indexed.
0001 # SPDX-FileCopyrightText: 2012-2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> 0002 # 0003 # SPDX-License-Identifier: BSD-3-Clause 0004 0005 #[=======================================================================[.rst: 0006 FindQtWaylandScanner 0007 -------------------- 0008 0009 Try to find qtwaylandscanner. 0010 0011 If the qtwaylandscanner executable is not in your PATH, you can provide 0012 an alternative name or full path location with the ``QtWaylandScanner_EXECUTABLE`` 0013 variable. 0014 0015 This will define the following variables: 0016 0017 ``QtWaylandScanner_FOUND`` 0018 True if qtwaylandscanner is available 0019 0020 ``QtWaylandScanner_EXECUTABLE`` 0021 The qtwaylandscanner executable. 0022 0023 If ``QtWaylandScanner_FOUND`` is TRUE, it will also define the following imported 0024 target: 0025 0026 ``Wayland::QtScanner`` 0027 The qtwaylandscanner executable. 0028 0029 This module provides the following functions to generate C++ protocol 0030 implementations: 0031 0032 - ``ecm_add_qtwayland_client_protocol`` 0033 - ``ecm_add_qtwayland_server_protocol`` 0034 0035 :: 0036 0037 ecm_add_qtwayland_client_protocol(<target> 0038 PROTOCOL <xmlfile> 0039 BASENAME <basename> 0040 [PREFIX <prefix>]) 0041 0042 ecm_add_qtwayland_client_protocol(<source_files_var> 0043 PROTOCOL <xmlfile> 0044 BASENAME <basename> 0045 [PREFIX <prefix>]) 0046 0047 Generate C++ wrapper to Wayland client protocol files from ``<xmlfile>`` 0048 XML definition for the ``<basename>`` interface and append those files 0049 to ``<source_files_var>`` or ``<target>``. Pass the ``<prefix>`` argument if the interface 0050 names don't start with ``qt_`` or ``wl_``. 0051 0052 WaylandScanner is required and will be searched for. 0053 0054 :: 0055 0056 ecm_add_qtwayland_server_protocol(<target> 0057 PROTOCOL <xmlfile> 0058 BASENAME <basename> 0059 [PREFIX <prefix>]) 0060 0061 ecm_add_qtwayland_server_protocol(<source_files_var> 0062 PROTOCOL <xmlfile> 0063 BASENAME <basename> 0064 [PREFIX <prefix>]) 0065 0066 Generate C++ wrapper to Wayland server protocol files from ``<xmlfile>`` 0067 XML definition for the ``<basename>`` interface and append those files 0068 to ``<source_files_var>`` or ``<target>``. Pass the ``<prefix>`` argument if the interface 0069 names don't start with ``qt_`` or ``wl_``. 0070 0071 WaylandScanner is required and will be searched for. 0072 0073 Since 1.4.0. 0074 #]=======================================================================] 0075 0076 include(${CMAKE_CURRENT_LIST_DIR}/ECMFindModuleHelpersStub.cmake) 0077 include("${ECM_MODULE_DIR}/ECMQueryQt.cmake") 0078 0079 ecm_find_package_version_check(QtWaylandScanner) 0080 0081 ecm_query_qt(qt_binaries_dir QT_HOST_BINS) 0082 0083 # Find qtwaylandscanner 0084 find_program(QtWaylandScanner_EXECUTABLE NAMES qtwaylandscanner HINTS ${qt_binaries_dir}) 0085 0086 include(FindPackageHandleStandardArgs) 0087 find_package_handle_standard_args(QtWaylandScanner 0088 FOUND_VAR 0089 QtWaylandScanner_FOUND 0090 REQUIRED_VARS 0091 QtWaylandScanner_EXECUTABLE 0092 ) 0093 0094 mark_as_advanced(QtWaylandScanner_EXECUTABLE) 0095 0096 if(NOT TARGET Wayland::QtScanner AND QtWaylandScanner_FOUND) 0097 add_executable(Wayland::QtScanner IMPORTED) 0098 set_target_properties(Wayland::QtScanner PROPERTIES 0099 IMPORTED_LOCATION "${QtWaylandScanner_EXECUTABLE}" 0100 ) 0101 endif() 0102 0103 include(FeatureSummary) 0104 set_package_properties(QtWaylandScanner PROPERTIES 0105 URL "https://qt.io/" 0106 DESCRIPTION "Executable that converts XML protocol files to C++ code" 0107 ) 0108 0109 function(ecm_add_qtwayland_client_protocol target_or_sources_var) 0110 # Parse arguments 0111 set(oneValueArgs PROTOCOL BASENAME PREFIX) 0112 cmake_parse_arguments(ARGS "" "${oneValueArgs}" "" ${ARGN}) 0113 0114 if(ARGS_UNPARSED_ARGUMENTS) 0115 message(FATAL_ERROR "Unknown keywords given to ecm_add_qtwayland_client_protocol(): \"${ARGS_UNPARSED_ARGUMENTS}\"") 0116 endif() 0117 0118 set(_prefix "${ARGS_PREFIX}") 0119 0120 find_package(WaylandScanner REQUIRED QUIET) 0121 ecm_add_wayland_client_protocol(${target_or_sources_var} 0122 PROTOCOL ${ARGS_PROTOCOL} 0123 BASENAME ${ARGS_BASENAME}) 0124 0125 get_filename_component(_infile ${ARGS_PROTOCOL} ABSOLUTE) 0126 set(_header "${CMAKE_CURRENT_BINARY_DIR}/qwayland-${ARGS_BASENAME}.h") 0127 set(_code "${CMAKE_CURRENT_BINARY_DIR}/qwayland-${ARGS_BASENAME}.cpp") 0128 0129 set_source_files_properties(${_header} ${_code} GENERATED) 0130 0131 add_custom_command(OUTPUT "${_header}" 0132 COMMAND ${QtWaylandScanner_EXECUTABLE} client-header ${_infile} "" ${_prefix} > ${_header} 0133 DEPENDS ${_infile} ${_cheader} VERBATIM) 0134 0135 add_custom_command(OUTPUT "${_code}" 0136 COMMAND ${QtWaylandScanner_EXECUTABLE} client-code ${_infile} "" ${_prefix} > ${_code} 0137 DEPENDS ${_infile} ${_header} VERBATIM) 0138 0139 set_property(SOURCE ${_header} ${_code} PROPERTY SKIP_AUTOMOC ON) 0140 0141 if (TARGET ${target_or_sources_var}) 0142 target_sources(${target_or_sources_var} PRIVATE "${_code}") 0143 else() 0144 list(APPEND ${target_or_sources_var} "${_code}") 0145 set(${target_or_sources_var} ${${target_or_sources_var}} PARENT_SCOPE) 0146 endif() 0147 endfunction() 0148 0149 0150 function(ecm_add_qtwayland_server_protocol target_or_sources_var) 0151 # Parse arguments 0152 set(oneValueArgs PROTOCOL BASENAME PREFIX) 0153 cmake_parse_arguments(ARGS "" "${oneValueArgs}" "" ${ARGN}) 0154 0155 if(ARGS_UNPARSED_ARGUMENTS) 0156 message(FATAL_ERROR "Unknown keywords given to ecm_add_qtwayland_server_protocol(): \"${ARGS_UNPARSED_ARGUMENTS}\"") 0157 endif() 0158 0159 set(_prefix "${ARGS_PREFIX}") 0160 0161 find_package(WaylandScanner REQUIRED QUIET) 0162 ecm_add_wayland_server_protocol(${target_or_sources_var} 0163 PROTOCOL ${ARGS_PROTOCOL} 0164 BASENAME ${ARGS_BASENAME}) 0165 0166 get_filename_component(_infile ${ARGS_PROTOCOL} ABSOLUTE) 0167 set(_header "${CMAKE_CURRENT_BINARY_DIR}/qwayland-server-${ARGS_BASENAME}.h") 0168 set(_code "${CMAKE_CURRENT_BINARY_DIR}/qwayland-server-${ARGS_BASENAME}.cpp") 0169 0170 set_source_files_properties(${_header} ${_code} GENERATED) 0171 0172 add_custom_command(OUTPUT "${_header}" 0173 COMMAND ${QtWaylandScanner_EXECUTABLE} server-header ${_infile} "" ${_prefix} > ${_header} 0174 DEPENDS ${_infile} VERBATIM) 0175 0176 add_custom_command(OUTPUT "${_code}" 0177 COMMAND ${QtWaylandScanner_EXECUTABLE} server-code ${_infile} "" ${_prefix} > ${_code} 0178 DEPENDS ${_infile} ${_header} VERBATIM) 0179 0180 set_property(SOURCE ${_header} ${_code} PROPERTY SKIP_AUTOMOC ON) 0181 0182 if (TARGET ${target_or_sources_var}) 0183 target_sources(${target_or_sources_var} PRIVATE "${_code}") 0184 else() 0185 list(APPEND ${target_or_sources_var} "${_code}") 0186 set(${target_or_sources_var} ${${target_or_sources_var}} PARENT_SCOPE) 0187 endif() 0188 endfunction()