Skip to content
Snippets Groups Projects
Commit 19e4eebb authored by adrien-matta's avatar adrien-matta
Browse files

* Allow compilation with Geant4 9.x

        - Skip the missing include depending on G4 version
parent 362093c4
No related branches found
No related tags found
No related merge requests found
......@@ -16,8 +16,22 @@ set(CMAKE_INSTALL_MESSAGE LAZY)
# Finding Geant 4
find_package(Geant4 REQUIRED ui_all vis_all)
message(${Geant4_USE_FILE})
# Rely on name of the file to set the version
string(REGEX MATCH "Geant4-*.*.*/" G4Version "${Geant4_USE_FILE}")
string(REPLACE "Geant4-" "" G4Version "${G4Version}")
string(REPLACE "/" "" G4Version "${G4Version}")
string(FIND "${G4Version}" "." pos)
string(SUBSTRING "${G4Version}" "0" "${pos}" NPS_GEANT4_VERSION_MAJOR)
string(REPLACE "${NPS_GEANT4_VERSION_MAJOR}." "" G4Version "${G4Version}")
string(FIND "${G4Version}" "." pos)
string(SUBSTRING "${G4Version}" "0" "${pos}" NPS_GEANT4_VERSION_MINOR)
string(REPLACE "${NPS_GEANT4_VERSION_MINOR}." "" G4Version "${G4Version}")
set(NPS_GEANT4_VERSION_PATCH "${G4Version}")
message ("Geant4 found, Version : ${NPS_GEANT4_VERSION_MAJOR}.${NPS_GEANT4_VERSION_MINOR}.${NPS_GEANT4_VERSION_PATCH}")
include(${Geant4_USE_FILE})
add_definitions(${Geant4_DEFINITIONS})
# Finding NPLib
find_package(NPLib)
......@@ -75,6 +89,9 @@ if(Geant4_gdml_FOUND)
endif()
# set the Geant4 version info
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNPS_GEANT4_VERSION_MAJOR=${NPS_GEANT4_VERSION_MAJOR}")
# If the compiler is Clang, silence the unrecognised flags
if(${CMAKE_CXX_COMPILER_ID} MATCHES ".*Clang.*")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics -Wno-deprecated-register -Wno-shadow")
......
......@@ -85,9 +85,15 @@ PhysicsList::PhysicsList() : G4VModularPhysicsList(){
if(m_StoppingPhysics)
m_PhysList["StoppingPhysics"]=new G4StoppingPhysics();
if(m_HadronPhysicsQGSP_BIC_HP)
m_PhysList["HadronPhysicsQGSP_BIC_HP"] = new G4HadronPhysicsQGSP_BIC_HP();
if(m_HadronPhysicsQGSP_BIC_HP){
#if NPS_GEANT4_VERSION_MAJOR > 9
m_PhysList["HadronPhysicsQGSP_BIC_HP"] = new G4HadronPhysicsQGSP_BIC_HP();
#else
std::cout << "\r\032[1;31m Warning: physics list HadronPhysicsQGSP_BIC_HP require Geant4 10, process not activated \033[0m" <<std::endl;
#endif
m_PhysList["HadronPhysicsQGSP_BIC_HP"] = new G4HadronPhysicsQGSP_BIC_HP();
}
// Optical Photon for scintillator simulation
if(m_OpticalPhysics){
opticalPhysicsList = new G4OpticalPhysics(0);
......
......@@ -56,7 +56,9 @@
#include "G4HadronElasticPhysics.hh"
#include "G4HadronElasticPhysicsHP.hh"
#include "G4IonBinaryCascadePhysics.hh"
#if NPS_GEANT4_VERSION_MAJOR > 9
#include "G4HadronPhysicsQGSP_BIC_HP.hh"
#endif
#include "G4HadronPhysicsQGSP_BIC.hh"
class G4VPhysicsConstructor;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment