Trouble Building Slicer on macOS

I hear your frustration, and honestly i dont really have a solution. Since every computer and configuration feels different. I read alot of post here and it seems alot of people having build trouble with arm.

First try to get the QT path ahead of your slicer build path in your .bash or .zsh file first

-update xcode

my qt version is this
Qt 5.15.16 from Homebrew so install this

which qt: to get bath and add it to your path variable,
export Qt5_DIR=/opt/homebrew/opt/qt@5/lib/cmake/Qt5

and then make sure you clean up your slicer and build from source:

my configuration:

based on my cache and path cmake used it looks like this (dont copy this but it can maybe help u diagnose)

cmake \
  -DADDITIONAL_CXX_FLAGS:STRING="" \
  -DADDITIONAL_C_FLAGS:STRING="" \
  -DBUILD_TESTING:BOOL=ON \
  -DCMAKE_BUILD_TYPE:STRING=Debug \
  -DCMAKE_OSX_SYSROOT:PATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk \
  -DQt5_DIR:PATH=/opt/homebrew/opt/qt@5/lib/cmake/Qt5 \
  -DSlicer_BUILD_APPLICATIONUPDATE_SUPPORT:BOOL=ON \
  -DSlicer_BUILD_BRAINSTOOLS:BOOL=ON \
  -DSlicer_BUILD_CLI:BOOL=ON \
  -DSlicer_BUILD_DICOM_SUPPORT:BOOL=ON \
  -DSlicer_BUILD_DIFFUSION_SUPPORT:BOOL=ON \
  -DSlicer_BUILD_EXTENSIONMANAGER_SUPPORT:BOOL=ON \
  -DSlicer_BUILD_MULTIMEDIA_SUPPORT:BOOL=ON \
  -DSlicer_BUILD_MULTIVOLUME_SUPPORT:BOOL=ON \
  -DSlicer_BUILD_PYTHONQT:BOOL=ON \
  -DSlicer_BUILD_QTLOADABLEMODULES:BOOL=ON \
  -DSlicer_BUILD_QTSCRIPTEDMODULES:BOOL=ON \
  -DSlicer_BUILD_WEBENGINE_SUPPORT:BOOL=ON \
  -DSlicer_DEFAULT_FAVORITE_MODULES:STRING="Data,Volumes,Models,Transforms,Markups,SegmentEditor" \
  -DSlicer_DEFAULT_HOME_MODULE:STRING="Welcome" \
  -DSlicer_ORGANIZATION_DOMAIN:STRING=slicer.org \
  -DSlicer_ORGANIZATION_NAME:STRING=slicer.org \
  -DSlicer_RELEASE_TYPE:STRING=Experimental \
  -DSlicer_REQUIRED_QT_VERSION:STRING=5.15 \
  -DSlicer_SUPERBUILD:BOOL=ON \
  -DSlicer_USE_CTKAPPLAUNCHER:BOOL=ON \
  -DSlicer_USE_NUMPY:BOOL=ON \
  -DSlicer_USE_PYTHONQT:BOOL=ON \
  -DSlicer_USE_PYTHONQT_WITH_OPENSSL:BOOL=ON \
  -DSlicer_USE_QtTesting:BOOL=ON \
  -DSlicer_USE_SCIPY:BOOL=ON \
  -DSlicer_USE_SimpleITK:BOOL=ON \
  -DSlicer_USE_SimpleITK_SHARED:BOOL=ON \
  -DSlicer_VTK_SMP_IMPLEMENTATION_TYPE:STRING=STDThread \
  -DSlicer_VTK_VERSION_MAJOR:STRING=9 \
  -DSlicer_VTK_VERSION_MINOR:STRING=4 \
  ~/Slicer-source

Try to follow these links:

“I confirm that the last Slicer version successfully compiles on apple m1 only with OpenSSL built outside of Slicer (configured for darwin x86_64) and SimpleITK disabled.

These should be the relevant flags:

-DCMAKE_OSX_ARCHITECTURES:STRING=x86_64
-DSlicer_USE_SYSTEM_OpenSSL:BOOL=ON
-DSlicer_USE_SimpleITK:BOOL=OFF

I think the issue is the configuration step of the default slicer openssl build, which allows various dependencies of OpenSSL to be compiled in 32 bit mode, which I believe is not supported in M1 chips.

In fact, OpenSSL on its own (1.1.1g in this example) builds very nicely with a very simple ./Configure darwin64-x86_64-cc shared"

Another post:

“I haven’t tried building on mac arm in a long time, so more recent changes in the dependencies may have broken things.

One idea is to turn off this flag:”

I also just want to preface that although my build was successful, it didn’t pass all the tests, I also used a lot of ai to help me so I am not too savvy with cmake at all. I mainly build slicer so i could extract lsp and get a configuration.json file to get access to autocomplete.