From b1922e6413017a513d65d74bda503ecadef61644 Mon Sep 17 00:00:00 2001
From: Gerardo Ganis <Gerardo.Ganis@cern.ch>
Date: Tue, 14 Jan 2020 18:02:43 +0100
Subject: [PATCH 01/15] Try compile_extra=1 for openloops

---
 generators/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/generators/CMakeLists.txt b/generators/CMakeLists.txt
index 3d04f29a0e..ad87732d5b 100644
--- a/generators/CMakeLists.txt
+++ b/generators/CMakeLists.txt
@@ -1525,7 +1525,7 @@ LCGPackage_Add(
       BUILD_COMMAND ./openloops libinstall pptttt pptt pptt_ew ppttbb ppttj ppttj_ew pptw pptj pptjj ppjj ppjj_ew ppjjj ppjjj_ew ppatt ppattj pplltt ppllttj pplntt pplnttj ppwtt ppwttj ppllaa pplllla ppvvv ppvvv_ew ppvvvj ppaaj ppaaj2 pplla pplla_ew ppllaj ppllll ppllll2 ppllll2_onlyh ppllll_ew ppllllj ppllllj2 ppllllj2_onlyh ppllnnjj_ew ppllnnjj_vbs pplnajj ppvv ppvv2 ppvv_ew ppvvj ppvvj2 ppvvj_ew ppajj ppajj_ew ppllj ppllj_ew pplljj pplljj_ew pplnjj pplnjj_ew ppnnjj_ew ppvj ppvj_ew ppwjj ppwjj_ew ppzjj ppzjj_ew pphtt pphtt_ew pphttj bbhj heftpphj heftpphjj pph2 pphbb pphbbj pphj2 pphjj_vbf pphjj_vbf_ew           
     ELSE
       #ppaaj2 and ppllnnjj_ew commented out for now; causes error - process: ppllnnjj_ew ... ERROR: not available; 
-      BUILD_COMMAND ./openloops libinstall pptttt pptt pptt_ew ppttbb ppttj ppttj_ew pptw pptj pptjj ppjj ppjj_ew ppjjj ppjjj_ew ppatt ppattj pplltt ppllttj pplntt pplnttj ppwtt ppwttj ppllaa pplllla ppvvv ppvvv_ew ppvvvj ppaaj #[[ppaaj2]] pplla pplla_ew ppllaj ppllll ppllll2 ppllll2_onlyh ppllll_ew ppllllj ppllllj2 ppllllj2_onlyh #[[ppllnnjj_ew]] ppllnnjj_vbs pplnajj ppvv ppvv2 ppvv_ew ppvvj ppvvj2 ppvvj_ew ppajj ppajj_ew ppllj ppllj_ew pplljj pplljj_ew pplnjj pplnjj_ew ppnnjj_ew ppvj ppvj_ew ppwjj ppwjj_ew ppzjj ppzjj_ew pphtt pphtt_ew pphttj bbhj heftpphj heftpphjj pph2 pphbb pphbbj pphj2 pphjj_vbf pphjj_vbf_ew
+      BUILD_COMMAND ./openloops libinstall pptttt pptt pptt_ew ppttbb ppttj ppttj_ew pptw pptj pptjj ppjj ppjj_ew ppjjj ppjjj_ew ppatt ppattj pplltt ppllttj pplntt pplnttj ppwtt ppwttj ppllaa pplllla ppvvv ppvvv_ew ppvvvj ppaaj compile_extra=1 #[[ppaaj2]] pplla pplla_ew ppllaj ppllll ppllll2 ppllll2_onlyh ppllll_ew ppllllj ppllllj2 ppllllj2_onlyh #[[ppllnnjj_ew]] ppllnnjj_vbs pplnajj ppvv ppvv2 ppvv_ew ppvvj ppvvj2 ppvvj_ew ppajj ppajj_ew ppllj ppllj_ew pplljj pplljj_ew pplnjj pplnjj_ew ppnnjj_ew ppvj ppvj_ew ppwjj ppwjj_ew ppzjj ppzjj_ew pphtt pphtt_ew pphttj bbhj heftpphj heftpphjj pph2 pphbb pphbbj pphj2 pphjj_vbf pphjj_vbf_ew
     ENDIF
   ENDIF
         COMMAND ${CMAKE_COMMAND} -E remove_directory <SOURCE_DIR>/process_obj
-- 
GitLab


From c3f8288dcc263a8b363df3f2922948f0cb9c6700 Mon Sep 17 00:00:00 2001
From: Pere Mato <pere.mato@cern.ch>
Date: Thu, 9 Jan 2020 17:40:00 +0100
Subject: [PATCH 02/15] Cope with trailing spaces

---
 bin/lcgcmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/lcgcmake b/bin/lcgcmake
index 074f2ccd85..bfa5b97432 100755
--- a/bin/lcgcmake
+++ b/bin/lcgcmake
@@ -545,7 +545,7 @@ def get_default_version():
 
 def parse_info(text):
   data = {}
-  text = text.split(', ')
+  text = text.strip().split(', ')
   for key, value in [x.split(':') for x in text]:
     data.update({key.strip(): value.strip()})
   # deps
-- 
GitLab


From ed0d5445fdff94019bf023059b82598ee9272b75 Mon Sep 17 00:00:00 2001
From: Pere Mato <pere.mato@cern.ch>
Date: Wed, 15 Jan 2020 20:28:07 +0100
Subject: [PATCH 03/15] Added AIDA to arm builds

---
 cmake/toolchain/heptools-devARM.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmake/toolchain/heptools-devARM.cmake b/cmake/toolchain/heptools-devARM.cmake
index 401243f2fd..890635a188 100644
--- a/cmake/toolchain/heptools-devARM.cmake
+++ b/cmake/toolchain/heptools-devARM.cmake
@@ -41,4 +41,4 @@ LCG_external_package(starlight r300   ${MCGENPATH}/starlight)
 
 #---Define the top level packages for this stack-------------------
 LCG_top_packages(Geant4 ROOT CMake evtgen pythia8 lcgenv rangev3 cppgsl CppUnit QMtest nose gperftools six networkx ninja xenv
-                 RELAX eigen vectorclass lxml rivet fastjet pythia6 crmc starlight)
+                 RELAX eigen vectorclass lxml rivet fastjet pythia6 crmc starlight AIDA)
-- 
GitLab


