Warning: This CMake command is deprecated since 2.4, consider using ImageFiles.files instead.
Adds image resources to the target.
qul_add_resource(<target> FILES file1 [file2...] [PREFIX <path>] [BASE <path>] [OUTPUT_DIRECTORY <path>])
The listed files become resources that can be accessed from QML files via resource URIs. Currently only image resources are supported.
Resources can have CMake source file properties. These properties must be set before
qul_add_resource is called. For a list of properties, see the CMake Reference.
Internally, the resource descriptions are collected and passed to the qulrcc tool resource compiler as a JSON file.
qulrcc tool generates C++ files for them, as well as a JSON file that maps resource names to symbol names. The C++ files are compiled into the target and the output JSON file is used by qmltocpp to look up resource names and emit symbol references into generated code.
qul_add_resource must be used in the same directory scope as the qul_add_target.
FILES argument takes a list of space-separated file paths, relative to the current source directory.
You can set the
OUTPUT_DIRECTORY option to control where the generated files are placed. If the path is relative, it is relative to the current build directory.
PREFIX path adds a prefix to the resource URI that the files are placed in. For example, if
PREFIX is "images" and one of the
FILES is "map/small.png", then the path in the resource filesystem will be "qrc:/images/map/small.png". The default prefix is "/".
BASE path determines the anchor for the computed resource URIs. For example, if
BASE is "data" and one of the
FILES is "data/images/foo.png", then the path resource filesystem will be "qrc:/images/foo.png". The default base is the current source directory.
Byte alignment for texture data
Enable optimization for splitting the image into opaque segments
Note: These properties are set for individual resources using the
set_source_files_properties CMake function. To set a value that applies to all resources by default, use
PREFIX_DEFAULT_<property>, where PREFIX is:
QUL_PLATFORM. It's required to set source file properties before calling
# Store all images in compressed format by default, except for button.png set(QUL_DEFAULT_RESOURCE_COMPRESSION ON) set_source_files_properties(button.png PROPERTIES QUL_RESOURCE_COMPRESSION OFF) qul_add_resource(...)
# Used in QML as "qrc:/button.png" and "qrc:/nav/arrow.png", # or simply as "button.png" and "nav/arrow.png". qul_add_resource(example_app FILES button.png nav/arrow.png)
set_source_files_properties(big/button.png PROPERTIES QUL_RESOURCE_COMPRESSION ON QUL_RESOURCE_OPTIMIZE_FOR_SCALE ON) # The resource path becomes "qrc:/images/button.png" qul_add_resource(example_app FILES big/button.png BASE big PREFIX images)
# Setting an image to be cached on demand with a custom memory allocator set_source_files_properties( big/button.png PROPERTIES QUL_RESOURCE_CACHE_POLICY "OnDemand" QUL_RESOURCE_STORAGE_SECTION "CustomSegment" QUL_RESOURCE_RUNTIME_ALLOCATION_TYPE "128" )
Available under certain Qt licenses.
Find out more.