The developer docs may need a minor update addressing development on the newer Macs (M-series chips). Here is a sufficient-for-development build from source on arm64 MacOS without requiring niche workarounds for specific libraries. The following steps explain how to build Slicer from source on M-chip computers. Note that the Slicer build still targets x86_64 (i.e. run through Rosetta 2), but native arm64 builds may be rolled out at a future date. To summarize the steps:
- Install Qt5 with x86_64
brew
- Use x86_64
bash
to build Slicer - Turn off SimpleITK
- There were a few libraries which could not compile using later versions of clang. This discussion post is coupled with PR#8097, which cherry picks a few patches in files within libarchive.
This is an attempt to partially address #6811.
Step-by-step:
-
Install the latest Xcode SDKs:
xcode-select --install
-
Checkout Slicer source files
git clone https://github.com/Slicer/Slicer.git
-
Setup the development environment
cd Slicer ./Utilities/SetupForDevelopment.sh
-
Install x86_64 Homebrew. You can install “x86_64 Homebrew” if you run the shell with Rosetta 2:
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Launch
/bin/bash
with Rosetta 2. x86_64 Homebrew is in/usr/local/bin/brew
, and it installs binaries in/usr/local/bin
./usr/local/bin
is added toPATH
by default on MacOS, so all binaries are accessible without any custom profiles (e.g..bash_profile
,.bashrc
). You should remain in the x86_64/bin/bash
for the rest of the build.exec /usr/bin/arch -x86_64 /bin/bash --norc --noprofile
export PATH="/usr/local/bin:$PATH" brew install qt5
Be aware: On MacOS,
/etc/paths
configures yourPATH
such that binaries installed by Homebrew will be preferred over those in/bin
. For example, if you install an x86_64 bash with/usr/local/bin/brew install bash
, Homebrew-installed x86_64/usr/local/bin/bash
will be resolved when typingbash
, not/bin/bash
. For native arm64 Homebrew, be careful to setPATH=/opt/homebrew/bin:$PATH
in custom profiles, or x86_64 binaries will always be resolved first, includingbrew
. -
Configure and build Slicer (from x86_64
/bin/bash
). Note that arm64cmake
here is permissible:cd .. cmake_build_type=Debug cmake \ -DQt5_DIR:PATH=/usr/local/opt/qt@5/lib/cmake/Qt5 \ -DCMAKE_OSX_ARCHITECTURES:STRING=x86_64 \ -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=13.0 \ -DCMAKE_BUILD_TYPE:STRING=Debug \ -DSlicer_USE_SYSTEM_QT:BOOL=ON \ -DSlicer_USE_SimpleITK:BOOL=OFF \ -B ./Slicer-$cmake_build_type \ -S ./Slicer cmake --build ./Slicer-$cmake_build_type
Happy developing!
Not all the tests pass, but you should be able to launch Slicer with ./Slicer-Debug/Slicer-build/Slicer
. This should make it easier to develop and iterate over 3DSlicer on Apple Silicon devices. Thank you to @Jared_Vicory for helpful input and @jcfr for the invaluable support.