QTP0006
将PRIVATE_CODE 设为Wayland协议源代码生成的默认选项。
该策略自 Qt 6.12 起引入。当调用qt_generate_wayland_protocol_client_sources()和qt_generate_wayland_protocol_server_sources()时,若未指定PRIVATE_CODE 或PUBLIC_CODE ,该策略将影响其行为。
如果该策略设置为OLD ,且既未传入PUBLIC_CODE 也未传入PRIVATE_CODE ,则该函数的行为将等同于传入了PUBLIC_CODE ,并会发出弃用警告。
如果策略设置为NEW ,且既未传入PUBLIC_CODE 也未传入PRIVATE_CODE ,则该函数的行为就如同传入了PRIVATE_CODE 一样,且不会发出弃用警告。
当未设置策略,且既未传入PUBLIC_CODE 也未传入PRIVATE_CODE 时,将发出AUTHOR_WARNING 警告,且该函数的行为将与传入了PUBLIC_CODE 时相同,以保持向后兼容性。
例如,以下代码未传递PUBLIC_CODE 或PRIVATE_CODE 。由于未设置 QTP0006,因此会抛出AUTHOR_WARNING :
# QTP0006 not set — AUTHOR_WARNING is emitted
qt_generate_wayland_protocol_client_sources(MyTarget
FILES myprotocol.xml
)如果在调用前将 QTP0006 设置为NEW ,则该函数的行为就如同传入了PRIVATE_CODE 一样,且不会发出任何警告:
qt_policy(SET QTP0006 NEW)
qt_generate_wayland_protocol_client_sources(MyTarget
FILES myprotocol.xml
)相同的策略行为也适用于qt_generate_wayland_protocol_server_sources()。
注意: 策略的“OLD ”行为 已弃用,未来可能会被移除。
另请参阅 qt_policy()、Qt CMake 策略、qt_generate_wayland_protocol_client_sources() 以及qt_generate_wayland_protocol_server_sources()。
© 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.