Doc: Extend qt_add_resource documentation
Change-Id: Ia76b1e681eb15cc8ad9de04bb80654e35442c82b Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 7bc91dbe9344b3537cbc786c2ce723b0ddc0885f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
9bed8335f7
commit
ae4dc69d6d
@ -22,6 +22,13 @@ qt_add_resources(SOURCES example.qrc)
|
|||||||
add_executable(myapp ${SOURCES})
|
add_executable(myapp ${SOURCES})
|
||||||
#! [qt_add_resources]
|
#! [qt_add_resources]
|
||||||
|
|
||||||
|
#! [qt_add_resources_target]
|
||||||
|
add_executable(myapp main.cpp)
|
||||||
|
qt_add_resources(myapp "images"
|
||||||
|
PREFIX "/images"
|
||||||
|
FILES image1.png image2.png)
|
||||||
|
#! [qt_add_resources_target]
|
||||||
|
|
||||||
#! [qt5_add_big_resources]
|
#! [qt5_add_big_resources]
|
||||||
set(SOURCES main.cpp)
|
set(SOURCES main.cpp)
|
||||||
qt5_add_big_resources(SOURCES big_resource.qrc)
|
qt5_add_big_resources(SOURCES big_resource.qrc)
|
||||||
|
@ -95,22 +95,77 @@ qt6_add_resources(<VAR> file1.qrc [file2.qrc ...]
|
|||||||
[OPTIONS ...])
|
[OPTIONS ...])
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
|
Since 6.0:
|
||||||
|
|
||||||
|
\badcode
|
||||||
|
qt_add_resources(<TARGET> <RESOURCE_NAME>
|
||||||
|
[PREFIX <PATH>]
|
||||||
|
[LANG <LANGUAGE>]
|
||||||
|
[BASE <PATH>]
|
||||||
|
[FILES ...] [OPTIONS ...])
|
||||||
|
|
||||||
|
qt6_add_resources(<TARGET> <RESOURCE_NAME>
|
||||||
|
[PREFIX <PATH>]
|
||||||
|
[LANG <LANGUAGE>]
|
||||||
|
[BASE <PATH>]
|
||||||
|
[FILES ...] [OPTIONS ...])
|
||||||
|
\endcode
|
||||||
|
|
||||||
\section1 Description
|
\section1 Description
|
||||||
|
|
||||||
Creates source code from Qt resource files using the
|
To add resources, you can pass either a variable name or a target as the first
|
||||||
\l{Resource Compiler (rcc)}. Paths to the generated source files are added to
|
argument of the command.
|
||||||
\c{<VAR>}.
|
|
||||||
|
When passing a variable name as first argument, \c qt_add_resources creates
|
||||||
|
source code from Qt resource files using the \l{Resource Compiler (rcc)}. Paths
|
||||||
|
to the generated source files are added to \c{<VAR>}.
|
||||||
|
|
||||||
|
When passing a target as first argument, the function creates a resource with
|
||||||
|
the name \c{RESOURCE_NAME}, containing the specified \c{FILES}. The resource is
|
||||||
|
automatically linked into \c{TARGET}.
|
||||||
|
|
||||||
For embedding bigger resources, see \l qt_add_big_resources.
|
For embedding bigger resources, see \l qt_add_big_resources.
|
||||||
|
|
||||||
\section1 Arguments
|
See \l{The Qt Resource System} for a general description of Qt resources.
|
||||||
|
|
||||||
|
\section1 Arguments of the target-based variant
|
||||||
|
|
||||||
|
\c PREFIX specifies a path prefix under which all files of this resource are
|
||||||
|
accessible from C++ code. This corresponds to the XML attribute \c prefix of the
|
||||||
|
\c .qrc file format. If \c PREFIX is not given, the target property
|
||||||
|
\l{cmake-target-property-QT_RESOURCE_PREFIX}{QT_RESOURCE_PREFIX} is used.
|
||||||
|
|
||||||
|
\c LANG specifies the locale of this resource. This corresponds to the XML
|
||||||
|
attribute \c lang of the \c .qrc file format.
|
||||||
|
|
||||||
|
\c BASE is a path prefix that denotes the root point of the file's alias. For
|
||||||
|
example, if \c BASE is \c{"assets"} and \c FILES is
|
||||||
|
\c{"assets/images/logo.png"}, then the alias of that file is
|
||||||
|
\c{"images/logo.png"}.
|
||||||
|
|
||||||
|
Alias settings for files need to be set via the \c QT_RESOURCE_ALIAS source file
|
||||||
|
property.
|
||||||
|
|
||||||
|
\section1 Arguments of both variants
|
||||||
|
|
||||||
You can set additional \c{OPTIONS} that should be added to the \c{rcc} calls.
|
You can set additional \c{OPTIONS} that should be added to the \c{rcc} calls.
|
||||||
You can find possible options in the \l{rcc}{rcc documentation}.
|
You can find possible options in the \l{rcc}{rcc documentation}.
|
||||||
|
|
||||||
\section1 Examples
|
\section1 Examples
|
||||||
|
|
||||||
|
Variable variant, using a .qrc file:
|
||||||
\snippet cmake-macros/examples.cmake qt_add_resources
|
\snippet cmake-macros/examples.cmake qt_add_resources
|
||||||
|
|
||||||
|
Target variant, using immediate resources:
|
||||||
|
\snippet cmake-macros/examples.cmake qt_add_resources_target
|
||||||
|
|
||||||
|
\section1 Caveats
|
||||||
|
|
||||||
|
When adding multiple resources, \c{RESOURCE_NAME} must be unique across all
|
||||||
|
resources linked into the final target.
|
||||||
|
|
||||||
|
This especially affects static builds. There, the same resource name in
|
||||||
|
different static libraries conflict in the consuming target.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -298,3 +298,20 @@ That library provides implementations of main (or WinMain).
|
|||||||
|
|
||||||
On targets that must provide their own entry point, set the property \c qt_no_entrypoint to inhibit linking against Qt's entrypoint library.
|
On targets that must provide their own entry point, set the property \c qt_no_entrypoint to inhibit linking against Qt's entrypoint library.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\page cmake-target-property-qt_resource_prefix.html
|
||||||
|
\ingroup cmake-properties-qtcore
|
||||||
|
\ingroup cmake-target-properties-qtcore
|
||||||
|
|
||||||
|
\title QT_RESOURCE_PREFIX
|
||||||
|
\target cmake-target-property-QT_RESOURCE_PREFIX
|
||||||
|
|
||||||
|
\brief Specifies the default Qt resource prefix.
|
||||||
|
|
||||||
|
\preliminarycmakeproperty
|
||||||
|
|
||||||
|
When using \l{qt6_add_resources}{qt_add_resources} without a \c PREFIX
|
||||||
|
argument, then the value of this target property will be used as
|
||||||
|
resource prefix.
|
||||||
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user