Issues Compiling a Geant4 Example on macOS: Incorrect Macro Invocation in Geant4PackageCache.cmake

I’ve been encountering a persistent issue when trying to compile a Geant4 example on my MacBook Retina 13-inch, early 2015, running macOS Monterey version 12.6.8. Despite trying multiple solutions, the problem persists, and I’m seeking guidance from the community.

System Information:

  • Device: MacBook Retina 13-inch, early 2015
  • Operating System: macOS Monterey version 12.6.8
  • C Compiler: AppleClang 14.0.0.14000029
  • C++ Compiler: AppleClang 14.0.0.14000029
  • CMake Version: 3.27.1

Geant4 Information:

  • Version: 11.1.2
  • Installation Path: /Users/serafeimzormpas/Software/geant4/geant4-v11.1.2-install

Problem Description: During the CMake configuration phase, I get the following error:

CMake Error at /Users/serafeimzormpas/Software/geant4/geant4-v11.1.2-install/lib/cmake/Geant4/Geant4PackageCache.cmake:19 (geant4_set_and_check_package_variable):
geant4_set_and_check_package_variable Macro invoked with incorrect
arguments for macro named: geant4_set_and_check_package_variable

Steps Taken:

  1. Ensured that Geant4 was correctly installed by using the echo $G4INSTALL command in the bash shell, which returned the expected installation path.
  2. Checked the Geant4PackageCache.cmake file to ensure the correct paths for dependencies, especially EXPAT.
  3. Updated the EXPAT_LIBRARY variable in Geant4PackageCache.cmake to point to the correct libexpat.dylib path: /usr/local/opt/expat/lib/libexpat.dylib .
  4. Set environment variables (LDFLAGS and CPPFLAGS ) as recommended by Homebrew for the keg-only installation of EXPAT: export LDFLAGS=“-L/usr/local/opt/expat/lib”
  5. export CPPFLAGS=“-I/usr/local/opt/expat/include”
  6. Cleared the CMake cache and attempted fresh configurations multiple times.

Despite these steps, the issue persists. I’ve verified that the paths exist and are correct, and all the necessary dependencies are installed.

I would greatly appreciate any insights or suggestions on how to resolve this issue. Perhaps someone has encountered a similar problem or can point to a specific combination of versions or configurations that might be causing the conflict.

Thank you in advance for your assistance.

This is a recent known issue with CMake 3.27 as reported here: 2556 – Changes to FindEXPAT in CMake 3.27 break Geant4PackageCache.cmake file.

The best solution for now is to install Geant4 with the option -DGEANT4_INSTALL_PACKAGE_CACHE=OFF to disable the install of that file (Or you can simply delete it from an existing install, which will not break anything).

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