From 624c116573ded8c3a2a01beb16b03cee71ad57bd Mon Sep 17 00:00:00 2001
From: Riccardo Maria Bianchi <riccardo.maria.bianchi@cern.ch>
Date: Thu, 20 Oct 2022 12:01:49 +0200
Subject: [PATCH 01/13] Conform project's name to package's name

---
 FullSimLight/Plugins/Examples/UserActionPlugins/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/FullSimLight/Plugins/Examples/UserActionPlugins/CMakeLists.txt b/FullSimLight/Plugins/Examples/UserActionPlugins/CMakeLists.txt
index a3ebdda28..73e5e7287 100644
--- a/FullSimLight/Plugins/Examples/UserActionPlugins/CMakeLists.txt
+++ b/FullSimLight/Plugins/Examples/UserActionPlugins/CMakeLists.txt
@@ -2,7 +2,7 @@
 
 # Set up the project.
 cmake_minimum_required( VERSION 3.1 )
-project( "FSLUserActionsPlugins" )
+project( "UserActionsPlugins" )
 
 #Set up the project. Check if we build it with GeoModel or individually
 if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
-- 
GitLab


From b52cf0c134047b25557c3d3c2793334708e90c82 Mon Sep 17 00:00:00 2001
From: Riccardo Maria Bianchi <riccardo.maria.bianchi@cern.ch>
Date: Thu, 20 Oct 2022 12:02:54 +0200
Subject: [PATCH 02/13] Print info about build type and C++ standard

---
 GeoModelG4/CMakeLists.txt            | 4 ++++
 GeoModelTools/CMakeLists.txt         | 4 ++++
 GeoModelVisualization/CMakeLists.txt | 4 ++++
 3 files changed, 12 insertions(+)

