Skip to content

Instantly share code, notes, and snippets.

@mnvr
Created August 4, 2023 10:34
Show Gist options
  • Save mnvr/9490c82fb86e3b97c083319fbc46f3a0 to your computer and use it in GitHub Desktop.
Save mnvr/9490c82fb86e3b97c083319fbc46f3a0 to your computer and use it in GitHub Desktop.

Building SuperCollider from Source

macOS

SuperCollider's documentation for building on macOS is in the README_MACOS.md file in the SuperCollider. These are additional notes for the way I did it.

Install CMake. This will generate the Xcode project files for building SuperCollider.

brew install cmake

Install libsndfile library.

brew install libsndfile

Install QT5. This is keg-only, so we'll need to also provide its path to cmake as the CMAKE_PREFIX_PATH variable when we generate the build files.

brew install qt5

Fetch all the submodules in the SuperCollider source.

git submodule init && git submodule update --recursive

CMake allows creating multiple build trees that all build the same source tree. So we create a build directory, but then also create variants inside it.

mkdir build && cd build
mkdir default && cd default

We're now in build/default. We can now generate the build files.

  • We need to tell CMake the path to the source tree. That will be ../...

  • We want to generate Xcode project files, so we'll pass the -G Xcode to select the "Xcode" generator supported by CMake.

  • Qt5 was "Keg Only". This means it was kept only in the "Cellar". Once we go beyond the Homebrew puns, what this means is that Qt5 was downloaded into a directory of Cellars (/opt/homebrew/Cellar/qt@5 on my machine) where the Kegs are kept, but it was not linked to the rest of the system. Possibly because it might get in the way of something else.

    For us, this means that qt5 is there on our machine all right, but we'll need to give additional help to get CMake to find it. We can do this by setting the CMAKE_PREFIX_PATH variable that tells CMake which additional places to go search for stuff. We can define this variable with the -D <var>=<value> flag. And instead of putting in the actual value, we can ask Homebrew to fill that in for us by doing

    -D CMAKE_PREFIX_PATH=`brew --prefix qt5`
    
  • On my machine, the Abelton Link support was giving some errors, but I don't need that right now anyway. So we can disable it by setting another (SuperCollider specific) CMake variable, SC_ABLETON_LINK to OFF. How did I find this toggle? By looking at the output of cmake -L ../... The CMake variable listing has two extra options –– -LA will list everything, and -LH will also add comments, and -LAH will also do what we expect it to.

The money command:

cmake -G Xcode -D CMAKE_PREFIX_PATH=`brew --prefix qt5` -D SC_ABLETON_LINK=OFF ../..

Some maybe useful tips:

  • Another useful CMake flag is --fresh, which causes it to regenerate everything from scratch.

  • The CMake output is in CMakeFiles/CMakeConfigureLog.yaml, so you can more CMakeFiles/CMakeConfigureLog.yaml to view its contents when things go south.

Once the build files are generated, we'll see an SuperCollider.xcodeproj in the current directory.

We can now start the build itself by passing the --build flag to cmake, asking it to build the current directory. However, whilst that'll generate a SuperCollider.app, it'll be incomplete – macOS will not recognize it as an executable. To fix this, we need to build the "install" target instead of the default target.

cmake --build . --target install

This will create a SuperCollider.app in ./Install/SuperCollider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment