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

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