qt_allow_non_utf8_sources
防止在 Windows 下将源文件强制处理为 UTF-8。
该命令在Qt6
软件包的Core
组件中定义,可以像这样加载:
find_package(Qt6 REQUIRED COMPONENTS Core)
此命令在 Qt 6.0 中引入。
简介
qt_allow_non_utf8_sources(target)
如果禁用了无版本命令,请使用qt6_allow_non_utf8_sources()
代替。它支持与此命令相同的参数集。
说明
使用某些 Windows 编译器编译时,链接到 Qt 库的目标将使用强制编译器将其源文件视为 UTF-8 的标志。目前,Visual Studio 和英特尔编译器已实现了这一功能。您可以通过调用qt_allow_non_utf8_sources()
并将目标作为参数传递,在每个目标上禁用此行为。
注意: 这不会改变QString 等类的运行时行为(其来自const char *
的构造函数需要正确编码的 UTF-8 输入)。请使用QT_NO_CAST_FROM_ASCII 和QT_RESTRICTED_CAST_FROM_ASCII
宏帮助识别此类代码。
{cmake-target-property-QT_NO_UTF8_SOURCE}。
© 2025 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.