BinaryData and CMake help

Hi,
I’m trying to setup a big project (that already builds correctly using Projucer) to use CMake instead.

However, BinaryData doesn’t build with more than 345 files.

// Number of elements in the namedResourceList and originalFileNames arrays. const int namedResourceListSize = 345;

If I add 1 more file, 346 files, whatever that file is, it just doesn’t build anymore, it doesn’t even generate the BinaryData.h and cpp files, error:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(240,5): error MSB8066: Custom build for 'C:\GITHUB\Kettering\Builds\cmake\CMakeFiles\820cdafe2695f996d19b64a31cb24c87\BinaryData1.cpp.rule' exited with code 9020. [C:\GITHUB\Kettering\Builds\cmake\BinaryData.vcxproj]

Any ideas?
Thanks

I just tried to repro this issue. I wrote a folder with 400 files in it:

for i in range(400):
    with open("assets/testfile_{}.foo".format(i), "w") as f:
        f.write("this is file {}\n".format(i))

Then, I modified the GuiApp example project like so:

file(GLOB assets "${JUCE_SOURCE_DIR}/assets/*")
juce_add_binary_data(GuiAppData SOURCES ${assets})
...
target_link_libraries(GuiAppExample
    PRIVATE
        GuiAppData
        ...

The project generates successfully for VS2019, and I’m able to build with
cmake --build cmake-build-vs --target GuiAppExample.

Is there anything special about the files you’re using? Do they have non-ASCII names/paths? I fixed some bugs to do with non-ASCII path names a few months ago, but perhaps there are still some issues in that area.

I think juceaide will fail to write binary data if the destination is not writeable, or if the input file does not exist, so it’s worth checking for these cases too.

2 Likes

Hi,

Still not working here…
I think it’s failing to generate the .cpp and .h BinaryData files, as it fails to compile the first one (as it’s non existent).

Any idea what this “The system cannot execute the specified program” means?

$ cmake --build Builds/cmake --target Kettering
Microsoft (R) Build Engine version 16.9.0+57a23d249 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Checking File Globs
Checking Build System
The system cannot execute the specified program.
Generating juce_binarydata_BinaryData/JuceLibraryCode/BinaryData1.cpp, juce_binarydata_BinaryData/JuceLibraryCode/BinaryData2.cpp,

[…]

juce_binarydata_BinaryData/JuceLibraryCode/BinaryData133.cpp, juce_binarydata_BinaryData/JuceLibraryCode
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(240,5): error MSB8066: Custom build for ‘C:\GITHUB\Kettering\Builds\cmake\CMakeFiles\820cdafe2695f996d19b64a31cb24c87\BinaryData1.cpp.rule’ exited with code 9020. [C:\GITHUB\Kettering\Builds\cmake\BinaryData.vcxproj]

I just tried my test procedure above, but generated longer names for the files, and now I can produce similar behaviour to what you’re seeing. (No sign of ‘error 9020’, but the build process does fail when generating the binary data.)

I think there must be some platform-imposed limit on the length of the command when juceaide is run. I’ll take a look at updating the build scripts so that we don’t have to pass all the input files on the command line.

I’ve pushed a fix which should resolve the issue:

Please let us know if you run into further problems.

1 Like

Awesome! Sorry for the delay!
That fixed the issue!
Tested and working now! Thanks!