Local GEANT4 installation on MacOS (BigSur and higher) - nyuad-astroparticle/tes-geant GitHub Wiki

Installing Brew

Homebrew is required for this Installation. See their official webpage for instructions.

Installing prerequisites

xcode-select --install;
brew install wget;
brew install cmake --cask;
brew install qt@5;
brew install xerces-c;

Downloading GEANT4 from CERN

Preferably from your home directory run:

wget https://gitlab.cern.ch/geant4/geant4/-/archive/v11.1.2/geant4-v11.1.2.tar.gz;
tar -xzf geant4-v11.1.2.tar.gz;

Installing GEANT4

mkdir geant4;
cd geant4;
mkdir build;
mkdir geant4-install;
mv ../geant4-v11.1.2 ./geant4-v11.1.2;
cd build;
ccmake ../geant4-v11.1.2;

Press c to configure. Change install prefix to your_geant4_dir_path/install. Have options listed below enabled.

After you press c to configure it will prompt you to include Qt5 path. To find it open a new terminal window (Cmd + t) and run:

where brew

It will produce a path that looks like /usr/homebrew/bin/brew. Then your Qt5 directory could be found at /usr/homebrew/Cellar/qt@5/QT_VERSION_HERE/lib/cmake/Qt5. You can use tab autocomplete in your ccmake window to include your version and verify your path exists. Make sure you include the same path for both QT_DIR and Qt5_DIR. Then you need to configure c and generate g.

Then run:

make -j7;
make --install

This may take a while. To speed up the installation we use -j flag to specify the number of cores used in the process. We recommend to use n-1 cores available on your Mac.

Sourcing GEANT4

In your bashrc (or any other rc) set an alias for GEANT4 sourcing:

echo "alias geant4='source your_geant4_folder_path/install/bin/geant4.sh'" >> ~/.bashrc


In case your Xcode happens to be an Xcode app under /Applications/Xcode.app/ you might need to modify geant4-install/lib/cmake/Geant4/Geant4PackageCache.cmake to add EXPAT PATH on line 19. Make sure the path exists and check the MacOS sdk version.

geant4_set_and_check_package_variable(EXPAT_LIBRARY "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Develop    er/SDKs/MacOSX14.5.sdk/usr/lib/libexpat.tbd" PATH "path to expat lib")