Strange CMake error (geant4_add_category)

I’m getting a weird error during the CMake invocation stage (version 10.7.p01):

CMake Error at cmake/Modules/G4DeveloperAPI.cmake:425 (message):
  geant4_add_category: trying to compose category 'G4analysis' using module
  'G4accumulables' which is already composed into category '1' 
Call Stack (most recent call first):
  cmake/Modules/G4DeveloperAPI.cmake:650 (geant4_add_category)
 source/analysis/CMakeLists.txt:31 (geant4_global_library_target)

This is the Docker file that reproduces the issue: remage-docker/Dockerfile.G4-10-7 at 072e5a8bcf505326d402e120955dee2505834cb0 · gipert/remage-docker · GitHub.

The weird thing is that this seems to be related to the way I install ROOT in the container. If I install the official binaries I can build G4 without any trouble, if I build ROOT from source I get the CMake error. Maybe it’s because of the build flags I’m using? I’ve got no clue.

I’ll continue investigating, I just wanted to know if build system developers have an idea about what is going on here.

1 Like

I’m afraid I don’t have any good ideas about what could be going on here. The only thing I can spot in the Dockerfile is that ROOT is built with C++17 and no other package is, but I have no idea why this would change/influence things (as Geant4 doesn’t depend on ROOT).

The thing to do is to try and track down whether the category “1” is being created, or if this is a bug in CMake scripts. That should be possible be adding some message commands before this block:

to print out the currently defined categories and where they were created:

get_property(__g4definedcats GLOBAL PROPERTY GEANT4_DEFINED_CATEGORIES)

foreach(__g4cat ${__g4definedcats})
  get_property(__g4catlocation GLOBAL PROPERTY GEANT4_CATEGORIES_${__g4cat}_CMAKE_LIST_FILE)
  message(STATUS "Category ${__g4cat} was defined at ${__g4catlocation}")
endforeach()

If you can try that for the failing case and see what’s printed, we’ll have a handle on where to look next.

Hi Ben, thanks for the input! Unfortunately one has to compile ROOT with the same C++ standard the app needs to be compiled with. That’s why I’m not relying on the official binaries. This instead is not needed for Geant4 (and VecGeom).

The situation gets even weirder if I try to swap the compilation order (first Geant4, then ROOT). In that case Geant4 compiles fine but ROOT fails with:

make[2]: Entering directory '/root/build'
[ 86%] Generating G__MathCore.cxx, ../../lib/libMathCore_rdict.pcm, ../../lib/libMathCore.rootmap
No such file or directory
make[2]: *** [math/mathcore/CMakeFiles/G__MathCore.dir/build.make:240: math/mathcore/G__MathCore.cxx] Error 1
make[2]: Leaving directory '/root/build'
make[1]: *** [CMakeFiles/Makefile2:26338: math/mathcore/CMakeFiles/G__MathCore.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

I will maybe post this in the ROOT forum. If I strip VecGeom out, I manage to compile both Geant4 and ROOT (???)

I don’t really understand what’s going on, it’s not even clear if it’s a Geant4 issue or not, at this point. Next step I guess I will try to do what you suggested…

Update: if I comment the Geant4 compilation step the ROOT error remains, so it must be related to VecGeom. I will post this on the ROOT forum.