#-*-python-*- # GEANT4 configuration for SCons import os import SCons import subprocess from buildhelp import testenv # Much easier with the geant4-config tool g4env = Environment(ENV = {'PATH' : os.environ['PATH']}) # Temporary SCons object to parse geant4-config output, add PATH so it can find geant4-config config_exec = g4env.WhereIs("geant4-config") if config_exec == None: print "scons: FATAL ERROR (GEANT4.scons)" print "scons: Couldn't find geant4-config in path." error = SCons.Errors.BuildError() error.errstr = "Couldn't find geant4-config in path." error.filename = "GEANT4.scons" error.status = 2 error.exitstatus = 2 raise error g4env.ParseConfig("geant4-config --cflags --libs") geant4_version = subprocess.Popen(["geant4-config", "--version"], stdout=subprocess.PIPE).communicate()[0].rstrip() geant4_target = "10.0.2" if not geant4_version == geant4_target: print "scons: FATAL ERROR (GEANT.scons)" print "scons: Wrong geant4 version, must be " + geant4_target + ", is " + geant4_version error = SCons.Errors.BuildError() error.errstr = "Wrong geant4 version, must be " + geant4_target error.filename = "GEANT.scons" error.status = 2 error.exitstatus = 2 raise error # Check for an external CLHEP installation if none is included with GEANT4 conf = g4env.Configure() if not conf.CheckLib('G4clhep') and 'G4clhep' not in g4env['LIBS']: # Temp CLHEP lib (only) addition, see http://bugzilla-geant4.kek.jp/show_bug.cgi?id=1328 # Do it this way so it doesn't break with newer CLHEP installations using cmake # which do not generate the symlink for the versionless library clhepenv = Environment(ENV = {'PATH' : os.environ['PATH']}) config_exec = g4env.WhereIs("clhep-config") if config_exec == None: print "scons: FATAL ERROR (GEANT4.scons)" print "scons: Couldn't find clhep-config in path." error = SCons.Errors.BuildError() error.errstr = "Couldn't find clhep-config in path." error.filename = "GEANT4.scons" error.status = 2 error.exitstatus = 2 raise error clhepenv.ParseConfig("clhep-config --include --libs") g4env.Append(LIBPATH=clhepenv["LIBPATH"]) g4env.Append(LIBS=clhepenv["LIBS"]) g4env = conf.Finish() # Add G4 visualisation optionally g4vis = int(ARGUMENTS.get('g4vis', 1)) == 1 if g4vis and not testenv("G4VIS_NONE"): g4env.Append(CPPDEFINES=['G4VIS_USE']) # Hand back dictionary instead of environment because there is no # good way to merge two Environment objects. g4opts = {} for key in ['ASFLAGS','CCFLAGS','CPPDEFINES','CPPPATH','LIBPATH','LIBS','LINKFLAGS']: g4opts[key] = g4env[key] # Returns a dictionary when you import this file using: # g4opts = SConscript('config/GEANT4.scons') # # Merge into your build environment with: # env.Append(g4opts) Return("g4opts")