Is there any way to use UNITY_BUILD with juce cmake products?

I tried it, and it adds all the juce module source to unity files, which is obviously not what I want, since they already use their own unity files. I want it to just apply to my own sources.

1 Like

You can use the property UNITY_BUILD to enable or disable unity builds on a per-target basis. You can also set the property SKIP_UNITY_BUILD_INCLUSION on individual source files to ensure that they are compiled individually.

One option might be to put all of the JUCE modules into a staticlib target with UNITY_BUILD explicitly disabled. Then, targets that depend on JUCE can just link that staticlib target. You can find out how (and also find out about the drawbacks of this approach) here:

1 Like


foreach (FILE IN LISTS module_files)

Thanks, setting SKIP_UNITY_BUILD_INCLUSION for everything in my modules folder is the easiest way to do it.

Interesting… I found this post right after reading this article on compilation times in blender, in particular the unity build section, first learning about SKIP_UNITY_BUILD_INCLUSION.

Is it only third-party modules in that folder, or is JUCE in there too? I’m assuming they aren’t their own cmake targets?

A few of my modules are their own CMake targets. Some don’t depend on juce modules like perfetto, so I’m assuming they might benefit from being excluded.

I’m less clear what’s happening in modules that rely on juce like the inspector — If SKIP_UNITY_BUILD_INCLUSION is true, is it going to add another copy of the juce module it relies on (like @reuk warns in his post)? Bit confused…