CMake does not configure with Qt5 on macOS Ventura 13.2


I try to configure CMake with Qt5 (installed via homebrew) on my macOS Ventura 13.2 and get the following error:

Checking C++ feature CXXSTDLIB_FILESYSTEM_NATIVE - Success
 CMake Error at /opt/homebrew/Cellar/qt@5/5.15.8_2/lib/cmake/Qt5Gui/Qt5GuiConfigExtras.cmake:9 (message):
   Failed to find "gl.h" in
 Call Stack (most recent call first):
   /opt/homebrew/Cellar/qt@5/5.15.8_2/lib/cmake/Qt5Gui/Qt5GuiConfig.cmake:227 (include)
   /opt/homebrew/Cellar/qt@5/5.15.8_2/lib/cmake/Qt5/Qt5Config.cmake:28 (find_package)
   cmake/Modules/G4InterfaceOptions.cmake:142 (find_package)
   cmake/Modules/G4CMakeMain.cmake:64 (include)
   CMakeLists.txt:50 (include)

In fact, the above-mentioned headers are not there. After some googling I managed to modify the Qt5GuiConfigExtras.cmake file to point it to the direction where I could locate those header files and it seems to find all Qt related packages but it ends up in a new error:

CMake Error at /opt/homebrew/Cellar/cmake/3.25.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
   Could NOT find OpenGL (missing: OPENGL_INCLUDE_DIR)
 Call Stack (most recent call first):
   /opt/homebrew/Cellar/cmake/3.25.2/share/cmake/Modules/FindOpenGL.cmake:443 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
   cmake/Modules/G4InterfaceOptions.cmake:199 (find_package)
   cmake/Modules/G4CMakeMain.cmake:64 (include)
   CMakeLists.txt:50 (include)

Hereby, I run the following command in my build directory:
ccmake -DCMAKE_PREFIX_PATH=/opt/homebrew/Cellar/qt@5/5.15.8_2/lib/cmake ..

Sidenote: by disabling Qt, I successfully compile Geant4 11.1.0 and run B1. However, in the vis.mac file I need to uncomment the line /vis/open/ VRML2FILE as it otherwise complains about /vis/open OGL 600x600-0+0 since it does not find OpenGL.

I understand that it is more OS-related issue (paths to OpenGL?) rather than G4, but maybe someone had similar troubles…

Any help is much appreciated! Thanks in advance

Hi Jurij

I find

cmake ... -DCMAKE_PREFIX_PATH="$(brew --prefix qt@5);..." ...

does the trick.


I have in my .profile

export PATH="/opt/homebrew/opt/qt@5/bin:$PATH"

following some printed out instructions when I installed it with brew. John’s answer is the nice dynamic solution.


Thank you both for a very quick reply!
Unfortunately, I still get the same errors trying both of your solutions. Followed even hints from here: Installation on macOS (M series)
but without any success…
One thing - I have disabled using system Expat since they weren’t found either - does it has any impact?

BR, Jurij

Using builtin expat shouldn’t make a difference, but the fact that system Expat and the OpenGL headers points, I think, to a system issue.

Do you have the command line developers tools installed and/or Xcode? Also, was this a completely fresh, from scratch build of Geant4, i.e. not reusing an existing build directory that might have old files in?


yes, I have both Xcode and CLT (ver 14.2). I even installed Apple’s OpenGL Metal since I read somewhere that Apple started providing their own OpenGL. Reinstalled Qt5 as well. Restarted my machine x times.
And yes, a completely fresh Geant4 installation. Intuitively, I also guess that it’s something weird with my OS. Will probably wait until next OS update and see if the error disappears. Yet, I can run Geant4 so it is not fully hopeless))

I tried: cmake -DCMAKE_PREFIX_PATH=/opt/homebrew/Cellar/qt@5/5.15.2_1/lib/cmake
and it fine with me

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