qt_generate_wayland_protocol_server_sources
为 Wayland 协议 .XML 文件生成服务器端的 C++ 绑定
该命令定义在Qt6 包的WaylandCompositor 组件中,可按以下方式加载:
find_package(Qt6 REQUIRED COMPONENTS WaylandCompositor)该命令于 Qt 6.0 中引入。
语法
qt_generate_wayland_protocol_server_sources(target
[PUBLIC_CODE | PRIVATE_CODE]
FILES file1.xml [file2.xml ...])如果禁用了无版本命令,请改用qt6_generate_wayland_protocol_server_sources() 。它支持与本命令相同的参数集。
描述
qt_generate_wayland_protocol_server_sources() 会生成构建步骤,用于对一个或多个 Wayland 协议文件运行waylandscanner 和qtwaylandscanner 。这些工具将进而生成用于实现协议的 C 和 C++ 绑定代码,生成的文件将作为target 的一部分进行构建。
选项PUBLIC_CODE 和PRIVATE_CODE (在 Qt 6.8 中新增)分别对应于wayland-scanner 中的public-code 和private-code 选项。
在 Qt 6.12 之前,默认值为PUBLIC_CODE 。对于 Qt 6.12 及更高版本,如果 Qt 策略qt_cmake_policy_qtp0006设置为NEW ,则默认值为PRIVATE_CODE 。通常强烈建议使用PRIVATE_CODE 。
qt_generate_wayland_protocol_server_sources() 将触发生成实现该协议合成器端所需的文件。
qt_generate_wayland_protocol_client_sources()是客户端对应的等效函数。
有关如何使用这些函数的示例,请参阅“自定义 Shell”或“自定义扩展”示例。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.