OpenGL CMake Automoc problem

I’m trying to compile Geant4.10.7 on our cluster and get stuck by a compilation error immediately:

[  1%] Automatic MOC for target G4OpenGL
cd /zfs_home/accsoft/SL68/build/Geant4/10.07-p01/GCC-8.3.0-2.32/easybuild_obj/source && /zfs_home/accsoft/SL68/software/CMake/3.8.0-GCC-8.3.0-2.32/bin/cmake -E cmake_autogen /zfs_home/accsoft/SL68/build/Geant4/10.07-p01/GCC-8.3.0-2.32/easybuild_obj/source/CMakeFiles/G4OpenGL_autogen.dir/ Release
AutoMoc: Error: /zfs_home/accsoft/SL68/build/Geant4/10.07-p01/GCC-8.3.0-2.32/geant4.10.07/source/visualization/OpenGL/src/
The file includes the moc file "moc_G4OpenGLQtExportDialog.cpp", but could not find header "G4OpenGLQtExportDialog{.h,.hh,.h++,.hm,.hpp,.hxx,.in,.txx}" in /zfs_home/accsoft/SL68/build/Geant4/10.07-p01/GCC-8.3.0-2.32/geant4.10.07/source/visualization/OpenGL/src/

make[2]: *** [source/CMakeFiles/G4OpenGL_autogen] Error 1

It seems to be looking for the header here:
but it should end with “include” where the file actually exists.

I’m using GCC 8.3.0, Qt5.15.2. Below is EasyConfig file contents I use as part of the EasyBuild system to make an environment module - our preferre build system for our cluster. It shows the dependencies and configuration options.

It’s SLC6.

File Edit Options Buffers Tools Help                                                                                                                                                                                   
name = 'Geant4'
version = '10.07-p01'

homepage = ''
description = """Geant4 is a toolkit for the simulation of the passage of particles through matter.
 Its areas of application include high energy, nuclear and accelerator physics,
 as well as studies in medical and space science."""

toolchain = {'name': 'GCC', 'version': '8.3.0-2.32'}

source_urls = ['']
sources = ['%(namelower)s.10.07.tar.gz']

patches = [

dependencies = [
    ('expat', '2.1.1'),
    ('CLHEP', ''),
    ('Xerces-C++', '3.1.2'),
    ('libGLU', '9.0.0', '-Mesa-11.2.1'),

parallel = 6

builddependencies = [('CMake', '3.8.0')]

configopts += " -DGEANT4_INSTALL_DATA=ON"
configopts += " -DGEANT4_USE_GDML=ON"
configopts += " -DGEANT4_USE_OPENGL_X11=ON"
configopts += " -DGEANT4_USE_QT=ON"
configopts += " -DGEANT4_USE_RAYTRACER_X11=ON"
configopts += " -DGEANT4_USE_SYSTEM_CLHEP=ON"
configopts += " -DGEANT4_USE_SYSTEM_EXPAT=ON"
configopts += " -DGEANT4_USE_SYSTEM_ZLIB=ON"

moduleclass = 'phys'

Any advice would be appreciated!

Thanks for the report! This is indeed a bug either in CMake 3.8 or how we are using the AUTOMOC/Autogen functionality. I’ve confirmed the error in CMake 3.8, but the issue appears resolved from 3.9.0 onwards. There’s a Bugzilla to track this:

but in the meantime there are two workarounds:

  1. Use CMake 3.9.0 or newer as these don’t appear to suffer the problem. This is the simplest solution.

  2. If (1) isn’t possible, then copy the files


    to source/visualization/OpenGL/src



    to source/interfaces/basic/src

This second option should not break the build as it’s just reproducing the same header and there should be no path clashes anyway.


Ah ha! Thanks for the solution. Indeed, 3.8 is a little old for CMake - just it’s what we had on the cluster. I updated it to 3.15 and it compiled no problem. Thanks for making the issue also.

I guess you could require >= 3.9? The release notes (and presumably the version check in the main CMakeLists.txt) say 3.8 as I’m sure you’re well aware.

Thanks again,

I’m going to see if there is a CMake variable/property that can be set first! However, yes, if this isn’t solvable I think we’ll have to require >=3.9, at least if Qt support is requested.