On this page

qt_generate_wayland_protocol_client_sources

Generates client-side C++ bindings for a Wayland protocol .XML file

The command is defined in the WaylandClient component of the Qt6 package, which can be loaded like so:

find_package(Qt6 REQUIRED COMPONENTS WaylandClient)

This command was introduced in Qt 6.0.

Synopsis

qt_generate_wayland_protocol_client_sources(target
                                            [PUBLIC_CODE | PRIVATE_CODE]
                                            [NO_INCLUDE_CORE_ONLY]
                                            FILES file1.xml [file2.xml ...])

If versionless commands are disabled, use qt6_generate_wayland_protocol_client_sources() instead. It supports the same set of arguments as this command.

Description

qt_generate_wayland_protocol_client_sources() creates the build steps to run wayland-scanner and qtwaylandscanner on one or more Wayland protocol files. The tools will in turn generate binding code in C and C++ for implementing the protocols, and the resulting files will be built as part of the target.

The options PUBLIC_CODE and PRIVATE_CODE (added in Qt 6.8) correspond to the public-code and private-code options of wayland-scanner. PUBLIC_CODE will cause the symbols in the code that is generated by wayland-scanner to be exported. For backwards compatibility PUBLIC_CODE is the default but generally PRIVATE_CODE is strongly recommended.

By default, wayland-scanner is invoked with the --include-core-only argument, ensuring that generated code includes "wayland-client-core.h". This behavior can be disabled using the NO_INCLUDE_CORE_ONLY option, which switches the include to "wayland-client.h".

Note: Using NO_INCLUDE_CORE_ONLY is generally discouraged. "wayland-client.h" includes a pre-compiled version of the core Wayland protocol which may conflict with newer protocol versions or other headers (like older versions of Vulkan). Only use this option if you have a specific requirement for types not present in the core header and are aware of the potential build-time conflicts.

qt_generate_wayland_protocol_client_sources() will trigger generation of the files needed to implement the client side of the protocol. qt_generate_wayland_protocol_server_sources() is the equivalent function for the compositor.

See the Custom Shell or Custom Extension examples for a demonstration of how to use these functions.

© 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.