When using cmrc_add_resource_library or cmrc_add_resources, you can control how file paths are mapped inside the binary using two keyword parameters:
WHENCE <path>: Tells CMakeRC how to rewrite filepaths. It defines the root directory from which resource paths are calculated. This is required for files located outside the current source directory. The default is CMAKE_CURRENT_SOURCE_DIR.PREFIX <string>: Prepends a directory-style path to all resources in the library. This is useful for avoiding filename collisions between different libraries.
Example:
If you have a directory images/ containing rose.jpg and you use:
cmrc_add_resource_library(flower-images
NAMESPACE flower
WHENCE images
PREFIX flowers
images/rose.jpg
)
The file will be accessible in C++ via fs.open("flowers/rose.jpg").
Combined Usage Example:
cmrc_add_resource_library(
flower-images
NAMESPACE flower
WHENCE images
PREFIX flowers
images/rose.jpg
images/tulip.jpg
images/daisy.jpg
images/sunflower.jpg
)
cmrc_add_resource_library(
flower-images
NAMESPACE flower
WHENCE images
PREFIX flowers
images/rose.jpg
images/tulip.jpg
images/daisy.jpg
images/sunflower.jpg
)