Adding external .rcc files into Android assets in CMake Qt6

32 Views Asked by At

I'm trying to put some image files in an external .rcc binary file, adding this resource file in the app using QResource::registerResource() to be able to access the images.

The .rcc file is correctly generated and it works great in desktop. But I don't know how to bundle the external .rcc files into the Android package built by QtCreator.

In my CMakeLists.txt I have that to create the .rcc file:

# creating the 'MyModule' qml module in my app
qt_add_qml_module(MyModule
    ...
    # I don't want to use RESOURCES here because I want them to be in a separate binary file
)

# creating the target 'images' which will compile the images.qrc into images.rcc
qt_add_binary_resources(images images.qrc)

# making the qrc file discoverable by QtCreator
target_sources(images PRIVATE images.qrc)

# adding the target images as a dependency to build it when the module is built
add_dependencies(MyModule images)

I know I could manually copy the .rcc file from the build directory into the ${ANDROID_PACKAGE_SOURCE_DIR}/assets folder and rerun the build from Qt Creator.
This is working fine, but it's not a viable solution.

Is there a way to automatically add the generated external .rcc files into the android package assets folder?

(I don't necessarily search for a cross-platform solution, but an android specific one)

0

There are 0 best solutions below