From 720779c86a0a733ba25873178d522997c1cd596e Mon Sep 17 00:00:00 2001
From: Marco Clemencic <marco.clemencic@cern.ch>
Date: Tue, 13 Oct 2015 16:04:43 +0200
Subject: [PATCH] Fixed build of the selected examples.

---
 Geant4/G4config/doc/release.notes           |  5 +++-
 Geant4/G4config/patches/geant4.cmake.patch  | 31 ++++++++++++++++++++-
 Geant4/G4config/patches/patch_g4_sources.py | 12 +++++++-
 3 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/Geant4/G4config/doc/release.notes b/Geant4/G4config/doc/release.notes
index 325affe..7456d84 100755
--- a/Geant4/G4config/doc/release.notes
+++ b/Geant4/G4config/doc/release.notes
@@ -4,6 +4,9 @@
 ! Purpose     : Configuration package for Geant4 build
 !-----------------------------------------------------------------------------
 
+! 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 +23,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
 
diff --git a/Geant4/G4config/patches/geant4.cmake.patch b/Geant4/G4config/patches/geant4.cmake.patch
index 896a6b3..f83ec94 100644
--- a/Geant4/G4config/patches/geant4.cmake.patch
+++ b/Geant4/G4config/patches/geant4.cmake.patch
@@ -190,7 +190,7 @@ diff -urN a/geant4.9.6.p04/cmake/Templates/Geant4Config.cmake.in b/geant4.9.6.p0
    G4RayTracer${_geant4_lib_use_suffix}
    G4VRML${_geant4_lib_use_suffix}
    )
-@@ -413,13 +411,14 @@
+@@ -413,13 +411,15 @@
  list(APPEND _geant4_internal_libraries
    G4vis_management${_geant4_lib_use_suffix}
    G4modeling${_geant4_lib_use_suffix}
@@ -205,6 +205,7 @@ diff -urN a/geant4.9.6.p04/cmake/Templates/Geant4Config.cmake.in b/geant4.9.6.p0
    G4readout${_geant4_lib_use_suffix}
 -  G4physicslists${_geant4_lib_use_suffix}
 +  G4physics_lists${_geant4_lib_use_suffix}
++  G4LHCblists${_geant4_lib_use_suffix}
    G4run${_geant4_lib_use_suffix}
    G4event${_geant4_lib_use_suffix}
    G4tracking${_geant4_lib_use_suffix}
@@ -747,3 +748,31 @@ diff -urN a/geant4.9.6.p04/source/visualization/OpenInventor/sources.cmake b/gea
      G4materials
      G4modeling
      G4tracking
+--- a/geant4.9.6.p04/examples/extended/electromagnetic/TestEm5/CMakeLists.txt	2015-02-04 10:01:02.000000001 +0100
++++ b/geant4.9.6.p04/examples/extended/electromagnetic/TestEm5/CMakeLists.txt	2015-10-13 14:12:01.000000001 +0200
+@@ -20,11 +20,14 @@
+ #
+ include(${Geant4_USE_FILE})
+
++find_package(ROOT REQUIRED Hist Gpad)
++
+ #----------------------------------------------------------------------------
+ # Locate sources and headers for this project
+ #
+-include_directories(${PROJECT_SOURCE_DIR}/include 
+-                    ${Geant4_INCLUDE_DIR})
++include_directories(${PROJECT_SOURCE_DIR}/include
++                    ${Geant4_INCLUDE_DIR}
++                    ${ROOT_INCLUDE_DIR})
+ file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
+ file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
+
+@@ -32,7 +35,7 @@
+ # Add the executable, and link it to the Geant4 libraries
+ #
+ add_executable(TestEm5 TestEm5.cc ${sources} ${headers})
+-target_link_libraries(TestEm5 ${Geant4_LIBRARIES} )
++target_link_libraries(TestEm5 ${Geant4_LIBRARIES} ${ROOT_LIBRARIES})
+
+ #----------------------------------------------------------------------------
+ # Copy all scripts to the build directory, i.e. the directory in which we
diff --git a/Geant4/G4config/patches/patch_g4_sources.py b/Geant4/G4config/patches/patch_g4_sources.py
index c82d6c1..0b498d4 100644
--- a/Geant4/G4config/patches/patch_g4_sources.py
+++ b/Geant4/G4config/patches/patch_g4_sources.py
@@ -45,7 +45,7 @@ copydir(join(root_dir, 'Geant4', 'G4LHCblists', 'src'),
 
 # replace fixed files
 fixes_root = join(root_dir, 'Geant4', 'G4processes', 'srcnew')
-fixes_dst_root = join('source', 'processes', 'hadronic') 
+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:
@@ -60,3 +60,13 @@ for src, dst in fixes:
 copydir(join(script_dir, 'cmake', 'Modules'),
         join('cmake', 'Modules'))
 
+# patches to examples
+for proc_type, ex_name, patch_map in [('electromagnetic', 'TestEm3', [('srcnew', 'src')]),
+                                      ('electromagnetic', 'TestEm5', [('incnew', 'include'),
+                                                                      ('srcnew', '.')])]:
+    for patches, orig in patch_map:
+        src = join(root_dir, 'Geant4', 'G4examples', 'extended', proc_type, 'G4' + ex_name, patches)
+        dst = join('examples', 'extended', proc_type, ex_name, orig)
+        #print src, dst
+        if exists(src):
+            copydir(src, dst)
-- 
GitLab