# BinaryData and CMake help

**URL:** <https://forum.juce.com/t/binarydata-and-cmake-help/45303>\
**Category:** General JUCE discussion\
**Created:** [March 31, 2021, 11:03am UTC](https://forum.juce.com/t/binarydata-and-cmake-help/45303 "2021-03-31T11:03:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![BS2007](https://avatars.discourse-cdn.com/v4/letter/b/94ad74/32.png) [@BS2007](https://forum.juce.com/u/BS2007)\
**Post date:** [March 31, 2021, 11:03am UTC](https://forum.juce.com/t/binarydata-and-cmake-help/45303/1 "2021-03-31T11:03:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [March 31, 2021, 5:09pm UTC](https://forum.juce.com/t/binarydata-and-cmake-help/45303/2 "2021-03-31T17:09:44Z")

</div>

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

```python
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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![BS2007](https://avatars.discourse-cdn.com/v4/letter/b/94ad74/32.png) [@BS2007](https://forum.juce.com/u/BS2007)\
**Post date:** [April 6, 2021, 7:37am UTC](https://forum.juce.com/t/binarydata-and-cmake-help/45303/3 "2021-04-06T07:37:18Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [April 6, 2021, 5:53pm UTC](https://forum.juce.com/t/binarydata-and-cmake-help/45303/4 "2021-04-06T17:53:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [April 7, 2021, 12:10pm UTC](https://forum.juce.com/t/binarydata-and-cmake-help/45303/5 "2021-04-07T12:10:43Z")

</div>

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

> <https://github.com/juce-framework/JUCE/commit/c7d082e770d9286210efd5104d414b6a5dd24b68>

Please let us know if you run into further problems.

---

<div class="post-metadata">

**Author:** ![BS2007](https://avatars.discourse-cdn.com/v4/letter/b/94ad74/32.png) [@BS2007](https://forum.juce.com/u/BS2007)\
**Post date:** [April 19, 2021, 7:39am UTC](https://forum.juce.com/t/binarydata-and-cmake-help/45303/6 "2021-04-19T07:39:04Z")

</div>

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