From f00df8fd53b5e949e4405fcbff2caa112ac1a7e7 Mon Sep 17 00:00:00 2001
From: Ivan Razumov <ivan.razumov@cern.ch>
Date: Thu, 16 Jan 2020 13:59:27 +0000
Subject: [PATCH 04/15] [SPI-1517] + [SPI-1518] + bison relocation fix

---
 cmake/toolchain/heptools-dev-base.cmake | 10 ++--
 externals/CMakeLists.txt                |  4 +-
 projects/patches/DD4hep-01-11.patch     | 70 +++++++++++++++++++++++++
 projects/patches/Geant4-10.06.patch     | 11 ++++
 projects/patches/ROOT-6.18.04.patch     | 22 ++++++++
 5 files changed, 109 insertions(+), 8 deletions(-)
 create mode 100644 projects/patches/DD4hep-01-11.patch
 create mode 100644 projects/patches/Geant4-10.06.patch

diff --git a/cmake/toolchain/heptools-dev-base.cmake b/cmake/toolchain/heptools-dev-base.cmake
index 6d78e35307..dfc8bd1c1e 100644
--- a/cmake/toolchain/heptools-dev-base.cmake
+++ b/cmake/toolchain/heptools-dev-base.cmake
@@ -38,7 +38,6 @@ else()
   LCG_external_package(rpy2              2.8.6                                    )
   LCG_external_package(networkx          2.2                                      )
   LCG_external_package(matplotlib        2.2.4                                    )
-  LCG_AA_project(DD4hep                  01-10                                    )
   LCG_external_package(4suite            1.0.2p1                                  )
   LCG_external_package(astroid           1.6.6p1                     author=1.6.6 )
   LCG_external_package(contextlib2       0.5.5                                    )
@@ -83,13 +82,14 @@ if(NOT ${LCG_OS}${LCG_OSVERS} MATCHES ubuntu18|mac[0-9]+)
 endif()
 LCG_AA_project(RELAX root6)
 LCG_AA_project(HepMC 2.06.10)
