qt_add_big_resources

将大型二进制资源编译为目标代码。

该命令在Qt6 软件包的Core 组件中定义,可以像这样加载:

find_package(Qt6 REQUIRED COMPONENTS Core)

该命令在 Qt 5.12 中引入。

简介

qt_add_big_resources(<VAR> file1.qrc [file2.qrc ...]
                     [OPTIONS ...])

如果禁用了无版本命令,请使用qt6_add_big_resources() 代替。它支持与此命令相同的参数集。

说明

使用Resource Compiler (rcc) 从 Qt 资源文件创建编译对象文件。生成文件的路径会添加到<VAR> 中。

这与qt_add_resources 类似,但直接生成对象文件 (.o,.obj) 而非 C++ 源代码。这样就可以嵌入更大的资源,因为编译成 C++ 源代码再编译成二进制文件会耗费太多时间或内存。

注意: file1.qrc 不会被Qt Creator 视为源文件。它需要作为源文件添加到 CMake 目标中,并将属性SKIP_AUTORCC 设置为ON

警告: 为 iOS 构建时不支持此命令,请使用qt_add_resources。详见QTBUG-103497

参数

您可以设置应添加到rcc 调用的其他OPTIONS 。您可以在rcc 文档中找到可能的选项。

示例

set(SOURCES main.cpp)
qt_add_big_resources(SOURCES big_resource.qrc)

# Have big_resource.qrc treated as a source file by Qt Creator
list(APPEND SOURCES big_resource.qrc)
set_property(SOURCE big_resource.qrc PROPERTY SKIP_AUTORCC ON)

qt_add_executable(myapp ${SOURCES})

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