Cmake environment variables error

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-v11.3.0
_Operating System: MacOS Sequoia 15.1.1
_Compiler/Version:
admin@MacBook-Pro-de-Leonardo ~ % gcc --version
Apple clang version 16.0.0 (clang-1600.0.26.6)
Target: x86_64-apple-darwin24.1.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
_CMake Version: admin@MacBook-Pro-de-Leonardo ~ % cmake --version

cmake version 3.29.0

Hi everyone,
It’s my first time to making a geant4 project, I had a geant4 v11.2.o and did workes done, But the MacOS was updated to Sequoia and makes error on geant4. I updated the system and apparently works done, now Cmake calls a different sdk that I’ve installed. I think this may be a beginner’s mistake.

  • That’s the error:
    admin@MacBook-Pro-de-Leonardo build % cmake …
    CMake Warning at /Applications/CMake.app/Contents/share/cmake-3.29/Modules/Platform/Darwin-Initialize.cmake:308 (message):
    Ignoring CMAKE_OSX_SYSROOT value:

    /Library/Developer/CommandLineTools/SDKs/MacOSX15.1.sdk

    because the directory does not exist.
    Call Stack (most recent call first):
    /Applications/CMake.app/Contents/share/cmake-3.29/Modules/CMakeSystemSpecificInitialize.cmake:34 (include)
    CMakeLists.txt:3 (project)

CMake Error at /usr/local/opt/qt@5/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:9 (message):
Failed to find “gl.h” in
“/System/Library/Frameworks/OpenGL.framework/Headers;/System/Library/Frameworks/AGL.framework/Headers”.
Call Stack (most recent call first):
/usr/local/opt/qt@5/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake:227 (include)
/usr/local/opt/qt@5/lib/cmake/Qt5/Qt5Config.cmake:28 (find_package)
CMakeLists.txt:9 (find_package)

– Configuring incomplete, errors occurred!

Cmake configuration

  • System Root configured on cmake:
    CMAKE_OSX_SYSROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX15.2.sdk

admin@MacBook-Pro-de-Leonardo ~ % ls /Library/Developer/CommandLineTools/SDKs/

MacOSX.sdk
MacOSX14.5.sdk
MacOSX14.sdk
MacOSX15.2.sdk
MacOSX15.sdk

  • Geant4PackageChace.cmake:
    geant4_set_and_check_package_variable(EXPAT_INCLUDE_DIR “/Library/Developer/CommandLineTools/SDKs/MacOSX15.1.sdk/usr/include” PATH “Path to a file.”)

geant4_set_and_check_package_variable(EXPAT_LIBRARY “/Library/Developer/CommandLineTools/SDKs/MacOSX15.1.sdk/usr/lib/libexpat.tbd” PATH “no documentation, not a cache value”)

geant4_set_and_check_package_variable(EXPAT_LIBRARY_RELEASE “/Library/Developer/CommandLineTools/SDKs/MacOSX15.1.sdk/usr/lib/libexpat.tbd” FILEPATH “Path to a library.”)

How can I fix it? I appraised than you can help me

Hi Leo

Looks like the problem is CMakeCache.txt in the build directory. It “remembers” previous builds. Simply remove it - a new one will be created.

Please try and let us know if it fixes things for you.

John

Hi John

I removed it and the problem is still there

OK. Let’s have another try.

How did you install Qt? With homebrew? If so, it installs both Qt5 and Qt6, and cross-links them is some way. It looks like you are building with Qt5 (I.e., you have not specified Qt6 explicitly - GEANT4_USE_QT_QT6=ON). To get Qt5, you have to unlink:

brew unlink qt

So, either specify Qt6 or unlink. (To get back to Qt6, brew link qt).

Goes without saying, at this level of problem, at every change, you should re-build from scratch in a clean build directory - or at least, remove CMakeCache.txt.

Let us know how you get on?

John

You need to remove the Geant4PackageCache.cmake file as this is the fundamental cause of the problem. This isn’t installed by default from version 11.3, so I suspect your v11.2 install is still around. Nevertheless, remove that file and the main error should resolve.

You may will then need to set CMAKE_PREFIX_PATH to include /usr/local/opt/qt@5 when building your application.