CMake macOS CommandlineTools support

Here is a little patch to make CMake build on macOS with just the CommandlineTools installed but no Xcode.

diff --git a/extras/Build/CMake/JUCEUtils.cmake b/extras/Build/CMake/JUCEUtils.cmake
index 4bf7206e5..0002899e4 100644
--- a/extras/Build/CMake/JUCEUtils.cmake
+++ b/extras/Build/CMake/JUCEUtils.cmake
@@ -413,8 +413,8 @@ function(_juce_add_au_resource_fork shared_code_target au_target)
             -I "${secret_au_resource_dir}"
             -I "/System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Versions/A/Headers"
             -I "/Applications/"
-            -I "/Applications/"
-            -isysroot "/Applications/"
+            -I "${CMAKE_OSX_SYSROOT}/System/Library/Frameworks/AudioUnit.framework/Headers    "
+            -isysroot "${CMAKE_OSX_SYSROOT}"
             -o "${au_rez_output}"


I made a similar change the other day which calls xcode-select -p to find the active developer directory. I think this may be a better solution than using the CMAKE_OSX_SYSROOT as we can locate the AUBase folder relative to the developer directory too (it looks like in your patch, the AUBase path still goes through

Could you try checking out the current develop branch and see whether it works for you?

Sure, i will have a look

Your change does only work with Xcode installed still, unfortunately.

${CMAKE_OSX_SYSROOT} resolves to “/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk” when setting the dev path (via xcode-select) to /Library/Developer/CommandLineTools

and to

“/Applications/” when setting it to “/Applications/”.

So the actual SDK sub path (after xcode-select -p) is different, and CMake does the logic.

Thanks for raising this. I’ve taken another look, and I think we can probably just remove the AUBase include path. I don’t think it’s doing anything at the moment (find /Applications/ -name AUBase returns no results). Then, we can just use CMAKE_OSX_SYSROOT for the other two paths, which works properly for both commandline-only installs and full Xcode installs.

1 Like