apt-sim / AdePT

Accelerated demonstrator of electromagnetic Particle Transport
Apache License 2.0
25 stars 34 forks source link

[cmake] Fix configuration with Geant4 11.1 #267

Closed hahnjo closed 8 months ago

hahnjo commented 11 months ago

When trying to configure with Geant4 11.1, G4HepEm seems to have problems finding Geant4 even though AdePT's correctly found it before. As a reason, CMake quotes not finding XercesC even though both Vecgeom and Geant4 (searched from AdePT) find it. It seems explicitly looking for XercesC solves the problem (not sure why).

hahnjo commented 11 months ago

@agheata @JuanGonzalezCaminero which version of Geant4 are you using, are you also facing errors like

CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Failed to find XercesC (missing: XercesC_INCLUDE_DIR) (found suitable
  version "3.2.3", minimum required is "3.2.3")
Call Stack (most recent call first):
  /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake/Modules/FindXercesC.cmake:110 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  /usr/share/cmake/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
  /home/jhahnfel/Geant4/geant4-11.1-release/install-v11.1.2/lib64/cmake/Geant4/Geant4Config.cmake:311 (find_dependency)                                                                                
  external/g4hepem/CMakeLists.txt:58 (find_package)

with Geant4 11.1 (version 11.0 seems to work fine)?

cc @drbenmorgan as well

phsft-bot commented 11 months ago

Can one of the admins verify this patch?

drbenmorgan commented 11 months ago

@hahnjo also which CMake version are you running? Just wondering if this is related to the changes in 3.27 that broke the finding of EXPAT. Do you have a /home/jhahnfel/Geant4/geant4-11.1-release/install-v11.1.2/lib64/cmake/Geant4/Geant4PackageCache.cmake file, and if so could you post it here (or just any lines related to XercesC) please?

I'll fire up things locally as well, though likely won't have time until Monday.

agheata commented 11 months ago

@agheata @JuanGonzalezCaminero which version of Geant4 are you using, are you also facing errors like

I'm on 11.0 and don't see this

hahnjo commented 11 months ago

@hahnjo also which CMake version are you running?

cmake version 3.20.2

(from AlmaLinux 8)

Just wondering if this is related to the changes in 3.27 that broke the finding of EXPAT. Do you have a /home/jhahnfel/Geant4/geant4-11.1-release/install-v11.1.2/lib64/cmake/Geant4/Geant4PackageCache.cmake file, and if so could you post it here (or just any lines related to XercesC) please?

Yes, that file exists. The relevant lines are

# XercesC Build Time Settings
geant4_set_and_check_package_variable(XercesC_INCLUDE_DIR "/usr/include" PATH "Xerces-C++ include directory")
geant4_set_and_check_package_variable(XercesC_LIBRARY_RELEASE "/usr/lib64/libxerces-c.so" FILEPATH "Xerces-C++ libraries (release)")

which looks reasonable to me, and is the same as in /home/jhahnfel/Geant4/geant4-11.0-release/install-v11.0.2/lib64/Geant4-11.0.2/Geant4PackageCache.cmake for Geant4 11.0 that works just fine. The only diff between the CMake files of the two installations related to XercesC is bumping the version to from 3.2.2 to 3.2.3, which is exactly the version I have installed.

I'll fire up things locally as well, though likely won't have time until Monday.

Thanks! Not really urgent for now, was just trying to update my local build...

drbenmorgan commented 11 months ago

Thanks @hahnjo, those lines indeed look fine. It might be something to do with the version - you could try ~hacking~ deleting the Xerces-C version that Geant4Config.cmake adds:

# - GDML
set(Geant4_gdml_FOUND ON)
if(Geant4_gdml_FOUND)
  find_dependency(XercesC 3.2.4)
endif()

to

# - GDML
set(Geant4_gdml_FOUND ON)
if(Geant4_gdml_FOUND)
  find_dependency(XercesC)
endif()

and seeing if that resolves things. I'll have a look in any case as there's something weird going on.

hahnjo commented 11 months ago

@drbenmorgan no luck, only changed the error message to

CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):                                                                                                              
  Failed to find XercesC (missing: XercesC_INCLUDE_DIR) (found version                                                                                                                                  
  "3.2.3")

ie not mentioning minimum required is "3.2.3" anymore...

drbenmorgan commented 10 months ago

I've managed to reproduce this locally, albeit using the master of VecGeom - @hahnjo, which VecGeom commit/tag are you using, or more specifically, does the VecGeomConfig.cmake file picked up have the lines:

if(NOT DEFINED VecCore_DIR)
   set(VecCore_DIR "/.../lib64/cmake/VecCore")
endif()
if(NOT DEFINED XercesC_INCLUDE_DIR)
  set(XercesC_INCLUDE_DIR "/.../include")
endif()

with ... being whatever prefix those are installed under? It's these that seem to affect behaviour/contend with Geant4 11.1, but wanted to cross-check.

hahnjo commented 10 months ago

@drbenmorgan yes, I'm using (approximately) VecGeom master as this is now required since recently. VecGeomConfig.cmake has the following lines:

if(NOT DEFINED XercesC_INCLUDE_DIR)
  set(XercesC_INCLUDE_DIR "/usr/include")
endif()

And just for completeness, Geant4 is not built against any VecGeom.

drbenmorgan commented 10 months ago

Thanks! Same here, "pure" Geant4 without VecGeom, and for reference, same CMake version (3.20.2, Rocky Linux 9).