CMake BinaryData regeneration

What is the most efficient way to force the regeneration of BinaryData in CMake builds? Specifically I have not been able to have the application icon update without deleting the entire build directory.

3 Likes

One way is to use a glob and CONFIGURE_DEPENDS to collect the files for the target, as described here: From Projucer to CMake - #3 by sudara

This is how I have it in my projects (could be seen as “dangerous” as every single file in the Assets/ folder will be bundled into the binary, so it requires some hygiene there).

file(GLOB_RECURSE AssetFiles CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/Assets/*")
juce_add_binary_data(Assets SOURCES ${AssetFiles})

# Make linux happy
set_target_properties(Assets PROPERTIES POSITION_INDEPENDENT_CODE TRUE)

Did you find a solution to this?

My use case is an SVG that I embed. The build system does not refresh the binary data when I edit the file and trigger a build. Even a rebuild does not work. I’m using Clion on macOS for development.

juce_add_binary_data(BinaryData SOURCES
        ./background.svg)

Any help is welcome.

In XCode I change the target to the "AppName"Data target and rebuild it. That seems to work.

Only solution I found to this is removing the juce_binarydata_BinaryData folder that I get in my CMake build folder, then get CMake to rebuild and the binary data gets updated. Seems like it’s likely not the best way to do it though.

1 Like

Thanks. Not perfect, but a better option than deleting the build folder and waiting for a full rebuild.

I have noticed that adding or removing a “dummy” binary resource in the CMake file also triggers a refresh of the binary data within the next build.