Skip to content
Snippets Groups Projects
Commit e233aa9b authored by liblhcb's avatar liblhcb
Browse files

updates and fixes to CMake build

- added build of examples
- use Geant4 sources from git (https://gitlab.cern.ch/lhcb/Geant4-srcs)

Merge branch 'master' of ssh://gitlab.cern.ch:7999/clemenci/Geant4

* 'master' of ssh://gitlab.cern.ch:7999/clemenci/Geant4:
  added entries to release.notes
  minor fix to handling of G4_NATIVE_VERSION
  use Geant4-srcs master for version HEAD
  do not use Ninja to buid Geant4 (not working)
  Get Geant4 sources from git instead of tarfiles
  fixed installation of Geant4 analysis headers
  install examples scripts and create "aliases" for commands
  removed 'Makefile's that should not be there
  Fixed build of the selected examples.
  updated copying of Geant4 sources to CMT directories
  added useful .gitignore files

See merge request !1


git-svn-id: svn+ssh://svn.cern.ch/reps/lhcb/Geant4/trunk@197133 4525493e-7705-40b1-a816-d608a930855b
parents d7d6ff1e d515758d
No related branches found
No related tags found
No related merge requests found
Showing
with 123 additions and 894 deletions
!-----------------------------------------------------------------------------
! Package : Geant4/G4VRML
! Responsible : Gloria CORTI
! Purpose :
! Purpose :
!-----------------------------------------------------------------------------
! 2015-11-02 - Marco Clemencic
- Added .gitignore file
!============================ G4VRML v4r2 2011-04-12 =========================
! 2011-04-12 - Gloria Corti
- Introduce use of pattern to switch off building this package on winxp
......
/G4analysis/
/src/
......@@ -4,6 +4,9 @@
! Purpose : Definition of analysis used in G4examples
!-----------------------------------------------------------------------------
! 2015-11-02 - Marco Clemencic
- Added .gitignore file
!===================== Geant4/G4analysis v1r0 2014-07-25 =====================
! 2014-03-06 - James Mccarthy
......
......@@ -21,11 +21,29 @@ else()
set(G4DATA ../share)
endif()
if(DEFINED ENV{G4_NATIVE_VERSION})
set(Geant4_tag $ENV{G4_NATIVE_VERSION})
if(NOT Geant4_tag MATCHES "^4\\.")
# G4_NATIVE_VERSION might not contain the initial '4.' that we need
# see https://its.cern.ch/jira/browse/LHCBGAUSS-43
set(Geant4_tag 4.${Geant4_tag})
endif()
if(NOT Geant4_tag MATCHES "^geant")
set(Geant4_tag geant${Geant4_tag})
endif()
else()
set(Geant4_tag ${CMAKE_PROJECT_VERSION})
endif()
# Special mapping of version HEAD
if(Geant4_tag STREQUAL "HEAD")
set(Geant4_tag master)
endif()
include(ExternalProject)
ExternalProject_Add(Geant4
URL http://geant4.cern.ch/support/source/geant${Geant4_version}.tar.gz
PATCH_COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/patches/patch_g4_sources.py ${CMAKE_SOURCE_DIR} ${Geant4_version}
GIT_REPOSITORY https://gitlab.cern.ch/lhcb/Geant4-srcs.git
GIT_TAG ${Geant4_tag}
CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/toolchain.cmake
-DGEANT4_BUILD_CXXSTD=${GAUDI_CXX_STANDARD}
-DGEANT4_INSTALL_DATA=OFF
......
# Normal packages
# Aliases (LHCb names -> G4 names)
set(parmodels_source parameterisations)
foreach(pack analysis digits_hits event geometry global graphics_reps intercoms
materials parmodels particles physics_lists processes readout run
track tracking)
message(STATUS "Copying ${pack} sources")
if(${pack}_source)
set(src_pack ${${pack}_source})
else()
set(src_pack ${pack})
endif()
message(STATUS "Copying ${src_pack} sources to G4${pack}")
execute_process(COMMAND find ( -type d -a -name src
-a -not ( -path "*test/*" -o -path "*/abla/*" ) )
#-printf "copying ${pack}/%p\\n"
-a -not -path "*test/*" )
#-printf "copying ${src_pack}/%p\\n"
-exec mkdir -p "@G4DST@/G4${pack}/{}" ";"
-exec cp -r "{}/." "@G4DST@/G4${pack}/{}" ";"
WORKING_DIRECTORY @G4SRC@/${pack})
WORKING_DIRECTORY @G4SRC@/${src_pack})
execute_process(COMMAND find ( -type d -a -name include
-a -not ( -path "*test/*" -o -path "*/abla/*" ) )
-a -not -path "*test/*" )
#-printf "copying ${pack}/%p\\n"
-exec mkdir -p "@G4DST@/G4${pack}/G4${pack}" ";"
-exec cp -r "{}/." "@G4DST@/G4${pack}/G4${pack}" ";"
WORKING_DIRECTORY @G4SRC@/${pack})
WORKING_DIRECTORY @G4SRC@/${src_pack})
endforeach()
# UI packages
......@@ -38,7 +46,7 @@ foreach(pack FukuiRenderer modeling OpenGL RayTracer Tree
else()
set(local_pack G4${pack})
endif()
message(STATUS "Copying visualization/${pack} sources")
message(STATUS "Copying visualization/${pack} sources to ${local_pack}")
execute_process(COMMAND mkdir -p @G4DST@/${local_pack}/${pack}/src
@G4DST@/${local_pack}/${local_pack})
execute_process(COMMAND cp -r @G4SRC@/visualization/${pack}/src/.
......@@ -48,15 +56,15 @@ foreach(pack FukuiRenderer modeling OpenGL RayTracer Tree
endforeach()
set(pack externals)
message(STATUS "Copying visualization/${pack} sources")
message(STATUS "Copying visualization/${pack} sources to G4${pack}")
execute_process(COMMAND find ( -type d -a -name src
-a -not ( -path "*test/*" -o -path "*/abla/*" ) )
-a -not -path "*test/*" )
#-printf "copying ${pack}/%p\\n"
-exec mkdir -p "@G4DST@/G4${pack}/{}" ";"
-exec cp -r "{}/." "@G4DST@/G4${pack}/{}" ";"
-exec mkdir -p "@G4DST@/G4${pack}/externals/{}" ";"
-exec cp -r "{}/." "@G4DST@/G4${pack}/externals/{}" ";"
WORKING_DIRECTORY @G4SRC@/visualization/${pack})
execute_process(COMMAND find ( -type d -a -name include
-a -not ( -path "*test/*" -o -path "*/abla/*" ) )
-a -not -path "*test/*" )
#-printf "copying ${pack}/%p\\n"
-exec mkdir -p "@G4DST@/G4${pack}/G4${pack}" ";"
-exec cp -r "{}/." "@G4DST@/G4${pack}/G4${pack}" ";"
......@@ -65,7 +73,7 @@ execute_process(COMMAND find ( -type d -a -name include
# Vis packages
set(pack gdml)
message(STATUS "Copying persistency/${pack} sources")
message(STATUS "Copying persistency/${pack} sources to ${local_pack}")
set(local_pack G4GDML)
execute_process(COMMAND mkdir -p @G4DST@/${local_pack}/src
@G4DST@/${local_pack}/schema
......@@ -76,3 +84,25 @@ execute_process(COMMAND cp -r @G4SRC@/persistency/${pack}/schema/.
@G4DST@/${local_pack}/schema)
execute_process(COMMAND cp -r @G4SRC@/persistency/${pack}/include/.
@G4DST@/${local_pack}/${local_pack})
# Examples
foreach(ex_name TestEm3 TestEm5 TestEm7 TestEm9)
message(STATUS "Copying examples/.../${ex_name} sources to G4examples/.../G4${ex_name}")
set(src @G4SRC@/../examples/extended/electromagnetic/${ex_name})
set(dest @G4DST@/G4examples/extended/electromagnetic/G4${ex_name})
execute_process(COMMAND mkdir -p ${dest}/include ${dest}/src)
execute_process(COMMAND cp -r ${src}/include/. ${dest}/include)
execute_process(COMMAND cp -r ${src}/src/. ${dest}/src)
execute_process(COMMAND cp -r ${src}/${ex_name}.cc ${dest})
endforeach()
foreach(ex_name Hadr00)
message(STATUS "Copying examples/.../${ex_name} sources to G4examples/.../G4${ex_name}")
set(src @G4SRC@/../examples/extended/hadronic/${ex_name})
set(dest @G4DST@/G4examples/extended/hadronic/G4${ex_name})
execute_process(COMMAND mkdir -p ${dest}/include ${dest}/src)
execute_process(COMMAND cp -r ${src}/include/. ${dest}/include)
execute_process(COMMAND cp -r ${src}/src/. ${dest}/src)
execute_process(COMMAND cp -r ${src}/${ex_name}.cc ${dest})
endforeach()
......@@ -4,6 +4,14 @@
! Purpose : Configuration package for Geant4 build
!-----------------------------------------------------------------------------
! 2015-11-02 - Marco Clemencic
- Build Geant4 using the sources in https://gitlab.cern.ch/lhcb/Geant4-srcs
instead of using official tarballs and patching them.
- Added .gitignore file
! 2015-10-13 - Marco Clemencic
- Fixed build of the selected examples.
! 2015-09-09 - Marco Clemencic
- Fixed ccache (and custom launchers) support in CMake build.
- Use the same C++ standard as Gaudi in CMake builds.
......@@ -20,7 +28,7 @@
! ======================= G4config v96r3p0 2015-05-11 ========================
! 2015-05-12 - Timothy Williams
- Updated copy_examples_source.csh to copy private sources for TestEm5
! 2015-05-11 - Timothy Williams
- Added execution of srcnew copying to copy_examples_source.csh
......
# - Try to find CLHEP
# Defines:
#
# CLHEP_FOUND
# CLHEP_VERSION
# CLHEP_INCLUDE_DIR
# CLHEP_INCLUDE_DIRS (not cached)
# CLHEP_<component>_LIBRARY
# CLHEP_<component>_FOUND
# CLHEP_LIBRARIES (not cached)
# CLHEP_LIBRARY_DIRS (not cached)
#
# Note: version detection inspired by FindBoost.cmake
find_path(CLHEP_INCLUDE_DIR CLHEP/ClhepVersion.h
HINTS $ENV{CLHEP_ROOT_DIR}/include ${CLHEP_ROOT_DIR}/include)
if(CLHEP_INCLUDE_DIR)
if(NOT DEFINED CLHEP_VERSION)
file(READ "${CLHEP_INCLUDE_DIR}/CLHEP/ClhepVersion.h" _CLHEP_VERSION_H_CONTENTS)
string(REGEX REPLACE ".*static std::string String\\(\\)[^\"]*return \"([^\"]*)\".*" "\\1" CLHEP_VERSION "${_CLHEP_VERSION_H_CONTENTS}")
set(CLHEP_VERSION ${CLHEP_VERSION} CACHE INTERNAL "Detected version of CLHEP")
message(STATUS "CLHEP version: ${CLHEP_VERSION}")
endif()
endif()
set(_CLHEP_COMPONENTS Cast Evaluator Exceptions GenericFunctions Geometry Random RandomObjects RefCount Vector Matrix)
foreach(component ${_CLHEP_COMPONENTS})
find_library(CLHEP_${component}_LIBRARY NAMES CLHEP-${component}-${CLHEP_VERSION}
HINTS $ENV{CLHEP_ROOT_DIR}/lib ${CLHEP_ROOT_DIR}/lib)
if (CLHEP_${component}_LIBRARY)
set(CLHEP_${component}_FOUND 1)
list(APPEND CLHEP_LIBRARIES ${CLHEP_${component}_LIBRARY})
get_filename_component(libdir ${CLHEP_${component}_LIBRARY} PATH)
list(APPEND CLHEP_LIBRARY_DIRS ${libdir})
else()
set(CLHEP_${component}_FOUND 0)
endif()
mark_as_advanced(CLHEP_${component}_LIBRARY)
endforeach()
if(CLHEP_LIBRARY_DIRS)
list(REMOVE_DUPLICATES CLHEP_LIBRARY_DIRS)
endif()
set(CLHEP_INCLUDE_DIRS ${CLHEP_INCLUDE_DIR})
# handle the QUIETLY and REQUIRED arguments and set CLHEP_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CLHEP DEFAULT_MSG CLHEP_INCLUDE_DIR CLHEP_LIBRARIES)
mark_as_advanced(CLHEP_FOUND CLHEP_INCLUDE_DIR)
# Hack for Geeant4 compatibility (we choose a random library)
set(CLHEP_LIBRARY ${CLHEP_Random_LIBRARY})
This diff is collapsed.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Script to patch Geant 4 sources for LHCb.
'''
import sys
import os
import shutil
import logging
from subprocess import call
from os.path import join, basename, exists
logging.basicConfig(level=logging.INFO)
log = logging.getLogger()
# root directory of the project and Geant4 version
root_dir, g4vers = sys.argv[1:]
script_dir = os.path.realpath(os.path.dirname(sys.argv[0]))
# apply patch to CMake configuration
log.info('patching Geant4 CMake configuration')
call(['patch', '-p2', '-i', join(script_dir, 'geant4.cmake.patch')])
# copy physics lists
def copydir(src, dst):
if not os.path.exists(dst):
log.info('creating directory %s', dst)
os.makedirs(dst)
for f in os.listdir(src):
if f in ('.', '..', '.svn'):
continue
if os.path.isdir(join(src, f)):
copydir(join(src, f), join(dst, f))
else:
log.info('copying %s -> %s', join(src, f), join(dst, f))
shutil.copy(join(src, f), join(dst, f))
copydir(join(root_dir, 'Geant4', 'G4LHCblists', 'G4LHCblists'),
join('source', 'physics_lists', 'LHCb', 'include'))
copydir(join(root_dir, 'Geant4', 'G4LHCblists', 'src'),
join('source', 'physics_lists', 'LHCb', 'src'))
# replace fixed files
fixes_root = join(root_dir, 'Geant4', 'G4processes', 'srcnew')
fixes_dst_root = join('source', 'processes', 'hadronic')
# (fixes is a list of pairs, src+dst)
fixes = [(join('cross_sections', 'G4ElectroNuclearCrossSection.cc'), join(fixes_dst_root, 'cross_sections', 'src'))]
for src, dst in fixes:
log.info('copying %s to dir %s', join(fixes_root, src), dst)
# bkup
old = join(dst, basename(src))
if exists(old):
shutil.copy(old, old + '.orig')
shutil.copy(join(fixes_root, src), dst)
# override Geant4 cmake modules
copydir(join(script_dir, 'cmake', 'Modules'),
join('cmake', 'Modules'))
/detector/
/digits/
/G4digits_hits/
/hits/
/scorer/
/utils/
!-----------------------------------------------------------------------------
! Package : Geant4/G4digits_hits
! Responsible : Gloria CORTI, Silvia MIGLIORANZI
! Purpose :
! Purpose :
!-----------------------------------------------------------------------------
! 2015-11-02 - Marco Clemencic
- Added .gitignore file
!====================== G4digits_hits v7r1p1 2011-07-14 ======================
! 2011-03-02 - Hubert Degaudenzi
- Added ignore properties in svn
......
/G4event/
/src/
!-----------------------------------------------------------------------------
! Package : Geant4/G4event
! Responsible : Florence RANJARD
! Purpose :
! Purpose :
!-----------------------------------------------------------------------------
! 2015-11-02 - Marco Clemencic
- Added .gitignore file
!========================= G4event v6r0p1 2011-06-29 =========================
! 2011-06-29 - Hubert DEGAUDENZI
- Added ignore properties in svn
......
include ${LBCONFIGURATIONROOT}/data/Makefile
include $(CMTROOT)/src/Makefile.header
include $(CMTROOT)/src/constituents.make
......@@ -3,6 +3,10 @@
! Responsible : James McCarthy, Luca Pescatore
! Purpose : Examples packages provided my Geant4, used as standalone tests
!-----------------------------------------------------------------------------
! 2015-11-02 - Marco Clemencic
- Added .gitignore file
!2015-07-29- Tim Williams
- Installed scripts to run TestEm3 and TestEm5, can be run with 'Calorimeter_test' and 'MultipleScattering_test' respectively
- Removed unused and unnecessary scripts from TestEm3 and TestEm5
......@@ -38,12 +42,12 @@
! 2014-07-16 - Gloria Corti
- Modified all requirements files to use pattern linker_library instead of
appending library to XXX_use_linkopts. This fixes compilation issues on
appending library to XXX_use_linkopts. This fixes compilation issues on
slc5, see details on https://its.cern.ch/jira/browse/LHCBGAUSS-193
!===================== Geant4/G4examples v4r0 2014-07-11 =====================
! 2014-03-27 - Nigel Watson
- Adapted requirements for nightly builds, following Marco Cl.'s
- Adapted requirements for nightly builds, following Marco Cl.'s
recommendations.
!=============================================================================
/include/
/src/
/TestEm3.cc
gaudi_depends_on_subdirs(Geant4/G4config)
gaudi_install_scripts()
gaudi_alias(Calorimeter_test ExampleTestEm3run.sh)
# CMT-compatibility alias
gaudi_alias(testEm3.exe TestEm3)
......@@ -3,6 +3,11 @@
! Responsible : Timothy Williams
! Purpose : Standalone Geant4 example used to test EM shower simulation
!-----------------------------------------------------------------------------
! 2015-11-02 - Marco Clemencic
- Added .gitignore file
- Added CMake configuration.
================================================================================
! 2015-05-07 - Timothy Williams
-Added srcnew diractory to store private source files. These get copied over with copyPatchedsource.py in cmt after sources are copied from LCG area.
......
/include/
/src/
/TestEm5.cc
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment