Install Geant4 from Source on a Mac

Please fill out the following information to help in answering your question, and also see tips for posting code snippets. If you don’t provide this information it will take more time to help with your problem!

Geant4 Version:
geant4/10.7.1
Operating System:
MAC OS Sonoma 14.4
Compiler/Version:
MacOSX14.4.sdk
CMake Version:
cmake version 3.21.4

When I try cd cd ./examples/extended/persistency/gdml/G01

and then cmake .

It is trying to pick a MacOSX11.1 version of the sdk.

I have tried deleting CMakeCache.txt but the cache still gets set 11.1
How do I get cmake to pick up the right version.

CMake Error in CMakeLists.txt:
Imported target “Geant4::G4OpenGL” includes non-existent path

"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/OpenGL.framework"

in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:

  • The path was deleted, renamed, or moved to another location.

  • An install or uninstall procedure did not complete successfully.

  • The installation package was faulty and references files it does not
    provide.


Could you check if the Geant4 install has a Geant4Package.cmake file next to its Geant4Config.cmake file? If it is present, is that path to OpenGL.framework there, or is it in the Geant4LibraryTargets(-mode).cmake file(s) in the same directory as Geant4Config.cmake?

If the Geant4PackageCache.cmake file is present and has that path, you can remove it and see if that fixes things. I’d guess that this is an old install of Geant4 done before a recent upgrade? If that’s the case, you might need to reinstall Geant4, but removing the hard-coded paths in that cache file might resolve things as a first step.

Not seeing much in install

cd /Users/keithsloan/geant4-v11.2.1-install

(g4) sh-3.2$ ls

bin include lib share

There is a Geant4Package.cmake & Geant4PackageCache.cmake
in /Users/keithsloan/geant4-v11.2.1-build:
(g4) sh-3.2$ ls
BuildProducts G4X11Shim.cmake cmake_install.cmake
CMakeCPackOptions.cmake Geant4Config.cmake cmake_uninstall.cmake
CMakeCache.txt Geant4ConfigVersion.cmake cmake_uninstall.cmake.in
CMakeFiles Geant4LibraryDepends.cmake cxx_filesystem
CPackConfig.cmake Geant4PackageCache.cmake data
CPackSourceConfig.cmake InstallTreeFiles geant4-config
Externals LICENSE.txt geant4_module_check.py
G4EXPATShim.cmake Makefile geant4_validate_sources.cmake
G4FreetypeShim.cmake Modules geant4make.csh
G4HDF5Shim.cmake README.txt geant4make.sh
G4ModuleAdjacencyList.txt UseGeant4.cmake install_manifest.txt
G4ModuleInterfaceMap.csv UseGeant4_internal.cmake source
G4MotifShim.cmake _source_extras source_package_extras.cmake

If the package cache file is there, it should be in

/Users/keithsloan/geant4-v11.2.1-install/lib/cmake/Geant4

alongside the Geant4LibraryDepends... files (sorry, I use the wrong name in my first post!).

To confirm though, is this a completely fresh install of Geant4, or was it built on the machine prior to any upgrade? If a fresh install, what CMake options did you use?

I probably should have explained as having failed to install with the prepackaged options on MacOS, it was suggested that I try from source using the Unix instructions as per geant4-v11.2.2-install.

I am changing /path/to to /Users/keithsloan.

Yes there is a previous install in a different directory, so as your question about clean install suggests, the options for “/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/OpenGL.framework”

Have probaby been set by the previous install.

O.k., then you’ll need to clean out that “bad” install before doing the new one, then repoint the build of the example to the fresh, correct one.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.