Building Geant4 with cmake-gui and Qt6 Installed

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.2.2
_Operating System:_MacOS Sonoma
_Compiler/Version:_xtools
_CMake Version:_cmake version 3.29.5

I would like to use cmake-gui when building a Geant4 Application. I am finding that for the generate option to pick up values etc, I seem to have needed to use cmake-gui when building the geant4 install.

I have Qt6 installed on my system via https://doc.qt.io/qt-6/macos.html for things other than geant4 which I understand does not have support for geant4-v11.2.2

When trying to use cmake-gui for geant4 install, I assume I need to change QT_DIR to point at the Qt5 installed by brew but when I change the value and click on generate it gets set back to /usr/local/lib/cmake/Qt6

Hi Keith

Have a look at this Forum item from a few days ago. It may be a homebrew issue. Does it help?

John

The post has qt stuff in /usr/local/opt/qt5

On my system I have subdirectories /usr/local/opt of qt, qt@4 qt@5 qt@6

If I try brew install qt5 it says qt5 has been renamed qt@5

To try and avoid any confusion over installs, unlinks etc.

I brew uninstalled qt@5 with
brew uninstall qt@5
brew install qt@5

Tried cmake-gui with ( Also with brew unlink qt as per mentioned post)
QT_DIR = /usr/local/opt/qt@5/lib/cmake/Qt5

(g4) keithsloan@Keiths-iMac-2 Qt5 % pwd
/usr/local/opt/qt@5/lib/cmake/Qt5
(g4) keithsloan@Keiths-iMac-2 Qt5 % ls
Qt5Config.cmake Qt5ConfigVersion.cmake Qt5ModuleLocation.cmake
(g4) keithsloan@Keiths-iMac-2 Qt5 % pwd

Get error as it looks for Qt6

CMake Error at cmake/Modules/G4InterfaceOptions.cmake:181 (find_package):
Could not find a package configuration file provided by “QT” with any of
the following names:

Qt6Config.cmake
qt6-config.cmake

Add the installation prefix of “QT” to CMAKE_PREFIX_PATH or set “QT_DIR” to
a directory containing one of the above files. If “QT” provides a separate
development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
cmake/Modules/G4CMakeMain.cmake:64 (include)
CMakeLists.txt:49 (include)

Configuring incomplete, errors occurred!

If I try brew uninstall qt@6 it barfs

(g4) keithsloan@Keiths-iMac-2 Qt5 % brew uninstall qt@6

Error: Refusing to uninstall /usr/local/Cellar/qt/6.7.0_2

because it is required by pyqt and vtk, which are currently installed.

You can override this and force removal with:

brew uninstall --ignore-dependencies qt@6

Hi Keith

Did you try

brew unlink qt

?

I installed Qt5 and Qt6 on my Mac with homebrew. (If I recall, it’s just brew install qt, and you get both.) If I want to build against Qt5, I issue the above command, then

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

To link against Qt6 (for development), brew link qt, and change ‘5’ to ‘6’ above.

John

CMake must also have been set with GEANT4_USE_QT_QT6 set to ON (it’s an advanced option, so isn’t shown be default in the GUI) as it wouldn’t look for Qt6 otherwise. That will also be forcing looking for Qt6 in preference to Qt5. Set it to off and see if that helps.

In all cases I deleted and recreated directories

geant4-v11.2.2-build
geant4-v11.2.2-install

Following Johns suggestion I was able to build a system with Qt but its location ended up not surprisingly under
/usr/local/opt/qt@5

So I decided to follow Ben’ suggestion.

uninstalled qt@5 and reinstalled with brew

from within geant4-v11.2.2-build

I did cmake-gui .

I added entry GEANT4_USE_QT_QT6
and then set it to OFF.

On clicking Generate the entry was no longer displayed but has created a correct set of CMakeFiles

Now able to successfully geant4-v11.2.2-install & build app

Many Thanks