防止強製將源文件視為 UTF-8 for Windows。
命令的定義在
Core
組件對於
Qt6
包,可以像這樣加載:
find_package(Qt6 REQUIRED COMPONENTS Core)
該命令在 Qt 6.0 引入。
qt_allow_non_utf8_sources(target)
若
無版本命令
被禁用,使用
qt6_allow_non_utf8_sources()
代替。它支持如此命令的一組相同自變量。
When building with some compilers for Windows, targets that link to a Qt library will use flags that force the compiler to treat its source files as UTF-8. This is currently implemented for Visual Studio and Intel compilers. You can disable this behavior on a per-target basis by calling
qt_allow_non_utf8_sources()
and passing the target as the argument.
注意:
This does not change the runtime behavior of classes like
QString
(its constructor from
const char *
requires properly encoded UTF-8 input). Use the
QT_NO_CAST_FROM_ASCII
and
QT_RESTRICTED_CAST_FROM_ASCII
macros to help identify such code.
{cmake-target-property-QT_NO_UTF8_SOURCE}
另請參閱 qt_disable_unicode_defines() .