diff --git a/GeoModelG4/CMakeLists.txt b/GeoModelG4/CMakeLists.txt
index 0d1c6e7b0..128f647f3 100644
--- a/GeoModelG4/CMakeLists.txt
+++ b/GeoModelG4/CMakeLists.txt
@@ -18,6 +18,8 @@ if( (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) OR GEOMODEL_BUILD_GEOMODELG4_
     include( cmake_colors_defs )
     # Warn the users about what they are doing
     message(STATUS "${BoldGreen}Building ${PROJECT_NAME} individually, as a top-level project.${ColourReset}")
+    # Set a default build type
+    include( BuildType )
     # Set default build and C++ options
     include( configure_cpp_options )
     set( CMAKE_FIND_FRAMEWORK "LAST" CACHE STRING
@@ -31,6 +33,8 @@ if( (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) OR GEOMODEL_BUILD_GEOMODELG4_
     endif()
     # Set a flag to steer the  of the subpackages
     set( ${PROJECT_NAME}_INDIVIDUAL_BUILD ON )
+    # Print Build Info on screen
+    include( PrintBuildInfo )
 else()
     # I am called from other projects with add_subdirectory().
     message( STATUS "Building ${PROJECT_NAME} as part of the root GeoModel project.")
diff --git a/GeoModelTools/CMakeLists.txt b/GeoModelTools/CMakeLists.txt
index 3c29cb7ad..738f05fcc 100644
--- a/GeoModelTools/CMakeLists.txt
+++ b/GeoModelTools/CMakeLists.txt
@@ -19,6 +19,8 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
     include( cmake_colors_defs )
     # Warn the users about what they are doing
     message(STATUS "${BoldGreen}Building ${PROJECT_NAME} individually, as a top-level project.${ColourReset}")
+    # Set a default build type
+    include( BuildType )
     # Set default build and C++ options
     include( configure_cpp_options )
     set( CMAKE_FIND_FRAMEWORK "LAST" CACHE STRING
@@ -36,6 +38,8 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
     find_package( GeoModelIO REQUIRED ${GeoModel_VERSION} ) 
     # Set a flag to steer the build of the subpackages
     #set( VISUALIZATION_INDIVIDUAL_BUILD ON )
+    # Print Build Info on screen
+    include( PrintBuildInfo )
 else()
     # I am called from other project with add_subdirectory().
     message( STATUS "Building ${PROJECT_NAME} as part of the root GeoModel project.")
diff --git a/GeoModelVisualization/CMakeLists.txt b/GeoModelVisualization/CMakeLists.txt
index 6ba88d176..054444a47 100644
--- a/GeoModelVisualization/CMakeLists.txt
+++ b/GeoModelVisualization/CMakeLists.txt
@@ -24,6 +24,8 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
     include( cmake_colors_defs )
     # Warn the users about what they are doing
     message(STATUS "${BoldGreen}Building ${PROJECT_NAME} individually, as a top-level project.${ColourReset}")
+    # Set a default build type
+    include( BuildType )
     # Set default build and C++ options
     include( configure_cpp_options )
     set( CMAKE_FIND_FRAMEWORK "LAST" CACHE STRING
@@ -33,6 +35,8 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
     find_package( GeoModelIO REQUIRED ${GeoModel_VERSION} )
     # Set a flag to steer the build of the subpackages
     set( VISUALIZATION_INDIVIDUAL_BUILD ON )
+    # Print Build Info on screen
+    include( PrintBuildInfo )
 else()
     # I am called from other project with add_subdirectory().
     message( STATUS "Building ${PROJECT_NAME} as part of the root GeoModel project.")
-- 
GitLab


From 33ed88b3e68be36d1cce3d400c7e25b5632b5b74 Mon Sep 17 00:00:00 2001
From: Riccardo Maria Bianchi <riccardo.maria.bianchi@cern.ch>
Date: Thu, 20 Oct 2022 12:03:37 +0200
Subject: [PATCH 03/13] Make dependency on HepMC3 optional

---
 FullSimLight/CMakeLists.txt                 | 21 ++++++++++++++++--
 FullSimLight/src/FSLActionInitialization.cc | 24 +++++++++++++++------
 2 files changed, 36 insertions(+), 9 deletions(-)

diff --git a/FullSimLight/CMakeLists.txt b/FullSimLight/CMakeLists.txt
index 8971f4cf2..8d30e772f 100644
--- a/FullSimLight/CMakeLists.txt
+++ b/FullSimLight/CMakeLists.txt
@@ -7,7 +7,6 @@ cmake_minimum_required( VERSION 3.14 )
 project( "FullSimLight" )
 
 #Set up the project. Check if we build it with GeoModel or individually
-
 if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
     # I am top-level project.
     # Make the root module directory visible to CMake.
@@ -20,6 +19,8 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
     include( cmake_colors_defs )
     # Warn the users about what they are doing
     message(STATUS "${BoldGreen}Building ${PROJECT_NAME} individually, as a top-level project.${ColourReset}")
+    # Set a default build type
+    include( BuildType )
     # Set default build and C++ options
     include( configure_cpp_options )
     set( CMAKE_FIND_FRAMEWORK "LAST" CACHE STRING
@@ -38,6 +39,8 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
     find_package( GeoModelG4 REQUIRED ${GeoModel_VERSION} )
     # Set a flag to steer the  of the subpackages
     set( ${PROJECT_NAME}_INDIVIDUAL_BUILD ON )
+    # Print Build Info on screen
+    include( PrintBuildInfo )
 else()
     # I am called from other project with add_subdirectory().
     message( STATUS "Building ${PROJECT_NAME} as part of the root GeoModel project.")
@@ -55,7 +58,7 @@ message( STATUS "Found Geant4: ${Geant4_INCLUDE_DIR}")
 #----------------------------------------------------------------------------
 
 find_package(Pythia QUIET) # optional
-find_package(HepMC3 REQUIRED)
+find_package(HepMC3 QUIET) # optional
 #find_package(ROOT QUIET) #optional
 #option(HEPMC3_ROOTIO_USE "Enable the use of HEPMC3 with ROOT" OFF)
 
@@ -97,6 +100,16 @@ include_directories(${PROJECT_SOURCE_DIR}/include)
 #
 file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
 file(GLOB headers ${PROJECT_SOURCE_DIR}/inc/*.hh)
+#message("sources: ${sources}") # debug msg
+
+
+if( NOT HepMC3_FOUND)
+    file(GLOB hepmc3src ${PROJECT_SOURCE_DIR}/src/HepMC3*.cc)
+    message(NOTICE "NOTE ==> HepMC3 was not found, we don't compile FullSimLight tools using it.")
+    #message("Removing those HepMC3-related sources: ${hepmc3src}") # debug msg
+    list(REMOVE_ITEM sources ${hepmc3src})
+    #message("new sources without HepMC3 support: ${sources}") # debug msg
+endif()
 
 #----------------------------------------------------------------------------
 # Add the executable, and link it to the Geant4 libraries
@@ -121,6 +134,10 @@ if(Pythia_FOUND)
   target_link_libraries(fullSimLight PRIVATE Pythia::Pythia)
 endif()
 
+if(HepMC3_FOUND)
+    target_compile_definitions(fullSimLight PRIVATE USE_HEPMC3)
+endif()
+
 #if(HEPMC3_ROOTIO_USE)
 #  message( STATUS "HEPMC3 Root Dependency Switched on")
 #  target_link_libraries(gmclash PUBLIC  ${HEPMC3_ROOTIO_LIB} ${ROOT_LIBRARIES})
diff --git a/FullSimLight/src/FSLActionInitialization.cc b/FullSimLight/src/FSLActionInitialization.cc
index 6f8e76ffb..c06970ba9 100644
--- a/FullSimLight/src/FSLActionInitialization.cc
+++ b/FullSimLight/src/FSLActionInitialization.cc
@@ -1,11 +1,13 @@
 #include "FSLActionInitialization.hh"
 #include "GeoModelKernel/GeoPluginLoader.h"
-#include "FSLPrimaryGeneratorAction.hh"
-#include "HepMC3PrimaryGeneratorAction.hh"
 #include "FSLRunAction.hh"
 #include "FSLEventAction.hh"
 #include "FSLSteppingAction.hh"
 #include "FSLTrackingAction.hh"
+#include "FSLPrimaryGeneratorAction.hh"
+#if USE_HEPMC3
+#include "HepMC3PrimaryGeneratorAction.hh"
+#endif
 #include "PythiaPrimaryGeneratorAction.hh"
 #include "FullSimLight/FSLUserActionPlugin.h"
 
@@ -66,7 +68,8 @@ void FSLActionInitialization::BuildForMaster() const {
 void FSLActionInitialization::Build() const {
 
 #if !USE_PYTHIA
-  
+ 
+#if USE_HEPMC3
   if(generator == "HepMC3 File")
   {
       std::cout << "Reading in events from file: " << hepmc3_file_path << std::endl;
@@ -74,8 +77,10 @@ void FSLActionInitialization::Build() const {
       
   }
     
-  else if(generator == "Generator Plugin")
-  {
+  else if(generator == "Generator Plugin") {
+#else
+  if(generator == "Generator Plugin") {
+#endif
       std::cout << "Loading in event generator from plugin" << std::endl;
       GeoPluginLoader<FSLUserActionPlugin> generator_loader;
       const FSLUserActionPlugin * gen_plugin = generator_loader.load(generator_plugin);
@@ -98,6 +103,9 @@ void FSLActionInitialization::Build() const {
     G4int pythiaSeed = fIsPerformance ? -1 : 0;
     SetUserAction(new PythiaPrimaryGeneratorAction(pythiaSeed));
   } else {
+
+
+#if USE_HEPMC3
       if(generator == "HepMC3 File")
       {
           std::cout << "Reading in events from file: " << hepmc3_file_path << std::endl;
@@ -105,8 +113,10 @@ void FSLActionInitialization::Build() const {
           
       }
         
-      else if(generator == "Generator Plugin")
-      {
+  else if(generator == "Generator Plugin") {
+#else
+  if(generator == "Generator Plugin") {
+#endif
           std::cout << "Loading in event generator from plugin" << std::endl;
           GeoPluginLoader<FSLUserActionPlugin> generator_loader;
           const FSLUserActionPlugin * gen_plugin = generator_loader.load(generator_plugin);
-- 
GitLab


From 70cdbae393bbb7eb96483bcd3fa2f5615894877a Mon Sep 17 00:00:00 2001
From: Riccardo Maria Bianchi <riccardo.maria.bianchi@cern.ch>
Date: Thu, 20 Oct 2022 13:08:17 +0200
Subject: [PATCH 04/13] Improve messages to user

---
 FullSimLight/CMakeLists.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/FullSimLight/CMakeLists.txt b/FullSimLight/CMakeLists.txt
index 8d30e772f..423b0e4b2 100644
--- a/FullSimLight/CMakeLists.txt
+++ b/FullSimLight/CMakeLists.txt
@@ -105,10 +105,12 @@ file(GLOB headers ${PROJECT_SOURCE_DIR}/inc/*.hh)
 
 if( NOT HepMC3_FOUND)
     file(GLOB hepmc3src ${PROJECT_SOURCE_DIR}/src/HepMC3*.cc)
-    message(NOTICE "NOTE ==> HepMC3 was not found, we don't compile FullSimLight tools using it.")
+    message(STATUS "NOTE ==> HepMC3 was not found, we don't compile FullSimLight tools using it.")
     #message("Removing those HepMC3-related sources: ${hepmc3src}") # debug msg
     list(REMOVE_ITEM sources ${hepmc3src})
     #message("new sources without HepMC3 support: ${sources}") # debug msg
+else()
+    message(STATUS "Found HepMC3, so support for it will be compiled. (${HepMC3_INCLUDE_DIRS})")
 endif()
 
 #----------------------------------------------------------------------------
-- 
GitLab


From a21fe9443cb26b6c0f1d580eee2f1519a75178d7 Mon Sep 17 00:00:00 2001
From: Riccardo Maria Bianchi <riccardo.maria.bianchi@cern.ch>
Date: Thu, 20 Oct 2022 13:08:44 +0200
Subject: [PATCH 05/13] Fix include directories for standalone build

---
 .../UserActionPlugins/DummyUserActionPlugin/CMakeLists.txt  | 2 +-
 FullSimLight/Plugins/HitsPlugin/CMakeLists.txt              | 2 +-
 FullSimLight/Plugins/TracksPlugin/CMakeLists.txt            | 6 +-----
 3 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/FullSimLight/Plugins/Examples/UserActionPlugins/DummyUserActionPlugin/CMakeLists.txt b/FullSimLight/Plugins/Examples/UserActionPlugins/DummyUserActionPlugin/CMakeLists.txt
index 2383e191c..d8caaceee 100644
--- a/FullSimLight/Plugins/Examples/UserActionPlugins/DummyUserActionPlugin/CMakeLists.txt
+++ b/FullSimLight/Plugins/Examples/UserActionPlugins/DummyUserActionPlugin/CMakeLists.txt
@@ -61,7 +61,7 @@ include(${Geant4_USE_FILE})
 # Use the GNU install directory names.
 include( GNUInstallDirs )
 
-target_include_directories( DummyUserActionPlugin PUBLIC  ${CMAKE_SOURCE_DIR}/FullSimLight ${HDF5_CXX_INCLUDE_DIRS})
+target_include_directories( DummyUserActionPlugin PUBLIC  ${CMAKE_SOURCE_DIR} ${HDF5_CXX_INCLUDE_DIRS})
 
 target_link_libraries ( DummyUserActionPlugin PUBLIC ${CMAKE_DL_LIBS} ${Geant4_LIBRARIES} ${HDF5_CXX_LIBRARIES})
 
diff --git a/FullSimLight/Plugins/HitsPlugin/CMakeLists.txt b/FullSimLight/Plugins/HitsPlugin/CMakeLists.txt
index 5f6dc0f00..6055cee3a 100644
--- a/FullSimLight/Plugins/HitsPlugin/CMakeLists.txt
+++ b/FullSimLight/Plugins/HitsPlugin/CMakeLists.txt
@@ -63,7 +63,7 @@ include(${Geant4_USE_FILE})
 # Use the GNU install directory names.
 include( GNUInstallDirs )
 
-target_include_directories( GenerateHitsPlugin PUBLIC  ${CMAKE_SOURCE_DIR}/FullSimLight ${HDF5_CXX_INCLUDE_DIRS})
+target_include_directories( GenerateHitsPlugin PUBLIC  ${CMAKE_SOURCE_DIR} ${HDF5_CXX_INCLUDE_DIRS})
 
 target_link_libraries ( GenerateHitsPlugin PUBLIC ${CMAKE_DL_LIBS} ${Geant4_LIBRARIES} ${HDF5_CXX_LIBRARIES})
 
diff --git a/FullSimLight/Plugins/TracksPlugin/CMakeLists.txt b/FullSimLight/Plugins/TracksPlugin/CMakeLists.txt
index 9fc0e614b..5fa8bed52 100644
--- a/FullSimLight/Plugins/TracksPlugin/CMakeLists.txt
+++ b/FullSimLight/Plugins/TracksPlugin/CMakeLists.txt
@@ -62,18 +62,14 @@ include(${Geant4_USE_FILE})
 # Use the GNU install directory names.
 include( GNUInstallDirs )
 
-target_include_directories( GenerateTracksPlugin PUBLIC  ${CMAKE_SOURCE_DIR}/FullSimLight ${HDF5_CXX_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include)
+target_include_directories( GenerateTracksPlugin PUBLIC  ${CMAKE_SOURCE_DIR} ${HDF5_CXX_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include)
 
 target_link_libraries ( GenerateTracksPlugin PUBLIC ${CMAKE_DL_LIBS} ${Geant4_LIBRARIES} ${HDF5_CXX_LIBRARIES})
 
-
-
 set_target_properties( GenerateTracksPlugin PROPERTIES
 		       VERSION ${PROJECT_VERSION}
 		       SOVERSION ${PROJECT_VERSION_MAJOR} )
 
-
-
 install( TARGETS GenerateTracksPlugin
 	 LIBRARY DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/FullSimLight/UserActionPlugins
 	 COMPONENT Runtime
-- 
GitLab


From c94f75f8955bff443551cd08e4a3c3b153274b3a Mon Sep 17 00:00:00 2001
From: Riccardo Maria Bianchi <riccardo.maria.bianchi@cern.ch>
Date: Thu, 20 Oct 2022 17:34:33 +0200
Subject: [PATCH 06/13] Fix the CMake configuration for standalone builds

---
 .../FSLExamplePrimaryGeneratorPlugin/CMakeLists.txt             | 2 +-
 .../UniformMagneticFieldPlugin/CMakeLists.txt                   | 2 +-
 .../PhysicsListPlugins/FSLTestPhysListPlugins/CMakeLists.txt    | 2 +-
 .../Examples/SensitiveDetectorPlugins/SDPlugin/CMakeLists.txt   | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/FullSimLight/Plugins/Examples/EventGeneratorPlugins/FSLExamplePrimaryGeneratorPlugin/CMakeLists.txt b/FullSimLight/Plugins/Examples/EventGeneratorPlugins/FSLExamplePrimaryGeneratorPlugin/CMakeLists.txt
index 124362dff..9e27b152e 100644
--- a/FullSimLight/Plugins/Examples/EventGeneratorPlugins/FSLExamplePrimaryGeneratorPlugin/CMakeLists.txt
+++ b/FullSimLight/Plugins/Examples/EventGeneratorPlugins/FSLExamplePrimaryGeneratorPlugin/CMakeLists.txt
@@ -60,7 +60,7 @@ include(${Geant4_USE_FILE})
 # Use the GNU install directory names.
 include( GNUInstallDirs )
 
-target_include_directories( ExamplePrimaryGeneratorPlugin PUBLIC  ${CMAKE_SOURCE_DIR}/FullSimLight)
+target_include_directories( ExamplePrimaryGeneratorPlugin PUBLIC  ${CMAKE_SOURCE_DIR} )
 
 target_link_libraries ( ExamplePrimaryGeneratorPlugin PUBLIC ${CMAKE_DL_LIBS} ${Geant4_LIBRARIES})
 
diff --git a/FullSimLight/Plugins/Examples/MagneticFieldPlugins/UniformMagneticFieldPlugin/CMakeLists.txt b/FullSimLight/Plugins/Examples/MagneticFieldPlugins/UniformMagneticFieldPlugin/CMakeLists.txt
index 778b68dbc..cb1a058ee 100644
--- a/FullSimLight/Plugins/Examples/MagneticFieldPlugins/UniformMagneticFieldPlugin/CMakeLists.txt
+++ b/FullSimLight/Plugins/Examples/MagneticFieldPlugins/UniformMagneticFieldPlugin/CMakeLists.txt
@@ -62,7 +62,7 @@ include( GNUInstallDirs )
 add_definitions (-DMAPPATH="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}" )
 
 
-target_include_directories( UniformMagneticFieldPlugin PUBLIC ${CMAKE_SOURCE_DIR}/FullSimLight )
+target_include_directories( UniformMagneticFieldPlugin PUBLIC ${CMAKE_SOURCE_DIR} )
 
 
 target_link_libraries ( UniformMagneticFieldPlugin PUBLIC ${CMAKE_DL_LIBS} ${Geant4_LIBRARIES} Eigen3::Eigen)
diff --git a/FullSimLight/Plugins/Examples/PhysicsListPlugins/FSLTestPhysListPlugins/CMakeLists.txt b/FullSimLight/Plugins/Examples/PhysicsListPlugins/FSLTestPhysListPlugins/CMakeLists.txt
index 21b03aab5..2ac446575 100644
--- a/FullSimLight/Plugins/Examples/PhysicsListPlugins/FSLTestPhysListPlugins/CMakeLists.txt
+++ b/FullSimLight/Plugins/Examples/PhysicsListPlugins/FSLTestPhysListPlugins/CMakeLists.txt
@@ -58,7 +58,7 @@ include(${Geant4_USE_FILE})
 # Use the GNU install directory names.
 include( GNUInstallDirs )
 
-target_include_directories( TestPhysicsListPlugin PUBLIC  ${CMAKE_SOURCE_DIR}/FullSimLight)
+target_include_directories( TestPhysicsListPlugin PUBLIC  ${CMAKE_SOURCE_DIR} )
 
 target_link_libraries ( TestPhysicsListPlugin PUBLIC ${CMAKE_DL_LIBS} ${Geant4_LIBRARIES})
 
diff --git a/FullSimLight/Plugins/Examples/SensitiveDetectorPlugins/SDPlugin/CMakeLists.txt b/FullSimLight/Plugins/Examples/SensitiveDetectorPlugins/SDPlugin/CMakeLists.txt
index 2f26af51b..12b869c5d 100644
--- a/FullSimLight/Plugins/Examples/SensitiveDetectorPlugins/SDPlugin/CMakeLists.txt
+++ b/FullSimLight/Plugins/Examples/SensitiveDetectorPlugins/SDPlugin/CMakeLists.txt
@@ -59,7 +59,7 @@ include(${Geant4_USE_FILE})
 # Use the GNU install directory names.
 include( GNUInstallDirs )
 
-target_include_directories( SDPlugin PUBLIC  ${CMAKE_SOURCE_DIR}/FullSimLight)
+target_include_directories( SDPlugin PUBLIC  ${CMAKE_SOURCE_DIR} )
 
 target_link_libraries ( SDPlugin PUBLIC ${CMAKE_DL_LIBS} ${Geant4_LIBRARIES})
 
-- 
GitLab


From 88e0ccf07bc21b4e589947d7de6c10ef452383a0 Mon Sep 17 00:00:00 2001
From: Riccardo Maria Bianchi <riccardo.maria.bianchi@cern.ch>
Date: Thu, 20 Oct 2022 17:35:42 +0200
Subject: [PATCH 07/13] Add message to inform the user about the G4
 SolidExtension path

---
 GeoModelG4/GeoModel2G4/CMakeLists.txt | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/GeoModelG4/GeoModel2G4/CMakeLists.txt b/GeoModelG4/GeoModel2G4/CMakeLists.txt
index d993096a8..df227e6de 100644
--- a/GeoModelG4/GeoModel2G4/CMakeLists.txt
+++ b/GeoModelG4/GeoModel2G4/CMakeLists.txt
@@ -30,7 +30,11 @@ file( GLOB HEADERS GeoModel2G4/*.h )
 
 # include Geant4 headers
 include(${Geant4_USE_FILE})
-add_definitions (-DG4EXTENSION_SOLID_DIR=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} )
+
+# set the path where the G4 extensions are found (e.g., the LArCustomSolid ATLAS extension)
+set(PATHEXTENSIONS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} )
+add_definitions (-DG4EXTENSION_SOLID_DIR=${PATHEXTENSIONS})
+message("==> NOTE: G4 solid extensions will be searched in: ${PATHEXTENSIONS}. If you need custom extensions check if this is the right path. If not, set the right path by setting the environmental variable 'G4EXTENSION_SOLID_DIR' before running the application that uses the GeoModel2G4 library (e.g., 'export G4EXTENSION_SOLID_DIR=/usr/local/Cellar/geomodel-extension-atlaslar/5.4.0/lib') " )
 
 # Set target and properties
 add_library( GeoModel2G4 SHARED ${HEADERS} ${SOURCES} )
-- 
GitLab


From 5a85d99feea12f37b66e2c28153b96e4de3d7958 Mon Sep 17 00:00:00 2001
From: Riccardo Maria Bianchi <riccardo.maria.bianchi@cern.ch>
Date: Fri, 21 Oct 2022 13:35:41 +0200
Subject: [PATCH 08/13] let users disable HepMC3 support if not needed

---
 FSL/.gitignore             |  1 +
 FSL/CMakeLists.txt         | 13 ++++++++++++-
 FSL/src/fsl_mainwindow.cpp | 24 ++++++++++++++++++------
 FSL/src/fsl_mainwindow.ui  |  8 ++++----
 4 files changed, 35 insertions(+), 11 deletions(-)
 create mode 100644 FSL/.gitignore

diff --git a/FSL/.gitignore b/FSL/.gitignore
new file mode 100644
index 000000000..e43b0f988
--- /dev/null
+++ b/FSL/.gitignore
@@ -0,0 +1 @@
+.DS_Store
diff --git a/FSL/CMakeLists.txt b/FSL/CMakeLists.txt
index f6033368f..d4eb6be19 100644
--- a/FSL/CMakeLists.txt
+++ b/FSL/CMakeLists.txt
@@ -33,9 +33,20 @@ else()
 endif()
 
 
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
 
 
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
+# Support for the HepMC3 exchange format
+# This is ON by default, but it can be disabled by the user if not used/needed,
+# or if HepMC3 is not installed
+option(GEOMODEL_USE_HEPMC3 "Enable the build of all GeoModel sub-packages" ON)
+if(GEOMODEL_USE_HEPMC3)
+    find_package(HepMC3 REQUIRED)
+endif()
+if(HepMC3_FOUND)
+    target_compile_definitions(fullSimLight PRIVATE USE_HEPMC3)
+endif()
+
 
 # Find the dependencies of the project.
 find_package( Qt5 COMPONENTS Core Gui Widgets Sql PrintSupport OpenGL REQUIRED )
diff --git a/FSL/src/fsl_mainwindow.cpp b/FSL/src/fsl_mainwindow.cpp
index ee37c1955..32d64ace6 100644
--- a/FSL/src/fsl_mainwindow.cpp
+++ b/FSL/src/fsl_mainwindow.cpp
@@ -191,6 +191,13 @@ FSLMainWindow::FSLMainWindow(QWidget *parent)
     connect(&fullSimLight_process,SIGNAL(started()),this,SLOT(fsml_process_started()));
     connect(&fullSimLight_process,SIGNAL(finished(int , QProcess::ExitStatus )),this,SLOT(fsml_process_finished()));
 
+    // Disable options if the underlying packages/tools are not installed/found
+    // (e.g., HepMC3, Pythia, ...)
+    // TODO: add check for Pythia, external plugins, and anything is not embedded in FullSimLight by default
+#ifndef USE_HEPMC3
+    ui->cB_gen_options->setItemData(2, false, Qt::UserRole -1);
+    ui->groupBox_hepmc3->setEnabled(false);
+#endif
 
 }
 
@@ -934,11 +941,12 @@ void FSLMainWindow::configure_generator()
     {
         ui->sB_NOT->setValue(1);
         ui->sB_NOT->setEnabled(false);
-        
+       
+#ifdef USE_HEPMC3
         ui->pB_hepmc3_browse_files->setEnabled(true);
         ui->cB_hepmc3_type_of_eve->setEnabled(true);
         ui->lE_HEPMC3->setEnabled(true);
-
+#endif
         
         ui->cB_particle->setEnabled(false);
         ui->lE_px->setEnabled(false);
@@ -1152,6 +1160,7 @@ void FSLMainWindow::run_configuration()
     QStringList args;   //Contains arguments of the command
     
     //Needs to be fixed. Should not be a hard coded path.
+    //TODO: add check if exe is found. If not, throw an error message
     Command = "fullSimLight";
     
     args<<"-c"<< QString::fromUtf8(tmpConf.c_str());
@@ -1173,6 +1182,7 @@ void FSLMainWindow::run_gmex()
     QStringList args;   //Contains arguments of the command
     
     //Needs to be fixed. Should not be a hard coded path.
+    //TODO: add check if exe is found. If not, throw an error message
     Command = "gmex";
      
     args << QString::fromUtf8(geom_file_address.c_str());
@@ -1194,6 +1204,7 @@ void FSLMainWindow::run_gmclash()
     QStringList args;   //Contains arguments of the command
     
     //Needs to be fixed. Should not be a hard coded path.
+    //TODO: add check if exe is found. If not, throw an error message
     Command = "gmclash";
      
     args << QString("-g") <<  QString::fromUtf8(geom_file_address.c_str());
@@ -1404,18 +1415,18 @@ void FSLMainWindow::load_configuration()
     {
         ui->sB_NOT->setValue(1);
         ui->sB_NOT->setEnabled(false);
-        
+#ifdef USE_HEPMC3    
         ui->cB_gen_options->setCurrentIndex(2);
         ui->pB_hepmc3_browse_files->setEnabled(true);
         ui->cB_hepmc3_type_of_eve->setEnabled(true);
         ui->lE_HEPMC3->setEnabled(true);
-
         
         hepmc3_type_of_file = j_load["HepMC3 type of file"];
         hepmc3_input_file = j_load["HepMC3 file"];
         
         ui->cB_hepmc3_type_of_eve->setCurrentText(QString::fromUtf8(hepmc3_type_of_file.c_str()));
         ui->lE_HEPMC3->setText(QString::fromUtf8(hepmc3_input_file.c_str()));
+#endif
 
         
         ui->lE_px->clear();
@@ -1879,7 +1890,8 @@ void FSLMainWindow::load_configuration_CL(std::string config_file_path)
     {
         ui->sB_NOT->setValue(1);
         ui->sB_NOT->setEnabled(false);
-        
+
+#ifdef USE_HEPMC3
         ui->cB_gen_options->setCurrentIndex(2);
         ui->pB_hepmc3_browse_files->setEnabled(true);
         ui->cB_hepmc3_type_of_eve->setEnabled(true);
@@ -1891,7 +1903,7 @@ void FSLMainWindow::load_configuration_CL(std::string config_file_path)
         
         ui->cB_hepmc3_type_of_eve->setCurrentText(QString::fromUtf8(hepmc3_type_of_file.c_str()));
         ui->lE_HEPMC3->setText(QString::fromUtf8(hepmc3_input_file.c_str()));
-
+#endif
         
         ui->lE_px->clear();
         ui->lE_py->clear();
diff --git a/FSL/src/fsl_mainwindow.ui b/FSL/src/fsl_mainwindow.ui
index cc26d0a65..e86dc0316 100644
--- a/FSL/src/fsl_mainwindow.ui
+++ b/FSL/src/fsl_mainwindow.ui
@@ -29,7 +29,7 @@
        </font>
       </property>
       <property name="currentIndex">
-       <number>0</number>
+       <number>1</number>
       </property>
       <widget class="QWidget" name="main">
        <attribute name="title">
@@ -595,7 +595,7 @@
          </spacer>
         </item>
         <item row="2" column="4">
-         <widget class="QGroupBox" name="groupBox_5">
+         <widget class="QGroupBox" name="groupBox_pythia">
           <property name="font">
            <font>
             <pointsize>15</pointsize>
@@ -667,7 +667,7 @@
          </widget>
         </item>
         <item row="3" column="4">
-         <widget class="QGroupBox" name="groupBox_10">
+         <widget class="QGroupBox" name="groupBox_hepmc3">
           <property name="font">
            <font>
             <pointsize>15</pointsize>
@@ -742,7 +742,7 @@
          </spacer>
         </item>
         <item row="4" column="4">
-         <widget class="QGroupBox" name="groupBox_12">
+         <widget class="QGroupBox" name="groupBox_plugin">
           <property name="font">
            <font>
             <pointsize>15</pointsize>
-- 
GitLab


From 95793199c6f54c0de39d3c8cec047e5e10d1d34a Mon Sep 17 00:00:00 2001
From: Riccardo Maria Bianchi <riccardo.maria.bianchi@cern.ch>
Date: Fri, 21 Oct 2022 16:33:38 +0200
Subject: [PATCH 09/13] Fix include of FullSimLight headers both for single and
 all-in-one build

---
 .../FSLExamplePrimaryGeneratorPlugin/CMakeLists.txt    |  9 ++++++++-
 .../UniformMagneticFieldPlugin/CMakeLists.txt          |  9 ++++++++-
 .../FSLTestPhysListPlugins/CMakeLists.txt              |  9 ++++++++-
 .../SensitiveDetectorPlugins/SDPlugin/CMakeLists.txt   |  9 ++++++++-
 .../DummyUserActionPlugin/CMakeLists.txt               |  9 ++++++++-
 FullSimLight/Plugins/HitsPlugin/CMakeLists.txt         | 10 +++++++++-
 FullSimLight/Plugins/TracksPlugin/CMakeLists.txt       |  9 ++++++++-
 7 files changed, 57 insertions(+), 7 deletions(-)

diff --git a/FullSimLight/Plugins/Examples/EventGeneratorPlugins/FSLExamplePrimaryGeneratorPlugin/CMakeLists.txt b/FullSimLight/Plugins/Examples/EventGeneratorPlugins/FSLExamplePrimaryGeneratorPlugin/CMakeLists.txt
index 9e27b152e..d7eb29db2 100644
--- a/FullSimLight/Plugins/Examples/EventGeneratorPlugins/FSLExamplePrimaryGeneratorPlugin/CMakeLists.txt
+++ b/FullSimLight/Plugins/Examples/EventGeneratorPlugins/FSLExamplePrimaryGeneratorPlugin/CMakeLists.txt
@@ -60,7 +60,14 @@ include(${Geant4_USE_FILE})
 # Use the GNU install directory names.
 include( GNUInstallDirs )
 
-target_include_directories( ExamplePrimaryGeneratorPlugin PUBLIC  ${CMAKE_SOURCE_DIR} )
+# Add the FullSimLight headers dir.
+# Path is different if built as a single top project, 
+# or as an all-in-one build together with all other GeoModel subpackages 
+if( FullSimLight_INDIVIDUAL_BUILD )
+    target_include_directories( ExamplePrimaryGeneratorPlugin PUBLIC  ${CMAKE_SOURCE_DIR} )
+else() # all-in-one--build
+    target_include_directories( ExamplePrimaryGeneratorPlugin PUBLIC  ${CMAKE_SOURCE_DIR}/FullSimLight )
+endif()
 
 target_link_libraries ( ExamplePrimaryGeneratorPlugin PUBLIC ${CMAKE_DL_LIBS} ${Geant4_LIBRARIES})
 
diff --git a/FullSimLight/Plugins/Examples/MagneticFieldPlugins/UniformMagneticFieldPlugin/CMakeLists.txt b/FullSimLight/Plugins/Examples/MagneticFieldPlugins/UniformMagneticFieldPlugin/CMakeLists.txt
index cb1a058ee..dcd0dfeb7 100644
--- a/FullSimLight/Plugins/Examples/MagneticFieldPlugins/UniformMagneticFieldPlugin/CMakeLists.txt
+++ b/FullSimLight/Plugins/Examples/MagneticFieldPlugins/UniformMagneticFieldPlugin/CMakeLists.txt
@@ -62,7 +62,14 @@ include( GNUInstallDirs )
 add_definitions (-DMAPPATH="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}" )
 
 
-target_include_directories( UniformMagneticFieldPlugin PUBLIC ${CMAKE_SOURCE_DIR} )
+# Add the FullSimLight headers dir.
+# Path is different if built as a single top project, 
+# or as an all-in-one build together with all other GeoModel subpackages 
+if( FullSimLight_INDIVIDUAL_BUILD )
+    target_include_directories( UniformMagneticFieldPlugin PUBLIC ${CMAKE_SOURCE_DIR} )
+else() # all-in-one--build
+    target_include_directories( UniformMagneticFieldPlugin PUBLIC ${CMAKE_SOURCE_DIR}/FullSimLight )
+endif()
 
 
 target_link_libraries ( UniformMagneticFieldPlugin PUBLIC ${CMAKE_DL_LIBS} ${Geant4_LIBRARIES} Eigen3::Eigen)
diff --git a/FullSimLight/Plugins/Examples/PhysicsListPlugins/FSLTestPhysListPlugins/CMakeLists.txt b/FullSimLight/Plugins/Examples/PhysicsListPlugins/FSLTestPhysListPlugins/CMakeLists.txt
index 2ac446575..c37cd349c 100644
--- a/FullSimLight/Plugins/Examples/PhysicsListPlugins/FSLTestPhysListPlugins/CMakeLists.txt
+++ b/FullSimLight/Plugins/Examples/PhysicsListPlugins/FSLTestPhysListPlugins/CMakeLists.txt
@@ -58,7 +58,14 @@ include(${Geant4_USE_FILE})
 # Use the GNU install directory names.
 include( GNUInstallDirs )
 
-target_include_directories( TestPhysicsListPlugin PUBLIC  ${CMAKE_SOURCE_DIR} )
+# Add the FullSimLight headers dir.
+# Path is different if built as a single top project, 
+# or as an all-in-one build together with all other GeoModel subpackages 
+if( FullSimLight_INDIVIDUAL_BUILD )
+    target_include_directories( TestPhysicsListPlugin PUBLIC  ${CMAKE_SOURCE_DIR} )
+else() # all-in-one--build
+    target_include_directories( TestPhysicsListPlugin PUBLIC  ${CMAKE_SOURCE_DIR}/FullSimLight )
+endif()
 
 target_link_libraries ( TestPhysicsListPlugin PUBLIC ${CMAKE_DL_LIBS} ${Geant4_LIBRARIES})
 
diff --git a/FullSimLight/Plugins/Examples/SensitiveDetectorPlugins/SDPlugin/CMakeLists.txt b/FullSimLight/Plugins/Examples/SensitiveDetectorPlugins/SDPlugin/CMakeLists.txt
index 12b869c5d..819b2d8fe 100644
--- a/FullSimLight/Plugins/Examples/SensitiveDetectorPlugins/SDPlugin/CMakeLists.txt
+++ b/FullSimLight/Plugins/Examples/SensitiveDetectorPlugins/SDPlugin/CMakeLists.txt
@@ -59,7 +59,14 @@ include(${Geant4_USE_FILE})
 # Use the GNU install directory names.
 include( GNUInstallDirs )
 
-target_include_directories( SDPlugin PUBLIC  ${CMAKE_SOURCE_DIR} )
+# Add the FullSimLight headers dir.
+# Path is different if built as a single top project, 
+# or as an all-in-one build together with all other GeoModel subpackages 
+if( FullSimLight_INDIVIDUAL_BUILD )
+    target_include_directories( SDPlugin PUBLIC  ${CMAKE_SOURCE_DIR} )
+else() # all-in-one--build
+    target_include_directories( SDPlugin PUBLIC  ${CMAKE_SOURCE_DIR}/FullSimLight )
+endif()
 
 target_link_libraries ( SDPlugin PUBLIC ${CMAKE_DL_LIBS} ${Geant4_LIBRARIES})
 
diff --git a/FullSimLight/Plugins/Examples/UserActionPlugins/DummyUserActionPlugin/CMakeLists.txt b/FullSimLight/Plugins/Examples/UserActionPlugins/DummyUserActionPlugin/CMakeLists.txt
index d8caaceee..2cf5e92a8 100644
--- a/FullSimLight/Plugins/Examples/UserActionPlugins/DummyUserActionPlugin/CMakeLists.txt
+++ b/FullSimLight/Plugins/Examples/UserActionPlugins/DummyUserActionPlugin/CMakeLists.txt
@@ -61,7 +61,14 @@ include(${Geant4_USE_FILE})
 # Use the GNU install directory names.
 include( GNUInstallDirs )
 
-target_include_directories( DummyUserActionPlugin PUBLIC  ${CMAKE_SOURCE_DIR} ${HDF5_CXX_INCLUDE_DIRS})
+# Add the FullSimLight headers dir.
+# Path is different if built as a single top project, 
+# or as an all-in-one build together with all other GeoModel subpackages 
+if( FullSimLight_INDIVIDUAL_BUILD )
+    target_include_directories( DummyUserActionPlugin PUBLIC  ${CMAKE_SOURCE_DIR} ${HDF5_CXX_INCLUDE_DIRS})
+else() # all-in-one--build
+    target_include_directories( DummyUserActionPlugin PUBLIC  ${CMAKE_SOURCE_DIR}/FullSimLight ${HDF5_CXX_INCLUDE_DIRS})
+endif()
 
 target_link_libraries ( DummyUserActionPlugin PUBLIC ${CMAKE_DL_LIBS} ${Geant4_LIBRARIES} ${HDF5_CXX_LIBRARIES})
 
diff --git a/FullSimLight/Plugins/HitsPlugin/CMakeLists.txt b/FullSimLight/Plugins/HitsPlugin/CMakeLists.txt
index 6055cee3a..e9fb430c2 100644
--- a/FullSimLight/Plugins/HitsPlugin/CMakeLists.txt
+++ b/FullSimLight/Plugins/HitsPlugin/CMakeLists.txt
@@ -63,7 +63,15 @@ include(${Geant4_USE_FILE})
 # Use the GNU install directory names.
 include( GNUInstallDirs )
 
-target_include_directories( GenerateHitsPlugin PUBLIC  ${CMAKE_SOURCE_DIR} ${HDF5_CXX_INCLUDE_DIRS})
+
+# Add the FullSimLight headers dir.
+# Path is different if built as a single top project, 
+# or as an all-in-one build together with all other GeoModel subpackages 
+if( FullSimLight_INDIVIDUAL_BUILD )
+    target_include_directories( GenerateHitsPlugin PUBLIC  ${CMAKE_SOURCE_DIR} ${HDF5_CXX_INCLUDE_DIRS})
+else() # all-in-one--build
+    target_include_directories( GenerateHitsPlugin PUBLIC  ${CMAKE_SOURCE_DIR}/FullSimLight ${HDF5_CXX_INCLUDE_DIRS})
+endif()
 
 target_link_libraries ( GenerateHitsPlugin PUBLIC ${CMAKE_DL_LIBS} ${Geant4_LIBRARIES} ${HDF5_CXX_LIBRARIES})
 
diff --git a/FullSimLight/Plugins/TracksPlugin/CMakeLists.txt b/FullSimLight/Plugins/TracksPlugin/CMakeLists.txt
index 5fa8bed52..21a411fbe 100644
--- a/FullSimLight/Plugins/TracksPlugin/CMakeLists.txt
+++ b/FullSimLight/Plugins/TracksPlugin/CMakeLists.txt
@@ -62,7 +62,14 @@ include(${Geant4_USE_FILE})
 # Use the GNU install directory names.
 include( GNUInstallDirs )
 
-target_include_directories( GenerateTracksPlugin PUBLIC  ${CMAKE_SOURCE_DIR} ${HDF5_CXX_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include)
+# Add the FullSimLight headers dir.
+# Path is different if built as a single top project, 
+# or as an all-in-one build together with all other GeoModel subpackages 
+if( FullSimLight_INDIVIDUAL_BUILD )
+    target_include_directories( GenerateTracksPlugin PUBLIC  ${CMAKE_SOURCE_DIR} ${HDF5_CXX_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include)
+else() # all-in-one--build
+    target_include_directories( GenerateTracksPlugin PUBLIC  ${CMAKE_SOURCE_DIR}/FullSimLight ${HDF5_CXX_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include)
+endif()
 
 target_link_libraries ( GenerateTracksPlugin PUBLIC ${CMAKE_DL_LIBS} ${Geant4_LIBRARIES} ${HDF5_CXX_LIBRARIES})
 
-- 
GitLab


From e97dae98aef62d0bbaba257af4d1d60475f8383d Mon Sep 17 00:00:00 2001
From: Riccardo Maria Bianchi <riccardo.maria.bianchi@cern.ch>
Date: Fri, 21 Oct 2022 16:34:26 +0200
Subject: [PATCH 10/13] Add option to disable support for HepMC3

---
 FSL/CMakeLists.txt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/FSL/CMakeLists.txt b/FSL/CMakeLists.txt
index d4eb6be19..db4d1e742 100644
--- a/FSL/CMakeLists.txt
+++ b/FSL/CMakeLists.txt
@@ -38,10 +38,10 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
 
 # Support for the HepMC3 exchange format
 # This is ON by default, but it can be disabled by the user if not used/needed,
-# or if HepMC3 is not installed
-option(GEOMODEL_USE_HEPMC3 "Enable the build of all GeoModel sub-packages" ON)
+# or if HepMC3 is not installed.
+option(GEOMODEL_USE_HEPMC3 "Buil GeoModel tools with support for the HepMC3 exchancge format (Note: HepMC3 must be installed on the target machine)" ON)
 if(GEOMODEL_USE_HEPMC3)
-    find_package(HepMC3 REQUIRED)
+    find_package(HepMC3 REQUIRED) # required by default, but it can be disabled 
 endif()
 if(HepMC3_FOUND)
     target_compile_definitions(fullSimLight PRIVATE USE_HEPMC3)
-- 
GitLab


From f2af664efa517bef9919319fe5b093bab54b3986 Mon Sep 17 00:00:00 2001
From: Riccardo Maria Bianchi <riccardo.maria.bianchi@cern.ch>
Date: Fri, 21 Oct 2022 16:35:06 +0200
Subject: [PATCH 11/13] Add option to disable support for HepMC3

---
 FullSimLight/CMakeLists.txt | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/FullSimLight/CMakeLists.txt b/FullSimLight/CMakeLists.txt
index 423b0e4b2..e56060316 100644
--- a/FullSimLight/CMakeLists.txt
+++ b/FullSimLight/CMakeLists.txt
@@ -57,10 +57,23 @@ find_package(Geant4 REQUIRED)
 message( STATUS "Found Geant4: ${Geant4_INCLUDE_DIR}")
 #----------------------------------------------------------------------------
 
+# Support for the Pythia MC generator
 find_package(Pythia QUIET) # optional
-find_package(HepMC3 QUIET) # optional
-#find_package(ROOT QUIET) #optional
-#option(HEPMC3_ROOTIO_USE "Enable the use of HEPMC3 with ROOT" OFF)
+if(Pythia_FOUND)
+  target_compile_definitions(fullSimLight PRIVATE USE_PYTHIA)
+  target_link_libraries(fullSimLight PRIVATE Pythia::Pythia)
+endif()
+
+# Support for the HepMC3 exchange format
+# This is ON by default, but it can be disabled by the user if not used/needed,
+# or if HepMC3 is not installed.
+option(GEOMODEL_USE_HEPMC3 "Buil GeoModel tools with support for the HepMC3 exchancge format (Note: HepMC3 must be installed on the target machine)" ON)
+if(GEOMODEL_USE_HEPMC3)
+    find_package(HepMC3 REQUIRED) # required by default, but it can be disabled 
+endif()
+if(HepMC3_FOUND)
+    target_compile_definitions(fullSimLight PRIVATE USE_HEPMC3)
+endif()
 
 
 #----------------------------------------------------------------------------
@@ -105,12 +118,12 @@ file(GLOB headers ${PROJECT_SOURCE_DIR}/inc/*.hh)
 
 if( NOT HepMC3_FOUND)
     file(GLOB hepmc3src ${PROJECT_SOURCE_DIR}/src/HepMC3*.cc)
-    message(STATUS "NOTE ==> HepMC3 was not found, we don't compile FullSimLight tools using it.")
+    message(STATUS "! NOTE ==> The support for HepMC3 was disabled by the user; therefore, support for it in FullSimLight will not be compiled.")
     #message("Removing those HepMC3-related sources: ${hepmc3src}") # debug msg
     list(REMOVE_ITEM sources ${hepmc3src})
     #message("new sources without HepMC3 support: ${sources}") # debug msg
 else()
-    message(STATUS "Found HepMC3, so support for it will be compiled. (${HepMC3_INCLUDE_DIRS})")
+    message(STATUS "Found HepMC3, so support for it will be compiled. (${HepMC3_INCLUDE_DIR})")
 endif()
 
 #----------------------------------------------------------------------------
@@ -131,14 +144,7 @@ add_executable(gmgeantino geantinoMaps.cc ${sources} ${headers})
 #add_executable(testMagneticField testMagneticField.cc)
 add_executable(gm2gdml geoModel2GDML.cc ${sources} ${headers})
 
-if(Pythia_FOUND)
-  target_compile_definitions(fullSimLight PRIVATE USE_PYTHIA)
-  target_link_libraries(fullSimLight PRIVATE Pythia::Pythia)
-endif()
 
-if(HepMC3_FOUND)
-    target_compile_definitions(fullSimLight PRIVATE USE_HEPMC3)
-endif()
 
 #if(HEPMC3_ROOTIO_USE)
 #  message( STATUS "HEPMC3 Root Dependency Switched on")
-- 
GitLab


From bf09e29f6a1781d12373e964ee1e55f62e0e6561 Mon Sep 17 00:00:00 2001
From: Riccardo Maria Bianchi <riccardo.maria.bianchi@cern.ch>
Date: Fri, 21 Oct 2022 16:48:50 +0200
Subject: [PATCH 12/13] Fix include of HepMC3

---
 FullSimLight/CMakeLists.txt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/FullSimLight/CMakeLists.txt b/FullSimLight/CMakeLists.txt
index e56060316..a15c5bee4 100644
--- a/FullSimLight/CMakeLists.txt
+++ b/FullSimLight/CMakeLists.txt
@@ -72,7 +72,8 @@ if(GEOMODEL_USE_HEPMC3)
     find_package(HepMC3 REQUIRED) # required by default, but it can be disabled 
 endif()
 if(HepMC3_FOUND)
-    target_compile_definitions(fullSimLight PRIVATE USE_HEPMC3)
+    #target_compile_definitions(fullSimLight PRIVATE USE_HEPMC3)
+    add_compile_definitions( USE_HEPMC3 )
 endif()
 
 
@@ -123,7 +124,7 @@ if( NOT HepMC3_FOUND)
     list(REMOVE_ITEM sources ${hepmc3src})
     #message("new sources without HepMC3 support: ${sources}") # debug msg
 else()
-    message(STATUS "Found HepMC3, so support for it will be compiled. (${HepMC3_INCLUDE_DIR})")
+    message(STATUS "Found HepMC3, so support for it will be compiled. (${HEPMC3_INCLUDE_DIR})")
 endif()
 
 #----------------------------------------------------------------------------
-- 
GitLab


From 86eb2462c6a63d89f7d04c6609b53624b46074fe Mon Sep 17 00:00:00 2001
From: Riccardo Maria Bianchi <riccardo.maria.bianchi@cern.ch>
Date: Mon, 24 Oct 2022 12:32:05 +0200
Subject: [PATCH 13/13] Fix typo in CMake option's description

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

diff --git a/FullSimLight/CMakeLists.txt b/FullSimLight/CMakeLists.txt
index a15c5bee4..d4ed57bcd 100644
--- a/FullSimLight/CMakeLists.txt
+++ b/FullSimLight/CMakeLists.txt
@@ -67,7 +67,7 @@ endif()
 # Support for the HepMC3 exchange format
 # This is ON by default, but it can be disabled by the user if not used/needed,
 # or if HepMC3 is not installed.
-option(GEOMODEL_USE_HEPMC3 "Buil GeoModel tools with support for the HepMC3 exchancge format (Note: HepMC3 must be installed on the target machine)" ON)
+option(GEOMODEL_USE_HEPMC3 "Build GeoModel tools with support for the HepMC3 exchancge format (Note: HepMC3 must be installed on the target machine)" ON)
 if(GEOMODEL_USE_HEPMC3)
     find_package(HepMC3 REQUIRED) # required by default, but it can be disabled 
 endif()
-- 
GitLab