-LCG_AA_project(Geant4 10.05.p01)
+LCG_AA_project(Geant4 10.06)
 LCG_AA_project(Garfield++  HEAD  GIT=https://gitlab.cern.ch/garfield/garfieldpp.git)
 if(${LCG_OS}${LCG_OSVERS} MATCHES centos7 AND ${LCG_COMP}${LCG_COMPVERS} MATCHES gcc8 
    OR ${LCG_OS} STREQUAL mac)
   LCG_AA_project(Gaudi  v32r2  GIT=https://gitlab.cern.ch/gaudi/Gaudi.git)
 endif()
 
+LCG_AA_project(DD4hep                  01-11                                    )
 
 # Externals
 LCG_external_package(lcgenv            1.3.8                                    )
@@ -112,13 +112,13 @@ LCG_external_package(backports.shutil_get_terminal_size 1.0.0
 LCG_external_package(backports.ssl_match_hostname       3.7.0.1                 )
 LCG_external_package(backports_abc     0.5                                      )
 LCG_external_package(benchmark         1.5.0                                    )
-LCG_external_package(bison             3.0.4                                    )
+LCG_external_package(bison             3.5                                      )
 #LCG_external_package(blas              3.8.0.netlib                             )
 LCG_external_package(blas              0.3.5.openblas                           )
 LCG_external_package(bleach            3.1.0                                    )
 LCG_external_package(brotli            1.0.7                                    )
 LCG_external_package(bzip2             1.0.6                                    )
-LCG_external_package(Boost             1.70.0                                   )
+LCG_external_package(Boost             1.72.0                                   )
 LCG_external_package(caniusepython3    7.1.0                                    )
 LCG_external_package(C50               2.07                                     )
 LCG_external_package(cachetools        3.1.1                                    )
@@ -517,7 +517,7 @@ LCG_external_package(Vc                1.4.1
 LCG_external_package(vcversioner       2.16.0.0                                 )
 LCG_external_package(vdt               0.4.3                                    )
 LCG_external_package(veccore           0.6.0                                    )
-LCG_external_package(VecGeom           v1.1.0                                   )
+LCG_external_package(VecGeom           v1.1.5                                   )
 LCG_external_package(vectorclass       1.30p1   author=1.30                     )
 LCG_external_package(wcwidth           0.1.7                                    )
 LCG_external_package(webencodings      0.5.1                                    )
diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt
index ec73dfc847..81b9fee989 100644
--- a/externals/CMakeLists.txt
+++ b/externals/CMakeLists.txt
@@ -1367,12 +1367,10 @@ LCGPackage_Add(
 )
 
 #---bison-------------------------------------------------------------------------------------------------
-# The relocationdir prefix and DESTDIR option are used to make bison relocatable to CVMFS
-# More info about this technique in section 12.7 here: https://www.gnu.org/software/bison/manual/bison.html
 LCGPackage_Add(
   bison
   URL ${GenURL}/bison-${bison_native_version}.tar.gz
-  CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=/relocationdir --enable-relocatable CC=${CMAKE_C_COMPILER}
+  CONFIGURE_COMMAND <SOURCE_DIR>/configure --enable-relocatable CC=${CMAKE_C_COMPILER} --prefix=""
   BUILD_COMMAND ${MAKE}
   INSTALL_COMMAND ${MAKE} install DESTDIR=<INSTALL_DIR>
   BUILD_IN_SOURCE 1
diff --git a/projects/patches/DD4hep-01-11.patch b/projects/patches/DD4hep-01-11.patch
new file mode 100644
index 0000000000..bdebe4b787
--- /dev/null
+++ b/projects/patches/DD4hep-01-11.patch
@@ -0,0 +1,70 @@
+--- GaudiPluginService/src/PluginService.cpp.orig	2019-08-26 17:23:22.000000000 +0200
++++ GaudiPluginService/src/PluginService.cpp	2019-08-26 17:45:56.000000000 +0200
+@@ -42,29 +42,22 @@
+ #define SINGLETON_LOCK
+ #endif
+ 
+-// string trimming functions taken from
+-// http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring
+ #include <algorithm>
+ // trim from start
+-static inline std::string &ltrim(std::string &s) {
+-        s.erase(s.begin(),
+-                std::find_if(s.begin(), s.end(),
+-                             std::not1(std::ptr_fun<int, int>(std::isspace))));
+-        return s;
++static inline std::string& ltrim(std::string& s) {
++  s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) {return !std::isspace(ch);}));
++  return s;
+ }
+ 
+ // trim from end
+-static inline std::string &rtrim(std::string &s) {
+-        s.erase(std::find_if(s.rbegin(), s.rend(),
+-                             std::not1(std::ptr_fun<int, int>(std::isspace)))
+-                                       .base(),
+-                s.end());
+-        return s;
++static inline std::string& rtrim(std::string& s) {
++  s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) {return !std::isspace(ch);}).base(), s.end());
++  return s;
+ }
++
+ // trim from both ends
+-static inline std::string &trim(std::string &s) {
+-        return ltrim(rtrim(s));
+-}
++static inline std::string& trim( std::string& s ) { return ltrim( rtrim( s ) ); }
++
+ 
+ namespace {
+   /// Helper function used to set values in FactoryInfo data members only
+--- DDCore/src/DetectorImp.cpp.orig	2019-08-26 17:58:05.000000000 +0200
++++ DDCore/src/DetectorImp.cpp	2019-08-26 18:01:07.000000000 +0200
+@@ -104,7 +104,6 @@
+            << "**************************************************** \n"
+            << endl ;
+ 
+-      set_unexpected(std::unexpected);
+       set_terminate(std::terminate);
+       // this provokes ROOT seg fault and stack trace (comment out to avoid it)
+       exit(1) ;
+@@ -153,7 +152,6 @@
+   : TNamed(), DetectorData(), DetectorLoad(this), m_buildType(BUILD_NONE)
+ {
+   SetTitle("DD4hep detector description object");
+-  set_unexpected( description_unexpected ) ;
+   set_terminate( description_unexpected ) ;
+   InstanceCount::increment(this);
+   //if ( gGeoManager ) delete gGeoManager;
+--- DDCore/include/DD4hep/Memory.h.orig	2019-08-26 17:50:49.000000000 +0200
++++ DDCore/include/DD4hep/Memory.h	2019-08-26 17:53:09.000000000 +0200
+@@ -30,7 +30,7 @@
+ #include <memory>
+ 
+ // Use std::auto_ptr<T> instead of std::unique_ptr<T>
+-#define DD4HEP_DD4HEP_PTR_AUTO
++//#define DD4HEP_DD4HEP_PTR_AUTO
+ 
+ /// Namespace for the AIDA detector description toolkit
+ namespace dd4hep  {
diff --git a/projects/patches/Geant4-10.06.patch b/projects/patches/Geant4-10.06.patch
new file mode 100644
index 0000000000..0eef7fabaf
--- /dev/null
+++ b/projects/patches/Geant4-10.06.patch
@@ -0,0 +1,11 @@
+--- cmake/Modules/G4VecGeomShim.cmake.orig	2020-01-14 18:38:43.000000000 +0100
++++ cmake/Modules/G4VecGeomShim.cmake	2020-01-14 18:32:36.000000000 +0100
+@@ -11,7 +11,7 @@
+ 
+     string(REGEX REPLACE "^\-D|;-D" ";" VECGEOM_COMPILE_DEFINITIONS "${VECGEOM_DEFINITIONS}")
+     set_target_properties(VecGeom::VecGeom PROPERTIES
+-      INTERFACE_COMPILE_DEFINITIONS ${VECGEOM_COMPILE_DEFINITIONS}
++      INTERFACE_COMPILE_DEFINITIONS "${VECGEOM_COMPILE_DEFINITIONS}"
+       INTERFACE_INCLUDE_DIRECTORIES "${VECGEOM_INCLUDE_DIRS}"
+       INTERFACE_LINK_LIBRARIES "${VECGEOM_LIBRARIES}"
+       IMPORTED_LOCATION "${VECGEOM_LIBRARY}")
diff --git a/projects/patches/ROOT-6.18.04.patch b/projects/patches/ROOT-6.18.04.patch
index 4b338447e1..05c3091193 100644
--- a/projects/patches/ROOT-6.18.04.patch
+++ b/projects/patches/ROOT-6.18.04.patch
@@ -43,3 +43,25 @@
      TMVA
  )
 +target_include_directories(RMVA BEFORE PRIVATE ${R_INCLUDE_DIR})
+From 41b424610d7c83b29869e841667617c2ef253f73 Mon Sep 17 00:00:00 2001
+From: Guilherme Amadio <amadio@cern.ch>
+Date: Thu, 3 Oct 2019 10:55:38 +0200
+Subject: [PATCH] Fix FindOracle.cmake to find version 19.x
+
+---
+ cmake/modules/FindOracle.cmake | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/cmake/modules/FindOracle.cmake b/cmake/modules/FindOracle.cmake
+index f09e7491954..e3ea87da5cd 100644
+--- cmake/modules/FindOracle.cmake
++++ cmake/modules/FindOracle.cmake
+@@ -55,7 +55,7 @@ FIND_LIBRARY(
+ )
+ FIND_LIBRARY(
+     ORACLE_LIBRARY_LNNZ
+-    NAMES libnnz10 nnz10 libnnz11 nnz11 libnnz12 nnz12 nnz18 ociw32
++    NAMES libnnz10 nnz10 libnnz11 nnz11 libnnz12 nnz12 nnz18 nnz19 ociw32
+     PATHS ${ORACLE_LIB_LOCATION}
+ )
+ 
\ No newline at end of file
-- 
GitLab


From 717d18c7e6e533b09c07e9ce6b9fc57608bfa2fe Mon Sep 17 00:00:00 2001
From: Ivan Razumov <ivan.razumov@cern.ch>
Date: Fri, 17 Jan 2020 09:51:38 +0100
Subject: [PATCH 05/15] Patch probably not needed

---
 projects/patches/DD4hep-01-11.patch | 70 -----------------------------
 1 file changed, 70 deletions(-)
 delete mode 100644 projects/patches/DD4hep-01-11.patch

diff --git a/projects/patches/DD4hep-01-11.patch b/projects/patches/DD4hep-01-11.patch
deleted file mode 100644
index bdebe4b787..0000000000
--- a/projects/patches/DD4hep-01-11.patch
+++ /dev/null
@@ -1,70 +0,0 @@
---- GaudiPluginService/src/PluginService.cpp.orig	2019-08-26 17:23:22.000000000 +0200
-+++ GaudiPluginService/src/PluginService.cpp	2019-08-26 17:45:56.000000000 +0200
-@@ -42,29 +42,22 @@
- #define SINGLETON_LOCK
- #endif
- 
--// string trimming functions taken from
--// http://stackoverflow.com/questions/216823/whats-the-best-way-to-trim-stdstring
- #include <algorithm>
- // trim from start
--static inline std::string &ltrim(std::string &s) {
--        s.erase(s.begin(),
--                std::find_if(s.begin(), s.end(),
--                             std::not1(std::ptr_fun<int, int>(std::isspace))));
--        return s;
-+static inline std::string& ltrim(std::string& s) {
-+  s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) {return !std::isspace(ch);}));
-+  return s;
- }
- 
- // trim from end
--static inline std::string &rtrim(std::string &s) {
--        s.erase(std::find_if(s.rbegin(), s.rend(),
--                             std::not1(std::ptr_fun<int, int>(std::isspace)))
--                                       .base(),
--                s.end());
--        return s;
-+static inline std::string& rtrim(std::string& s) {
-+  s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) {return !std::isspace(ch);}).base(), s.end());
-+  return s;
- }
-+
- // trim from both ends
--static inline std::string &trim(std::string &s) {
--        return ltrim(rtrim(s));
--}
-+static inline std::string& trim( std::string& s ) { return ltrim( rtrim( s ) ); }
-+
- 
- namespace {
-   /// Helper function used to set values in FactoryInfo data members only
---- DDCore/src/DetectorImp.cpp.orig	2019-08-26 17:58:05.000000000 +0200
-+++ DDCore/src/DetectorImp.cpp	2019-08-26 18:01:07.000000000 +0200
-@@ -104,7 +104,6 @@
-            << "**************************************************** \n"
-            << endl ;
- 
--      set_unexpected(std::unexpected);
-       set_terminate(std::terminate);
-       // this provokes ROOT seg fault and stack trace (comment out to avoid it)
-       exit(1) ;
-@@ -153,7 +152,6 @@
-   : TNamed(), DetectorData(), DetectorLoad(this), m_buildType(BUILD_NONE)
- {
-   SetTitle("DD4hep detector description object");
--  set_unexpected( description_unexpected ) ;
-   set_terminate( description_unexpected ) ;
-   InstanceCount::increment(this);
-   //if ( gGeoManager ) delete gGeoManager;
---- DDCore/include/DD4hep/Memory.h.orig	2019-08-26 17:50:49.000000000 +0200
-+++ DDCore/include/DD4hep/Memory.h	2019-08-26 17:53:09.000000000 +0200
-@@ -30,7 +30,7 @@
- #include <memory>
- 
- // Use std::auto_ptr<T> instead of std::unique_ptr<T>
--#define DD4HEP_DD4HEP_PTR_AUTO
-+//#define DD4HEP_DD4HEP_PTR_AUTO
- 
- /// Namespace for the AIDA detector description toolkit
- namespace dd4hep  {
-- 
GitLab


From 485c1443dcae91b9e293fee38698800b74ca0d10 Mon Sep 17 00:00:00 2001
From: Richard Bachmann <richard.bachmann@cern.ch>
Date: Fri, 17 Jan 2020 11:59:27 +0100
Subject: [PATCH 06/15] Bison downgrade due to gcc8 thrift build fail

---
 cmake/toolchain/heptools-dev-base.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmake/toolchain/heptools-dev-base.cmake b/cmake/toolchain/heptools-dev-base.cmake
index dfc8bd1c1e..b31fa0721b 100644
--- a/cmake/toolchain/heptools-dev-base.cmake
+++ b/cmake/toolchain/heptools-dev-base.cmake
@@ -112,7 +112,7 @@ LCG_external_package(backports.shutil_get_terminal_size 1.0.0
 LCG_external_package(backports.ssl_match_hostname       3.7.0.1                 )
 LCG_external_package(backports_abc     0.5                                      )
 LCG_external_package(benchmark         1.5.0                                    )
-LCG_external_package(bison             3.5                                      )
+LCG_external_package(bison             3.4.1                                    )
 #LCG_external_package(blas              3.8.0.netlib                             )
 LCG_external_package(blas              0.3.5.openblas                           )
 LCG_external_package(bleach            3.1.0                                    )
-- 
GitLab


From b67832622d35b8513917d148398402753c91491f Mon Sep 17 00:00:00 2001
From: Pere Mato Vila <pere.mato@cern.ch>
Date: Mon, 20 Jan 2020 15:41:02 +0000
Subject: [PATCH 07/15] Installation of cuda as a compiler

---
 cmake/toolchain/heptools-contrib.cmake     |  1 +
 cmake/toolchain/heptools-dev3cuda.cmake    |  2 +-
 cmake/toolchain/heptools-dev3cuda101.cmake |  2 +-
 contrib/CMakeLists.txt                     | 23 +++++++++++++++++
 contrib/templates/cuda-setup.csh.in        | 24 +++++++++++++++++
 contrib/templates/cuda-setup.sh.in         | 24 +++++++++++++++++
 externals/CMakeLists.txt                   | 30 ----------------------
 projects/CMakeLists.txt                    |  2 +-
 8 files changed, 75 insertions(+), 33 deletions(-)
 create mode 100644 contrib/templates/cuda-setup.csh.in
 create mode 100644 contrib/templates/cuda-setup.sh.in

diff --git a/cmake/toolchain/heptools-contrib.cmake b/cmake/toolchain/heptools-contrib.cmake
index cdc05feb6d..c7a0edec06 100644
--- a/cmake/toolchain/heptools-contrib.cmake
+++ b/cmake/toolchain/heptools-contrib.cmake
@@ -5,3 +5,4 @@ LCG_external_package(gcc              7.3.0
 LCG_external_package(gcc              8.1.0                                     )
 LCG_external_package(clang            6.0.0           gcc=7.3.0                 )
 LCG_external_package(clang            7.0.0           gcc=8.1.0                 )
+LCG_external_package(cuda             10.2            full=10.2.89_440.33.01    )
diff --git a/cmake/toolchain/heptools-dev3cuda.cmake b/cmake/toolchain/heptools-dev3cuda.cmake
index 32142b566b..a39cc3cdc6 100644
--- a/cmake/toolchain/heptools-dev3cuda.cmake
+++ b/cmake/toolchain/heptools-dev3cuda.cmake
@@ -17,7 +17,7 @@ endif()
 LCG_external_package(ROOT         HEAD   GIT=http://root.cern.ch/git/root.git        )
 LCG_external_package(hepmc3       HEAD   GIT=https://gitlab.cern.ch/hepmc/HepMC3.git )
 
-LCG_external_package(cuda         10.0                          )
+LCG_external_package(cuda         10.0    full=10.0.130_410.48  )
 LCG_external_package(cudnn        7.6.1.34                      )
 
 LCG_external_package(appdirs      1.4.3                         )
diff --git a/cmake/toolchain/heptools-dev3cuda101.cmake b/cmake/toolchain/heptools-dev3cuda101.cmake
index d4081e950d..a515c4d96c 100644
--- a/cmake/toolchain/heptools-dev3cuda101.cmake
+++ b/cmake/toolchain/heptools-dev3cuda101.cmake
@@ -19,5 +19,5 @@ LCG_external_package(hepmc3       HEAD   GIT=https://gitlab.cern.ch/hepmc/HepMC3
 LCG_external_package(tensorflow   1.14.0                        )
 LCG_external_package(tensorflow_estimator  1.14.0               )
 LCG_external_package(tensorboard  1.14.0    protobuf=3.6.1      )
-LCG_external_package(cuda         10.1                          )
+LCG_external_package(cuda         10.1      full=10.1.168_418.67)
 LCG_external_package(cudnn        7.6.1.34                      )
diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt
index 6a12f111a9..a9f8eb84ce 100644
--- a/contrib/CMakeLists.txt
+++ b/contrib/CMakeLists.txt
@@ -82,3 +82,26 @@ LCGPackage_Add(
 )
 
 
+#---cuda------------------------------------------------------------------------
+LCGPackage_Add(
+  cuda
+  DOWNLOAD_COMMAND ${CMAKE_COMMAND} -Durl=${GenURL}/cuda_<cuda_<VERSION>_full>_linux
+                                    -Dsource_dir=<SOURCE_DIR>
+                                    -P ${CMAKE_SOURCE_DIR}/cmake/scripts/DownloadURL.cmake
+  UPDATE_COMMAND chmod +x <SOURCE_DIR>/cuda_<cuda_<VERSION>_full>_linux
+  CONFIGURE_COMMAND <VOID>
+  BUILD_COMMAND <VOID>
+  INSTALL_COMMAND <SOURCE_DIR>/cuda_<cuda_<VERSION>_full>_linux 
+                  --silent         # disable interactive prompts
+                  --override       # override compiler version checks
+                  --toolkit        # install CUDA Toolkit
+                  --toolkitpath=<INSTALL_DIR> 
+                  IF ${cuda_native_version} VERSION_GREATER 10.0 THEN --defaultroot=<INSTALL_DIR> ENDIF
+                  COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/cuda-setup.sh <INSTALL_DIR>/setup.sh 
+                  COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/cuda-setup.csh <INSTALL_DIR>/setup.csh 
+  BUILD_IN_SOURCE 1
+)
+# The setup[sh,csh] files uses cuda_home as base installation, which is defined after LCGPackage_Add(cuda)
+configure_file(templates/cuda-setup.sh.in cuda-setup.sh @ONLY)
+configure_file(templates/cuda-setup.csh.in cuda-setup.csh @ONLY)
+
diff --git a/contrib/templates/cuda-setup.csh.in b/contrib/templates/cuda-setup.csh.in
new file mode 100644
index 0000000000..11b0a7d80c
--- /dev/null
+++ b/contrib/templates/cuda-setup.csh.in
@@ -0,0 +1,24 @@
+# Simple bash script for setting up the CUDA installation for the
+# runtime environment.
+
+# The directory of this script:
+set BASE=@cuda_home@
+
+# Set up the directories:
+if ($?PATH) then
+    setenv PATH ${BASE}/bin:${PATH}
+else
+    setenv PATH ${BASE}/bin
+endif
+if ($?LD_LIBRARY_PATH) then
+    setenv LD_LIBRARY_PATH ${BASE}/lib64:${LD_LIBRARY_PATH}
+else
+    setenv LD_LIBRARY_PATH ${BASE}/lib64
+endif
+echo "Configured CUDA from: ${BASE}"
+
+# Set up which CUDA compiler to use:
+setenv CUDACXX `which nvcc`
+
+# Clean up:
+unset BASE
diff --git a/contrib/templates/cuda-setup.sh.in b/contrib/templates/cuda-setup.sh.in
new file mode 100644
index 0000000000..e71b0a43e6
--- /dev/null
+++ b/contrib/templates/cuda-setup.sh.in
@@ -0,0 +1,24 @@
+# Simple bash script for setting up the CUDA installation for the
+# runtime environment.
+
+# The directory of this script:
+BASE=@cuda_home@
+
+# Set up the directories:
+if [ -z "${PATH}" ]; then
+  export PATH=${BASE}/bin
+else
+  export PATH=${BASE}/bin:$PATH
+fi
+if [ -z "${LD_LIBRARY_PATH}" ]; then
+  export LD_LIBRARY_PATH=${BASE}/lib64
+else
+  export LD_LIBRARY_PATH=${BASE}/lib64:$LD_LIBRARY_PATH
+fi
+echo "Configured CUDA from: ${BASE}"
+
+# Set up which CUDA compiler to use:
+export CUDACXX=`which nvcc`
+
+# Clean up:
+unset BASE
diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt
index 81b9fee989..ba8a310401 100644
--- a/externals/CMakeLists.txt
+++ b/externals/CMakeLists.txt
@@ -2419,36 +2419,6 @@ LCGPackage_Add(
              -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
 )
 
-#---cuda------------------------------------------------------------------------
-if(cuda_native_version VERSION_EQUAL 10.1)
-  set(cuda_full_version 10.1.168_418.67)
-elseif(cuda_native_version VERSION_EQUAL 10.0)
-  set(cuda_full_version 10.0.130_410.48)
-elseif(cuda_native_version VERSION_EQUAL 9.2)
-  set(cuda_full_version 9.2.88_396.26)
-elseif(cuda_native_version VERSION_EQUAL 9.0)
-  set(cuda_full_version 9.0.176_384.81)
-else()
-  set(cuda_full_version  ${cuda_native_version})
-endif()
-
-LCGPackage_Add(
-  cuda
-  DOWNLOAD_COMMAND ${CMAKE_COMMAND} -Durl=${GenURL}/cuda_${cuda_full_version}_linux
-                                    -Dsource_dir=<SOURCE_DIR>
-                                    -P ${CMAKE_SOURCE_DIR}/cmake/scripts/DownloadURL.cmake
-  UPDATE_COMMAND chmod +x <SOURCE_DIR>/cuda_${cuda_full_version}_linux
-  CONFIGURE_COMMAND <VOID>
-  BUILD_COMMAND <VOID>
-  INSTALL_COMMAND <SOURCE_DIR>/cuda_${cuda_full_version}_linux 
-                  --silent         # disable interactive prompts
-                  --override       # override compiler version checks
-                  --toolkit        # install CUDA Toolkit
-                  --toolkitpath=<INSTALL_DIR> 
-                  IF ${cuda_native_version} VERSION_GREATER 10.0 THEN --defaultroot=<INSTALL_DIR> ENDIF 
-  BUILD_IN_SOURCE 1
-)
-
 #---cudnn-----------------------------------------------------------------------
 LCGPackage_Add(
   cudnn
diff --git a/projects/CMakeLists.txt b/projects/CMakeLists.txt
index 8fd9fabba1..3d368d88ec 100644
--- a/projects/CMakeLists.txt
+++ b/projects/CMakeLists.txt
@@ -554,7 +554,7 @@ LCGPackage_add(
 )
 
 #---hepmc3----------------------------------------------------------------------------
-string(REPLACE "." "" Python_config_version_twodigit_nodot ${Python_config_version_twodigit})
+string(REPLACE "." "" Python_config_version_twodigit_nodot "${Python_config_version_twodigit}")
 LCGPackage_Add(
     hepmc3
     URL ${GenURL}/HepMC3-${hepmc3_native_version}.tar.gz
-- 
GitLab


From e8e412585afac29f71977822d506b1e264f04ba1 Mon Sep 17 00:00:00 2001
From: Pere Mato <pere.mato@cern.ch>
Date: Tue, 21 Jan 2020 12:18:58 +0100
Subject: [PATCH 08/15] Downgrade some MC generators for LHCb checks

---
 cmake/toolchain/heptools-devARM.cmake | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cmake/toolchain/heptools-devARM.cmake b/cmake/toolchain/heptools-devARM.cmake
index 890635a188..519dbdf098 100644
--- a/cmake/toolchain/heptools-devARM.cmake
+++ b/cmake/toolchain/heptools-devARM.cmake
@@ -38,6 +38,9 @@ LCG_external_package(rangev3   0.5.0       )
 LCG_external_package(photos++  3.56   ${MCGENPATH}/photos++ )
 LCG_external_package(crmc      1.5.6  ${MCGENPATH}/crmc     )
 LCG_external_package(starlight r300   ${MCGENPATH}/starlight)
+LCG_external_package(pythia8   240    ${MCGENPATH}/pythia8  )
+LCG_external_package(tauola++  1.1.6b.lhcb  ${MCGENPATH}/tauola++ author=1.1.6b )
+LCG_external_package(evtgen    1.7.0        ${MCGENPATH}/evtgen   tag=R01-07-00 pythia8=240 tauola++=1.1.6b.lhcb)
 
 #---Define the top level packages for this stack-------------------
 LCG_top_packages(Geant4 ROOT CMake evtgen pythia8 lcgenv rangev3 cppgsl CppUnit QMtest nose gperftools six networkx ninja xenv
-- 
GitLab


From 5403f193ab0a69795d44a48e41f7616b323c65db Mon Sep 17 00:00:00 2001
From: SFTnight Jenkins <project-lcg-spi-ci-notifications@cern.ch>
Date: Tue, 21 Jan 2020 22:35:07 +0100
Subject: [PATCH 09/15] [Jenkins] Automated update of packages.json and
 releases.json

---
 documentation/releases.json | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/documentation/releases.json b/documentation/releases.json
index 90a2a95105..221f493670 100644
--- a/documentation/releases.json
+++ b/documentation/releases.json
@@ -7,10 +7,6 @@
         "extra_notes": null, 
         "version": "devBE"
     }, 
-    {
-        "extra_notes": null, 
-        "version": "dev4cuda"
-    }, 
     {
         "extra_notes": null, 
         "version": "dev4"
-- 
GitLab


From 635eb61df47029aaa196514d18de4e2c2638b992 Mon Sep 17 00:00:00 2001
From: Ivan Razumov <ivan.razumov@cern.ch>
Date: Wed, 22 Jan 2020 12:12:36 +0000
Subject: [PATCH 10/15] [SPI-1524] Provide gperftools built with clang

---
 cmake/toolchain/heptools-dev-base.cmake | 4 +---
 externals/CMakeLists.txt                | 8 +++++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/cmake/toolchain/heptools-dev-base.cmake b/cmake/toolchain/heptools-dev-base.cmake
index b31fa0721b..6db9d3e2fe 100644
--- a/cmake/toolchain/heptools-dev-base.cmake
+++ b/cmake/toolchain/heptools-dev-base.cmake
@@ -222,9 +222,7 @@ if(${LCG_OS} STREQUAL slc OR ${LCG_OS} STREQUAL centos OR ${LCG_OS} STREQUAL cc)
 endif()
 LCG_external_package(google_auth       1.6.3                                    )
 LCG_external_package(gperf             3.1                                      )
-if(NOT LCG_COMP STREQUAL "clang")
-  LCG_external_package(gperftools      2.7                                      )
-endif()
+LCG_external_package(gperftools      2.7                                        )
 LCG_external_package(graphviz          2.40.1                                   )
 LCG_external_package(grpcio            1.21.1                                   )
 LCG_external_package(GSL               2.5                                      )
diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt
index ba8a310401..fb912c0528 100644
--- a/externals/CMakeLists.txt
+++ b/externals/CMakeLists.txt
@@ -1537,10 +1537,12 @@ LCGPackage_Add(
 #---gperftools--------------------------------------------------------------------------------------------
 if(NOT APPLE) # There are problems building on MacOSX
   if(LCG_TARGET MATCHES "x86_64")
-    set(gperftools_config_options "--enable-frame-pointers;--disable-deprecated-pprof")
+    set(gperftools_config_options "--enable-frame-pointers;--enable-libunwind")
   endif()
   if(LCG_TARGET MATCHES "ubuntu")
-    set(gperftools_config_options ${gperftools_config_options} "CXXFLAGS=-fpermissive")
+    set(gperftools_config_options ${gperftools_config_options} "CXXFLAGS=-fpermissive -I${libunwind_home}/include -L${libunwind_home}/lib;CFLAGS=-fpermissive -I${libunwind_home}/include -L${libunwind_home}/lib")
+  else()
+    set(gperftools_config_options ${gperftools_config_options} "CXXFLAGS=-I${libunwind_home}/include -L${libunwind_home}/lib;CFLAGS=-I${libunwind_home}/include -L${libunwind_home}/lib")
   endif()
   LCGPackage_Add(
     gperftools
@@ -1551,7 +1553,7 @@ if(NOT APPLE) # There are problems building on MacOSX
     ENDIF
     CONFIGURE_COMMAND ./configure --prefix <INSTALL_DIR> ${gperftools_config_options}
     BUILD_IN_SOURCE 1
-    REVISION 2
+    DEPENDS libunwind
   )
 else()
   add_custom_target(gperftools ALL COMMENT "Dummy gperftools target")
-- 
GitLab


From f078999390883fe937079b543adacb2fd249a171 Mon Sep 17 00:00:00 2001
From: Pere Mato <pere.mato@cern.ch>
Date: Wed, 22 Jan 2020 13:49:13 +0100
Subject: [PATCH 11/15] Fix problem with IS

---
 cmake/modules/lcgsoft-macros.cmake | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cmake/modules/lcgsoft-macros.cmake b/cmake/modules/lcgsoft-macros.cmake
index 4ca08a529d..13d6fec42f 100644
--- a/cmake/modules/lcgsoft-macros.cmake
+++ b/cmake/modules/lcgsoft-macros.cmake
@@ -153,8 +153,8 @@ macro(LCGPackage_Add name)
 
     #---Instruction set handling----------------------------------------------------------------------
     set(instructionset OFF)
+    set(LCG_saved_system ${LCG_system})
     if(NOT ARG_BUILD_WITH_INSTRUCTION_SET)
-      set(LCG_saved_system ${LCG_system})
       set(LCG_system ${LCG_naked_system})
     elseif(LCG_INSTRUCTIONSET)
       set(instructionset ON)
@@ -292,7 +292,7 @@ macro(LCGPackage_Add name)
                       COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_BINARY_DIR}/${tarname}
                       COMMAND ${LOCKFILE} -l 120 ${CMAKE_BINARY_DIR}/summary.lock
                       COMMAND ${CMAKE_COMMAND} -DNAME=${name} 
-                                               -DSUMFILE=${CMAKE_BINARY_DIR}/LCG_${LCG_VERSION}_${LCG_system}.txt
+                                               -DSUMFILE=${CMAKE_BINARY_DIR}/LCG_${LCG_VERSION}_${LCG_saved_system}.txt
                                                -DINSTALLDIR=${CMAKE_INSTALL_PREFIX}/${install_path}
                                                -P ${CMAKE_SOURCE_DIR}/cmake/scripts/UpdateSummaryFile.cmake
                       COMMAND ${LOCKFILE} --unlock ${CMAKE_BINARY_DIR}/summary.lock
-- 
GitLab


From a1b6a2f0e219a07747a37ef5a0ba6dd9d103e0f2 Mon Sep 17 00:00:00 2001
From: Ivan Razumov <ivan.razumov@cern.ch>
Date: Wed, 22 Jan 2020 16:03:53 +0000
Subject: [PATCH 12/15] [SPI-1525] Update COOL and CORAL versions in dev4

---
 cmake/toolchain/heptools-dev4.cmake | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/cmake/toolchain/heptools-dev4.cmake b/cmake/toolchain/heptools-dev4.cmake
index b61097f0e3..cb6137380c 100644
--- a/cmake/toolchain/heptools-dev4.cmake
+++ b/cmake/toolchain/heptools-dev4.cmake
@@ -4,14 +4,14 @@ include(heptools-dev-base)
 
 #---Additional External packages------(Generators)-----------------
 include(heptools-dev-generators)
- 
+
 LCG_external_package(ROOT    v6-20-00-patches  GIT=http://root.cern.ch/git/root.git )
 LCG_external_package(hepmc3  3.1.1  )
 
 # Latest tagged version of COOL, CORAL instead of master (if required)
 if(NOT ${LCG_OS}${LCG_OSVERS} MATCHES ubuntu18|mac[0-9]+)
   LCG_remove_package(CORAL)
-  LCG_AA_project(CORAL 3_2_2)
+  LCG_AA_project(CORAL 3_2_3)
   LCG_remove_package(COOL)
-  LCG_AA_project(COOL 3_2_2)
+  LCG_AA_project(COOL 3_2_3)
 endif()
-- 
GitLab


From bd787567bf28008676ebe533d4c4c66471c07fda Mon Sep 17 00:00:00 2001
From: SFTnight Jenkins <project-lcg-spi-ci-notifications@cern.ch>
Date: Thu, 23 Jan 2020 22:36:14 +0100
Subject: [PATCH 13/15] [Jenkins] Automated update of packages.json and
 releases.json

---
 documentation/releases.json | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/documentation/releases.json b/documentation/releases.json
index 221f493670..5713856f72 100644
--- a/documentation/releases.json
+++ b/documentation/releases.json
@@ -11,10 +11,6 @@
         "extra_notes": null, 
         "version": "dev4"
     }, 
-    {
-        "extra_notes": null, 
-        "version": "dev3python3"
-    }, 
     {
         "extra_notes": null, 
         "version": "dev3cuda"
-- 
GitLab


From 1ae192b414f4c4e85c44640943b6dc72c4d9e9d6 Mon Sep 17 00:00:00 2001
From: Gerardo Ganis <Gerardo.Ganis@cern.ch>
Date: Fri, 24 Jan 2020 12:52:25 +0100
Subject: [PATCH 14/15] Try again openloops 2.0.0 for dev3python3

---
 cmake/toolchain/heptools-dev-generators.cmake | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/cmake/toolchain/heptools-dev-generators.cmake b/cmake/toolchain/heptools-dev-generators.cmake
index cf418ed657..606a322df3 100644
--- a/cmake/toolchain/heptools-dev-generators.cmake
+++ b/cmake/toolchain/heptools-dev-generators.cmake
@@ -16,8 +16,10 @@ endif(LCG_PYTHON_VERSION EQUAL 2)
 if(LCG_PYTHON_VERSION EQUAL 3)
   #LCG_external_package(yoda              1.7.0-py3      ${MCGENPATH}/yoda  )
   #LCG_external_package(rivet             2.6.0-py3      ${MCGENPATH}/rivet yoda=1.7.0-py3    )
-  LCG_external_package(openloops         1.3.1          ${MCGENPATH}/openloops)
-  LCG_external_package(herwig3           7.2.0          ${MCGENPATH}/herwig++  thepeg=2.2.0 madgraph=2.6.7 openloops=1.3.1 lhapdf=6.2.3)
+#  LCG_external_package(openloops         1.3.1          ${MCGENPATH}/openloops)
+#  LCG_external_package(herwig3           7.2.0          ${MCGENPATH}/herwig++  thepeg=2.2.0 madgraph=2.6.7 openloops=1.3.1 lhapdf=6.2.3)
+  LCG_external_package(openloops         2.0.0          ${MCGENPATH}/openloops)
+  LCG_external_package(herwig3           7.2.0          ${MCGENPATH}/herwig++  thepeg=2.2.0 madgraph=2.6.7 openloops=2.0.0 lhapdf=6.2.3)
 endif(LCG_PYTHON_VERSION EQUAL 3)
 
 LCG_external_package(yoda              1.7.7          ${MCGENPATH}/yoda  )
-- 
GitLab


From 3be46cbacb5b1664e34b15fec92d0cb6246940bd Mon Sep 17 00:00:00 2001
From: Gerardo Ganis <Gerardo.Ganis@cern.ch>
Date: Fri, 24 Jan 2020 12:58:41 +0100
Subject: [PATCH 15/15] Revert "Try again openloops 2.0.0 for dev3python3"

Openloops 2.0.0 does not support python3
This reverts commit 1ae192b414f4c4e85c44640943b6dc72c4d9e9d6.
---
 cmake/toolchain/heptools-dev-generators.cmake | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/cmake/toolchain/heptools-dev-generators.cmake b/cmake/toolchain/heptools-dev-generators.cmake
index 606a322df3..cf418ed657 100644
--- a/cmake/toolchain/heptools-dev-generators.cmake
+++ b/cmake/toolchain/heptools-dev-generators.cmake
@@ -16,10 +16,8 @@ endif(LCG_PYTHON_VERSION EQUAL 2)
 if(LCG_PYTHON_VERSION EQUAL 3)
   #LCG_external_package(yoda              1.7.0-py3      ${MCGENPATH}/yoda  )
   #LCG_external_package(rivet             2.6.0-py3      ${MCGENPATH}/rivet yoda=1.7.0-py3    )
-#  LCG_external_package(openloops         1.3.1          ${MCGENPATH}/openloops)
-#  LCG_external_package(herwig3           7.2.0          ${MCGENPATH}/herwig++  thepeg=2.2.0 madgraph=2.6.7 openloops=1.3.1 lhapdf=6.2.3)
-  LCG_external_package(openloops         2.0.0          ${MCGENPATH}/openloops)
-  LCG_external_package(herwig3           7.2.0          ${MCGENPATH}/herwig++  thepeg=2.2.0 madgraph=2.6.7 openloops=2.0.0 lhapdf=6.2.3)
+  LCG_external_package(openloops         1.3.1          ${MCGENPATH}/openloops)
+  LCG_external_package(herwig3           7.2.0          ${MCGENPATH}/herwig++  thepeg=2.2.0 madgraph=2.6.7 openloops=1.3.1 lhapdf=6.2.3)
 endif(LCG_PYTHON_VERSION EQUAL 3)
 
 LCG_external_package(yoda              1.7.7          ${MCGENPATH}/yoda  )
-- 
GitLab