From b4221f15a22fdd3ccfb170426101cfa652a9b8a7 Mon Sep 17 00:00:00 2001
From: lintao <lintao51@gmail.com>
Date: Fri, 25 Dec 2020 10:43:24 +0800
Subject: [PATCH] WIP: refactor the cmake: move all find_package into one cmake
 file.

---
 Analysis/TotalInvMass/CMakeLists.txt          |  6 ----
 Detector/DetSegmentation/CMakeLists.txt       |  2 --
 Detector/GeomSvc/CMakeLists.txt               |  4 ---
 Digitisers/DCHDigi/CMakeLists.txt             |  8 -----
 Digitisers/G2CDArbor/CMakeLists.txt           |  9 ------
 Digitisers/SimHitMerge/CMakeLists.txt         |  4 ---
 Digitisers/SimpleDigi/CMakeLists.txt          |  8 -----
 Examples/CMakeLists.txt                       |  7 -----
 Generator/CMakeLists.txt                      |  8 -----
 Reconstruction/DCHDedx/CMakeLists.txt         |  4 ---
 Reconstruction/Digi_Calo/CMakeLists.txt       |  7 -----
 .../PFA/Pandora/GaudiPandora/CMakeLists.txt   | 13 ---------
 .../PFA/Pandora/MatrixPandora/CMakeLists.txt  | 13 ---------
 Reconstruction/SiliconTracking/CMakeLists.txt |  7 -----
 Reconstruction/Tracking/CMakeLists.txt        |  6 ----
 Service/GearSvc/CMakeLists.txt                |  4 ---
 Service/TrackSystemSvc/CMakeLists.txt         |  9 ------
 Simulation/DetSimAna/CMakeLists.txt           |  5 ----
 Simulation/DetSimCore/CMakeLists.txt          |  2 --
 Simulation/DetSimDedx/CMakeLists.txt          |  3 --
 Simulation/DetSimFastModel/CMakeLists.txt     |  2 +-
 Simulation/DetSimGeom/CMakeLists.txt          |  1 -
 Simulation/DetSimSD/CMakeLists.txt            |  4 ---
 Utilities/DataHelper/CMakeLists.txt           |  8 -----
 Utilities/KalDet/CMakeLists.txt               |  7 -----
 Utilities/KalTest/CMakeLists.txt              |  2 --
 Utilities/KiTrack/CMakeLists.txt              |  8 -----
 cmake/CEPCSWDependencies.cmake                | 29 +++++++++++++++++--
 28 files changed, 27 insertions(+), 163 deletions(-)

diff --git a/Analysis/TotalInvMass/CMakeLists.txt b/Analysis/TotalInvMass/CMakeLists.txt
index 779dc0c3..6a9be88e 100644
--- a/Analysis/TotalInvMass/CMakeLists.txt
+++ b/Analysis/TotalInvMass/CMakeLists.txt
@@ -1,10 +1,4 @@
 
-find_package(CLHEP REQUIRED;CONFIG)
-find_package(EDM4HEP REQUIRED)
-find_package(GSL REQUIRED ) 
-find_package(LCIO REQUIRED ) 
-find_package(k4FWCore REQUIRED)
-
 gaudi_add_module(TotalInvMass
                  SOURCES src/TotalInvMass.cc
                  LINK k4FWCore::k4FWCore 
diff --git a/Detector/DetSegmentation/CMakeLists.txt b/Detector/DetSegmentation/CMakeLists.txt
index 4580fba5..9b027334 100644
--- a/Detector/DetSegmentation/CMakeLists.txt
+++ b/Detector/DetSegmentation/CMakeLists.txt
@@ -7,8 +7,6 @@ set(CMAKE_MODULE_PATH  ${CMAKE_MODULE_PATH}  ${DD4hep_ROOT}/cmake )
 
 include(DD4hep)
 
-find_package(ROOT COMPONENTS MathCore Physics GenVector Geom REQUIRED)
-
 gaudi_add_library(DetSegmentation
                   SOURCES src/GridDriftChamber.cpp
                   LINK Gaudi::GaudiKernel
diff --git a/Detector/GeomSvc/CMakeLists.txt b/Detector/GeomSvc/CMakeLists.txt
index a4b10c8b..137aa0e5 100644
--- a/Detector/GeomSvc/CMakeLists.txt
+++ b/Detector/GeomSvc/CMakeLists.txt
@@ -4,10 +4,6 @@
 #    Desc: implement the IGeomSvc interface.
 ##############################################################################
 
-find_package(ROOT COMPONENTS MathCore GenVector Geom Tree)
-find_package(DD4hep COMPONENTS DDG4 DDRec REQUIRED)
-find_package(GEAR REQUIRED)
-
 gaudi_add_module(GeomSvc
                  SOURCES src/GeomSvc.cpp
                  LINK
diff --git a/Digitisers/DCHDigi/CMakeLists.txt b/Digitisers/DCHDigi/CMakeLists.txt
index 9cc17c8c..8246da79 100644
--- a/Digitisers/DCHDigi/CMakeLists.txt
+++ b/Digitisers/DCHDigi/CMakeLists.txt
@@ -1,11 +1,3 @@
-
-find_package(k4FWCore)
-find_package(CLHEP REQUIRED;CONFIG)
-find_package(DD4hep COMPONENTS DDG4 REQUIRED)
-find_package(EDM4HEP REQUIRED )
-
-find_package(ROOT COMPONENTS MathCore Physics GenVector Geom REQUIRED)
-
 ## Modules
 gaudi_add_module(DCHDigi
                  SOURCES src/DCHDigiAlg.cpp
diff --git a/Digitisers/G2CDArbor/CMakeLists.txt b/Digitisers/G2CDArbor/CMakeLists.txt
index fe75a60e..cc6bf389 100644
--- a/Digitisers/G2CDArbor/CMakeLists.txt
+++ b/Digitisers/G2CDArbor/CMakeLists.txt
@@ -1,12 +1,3 @@
-
-find_package(CLHEP REQUIRED;CONFIG)
-find_package(DD4hep COMPONENTS DDG4 REQUIRED)
-find_package(EDM4HEP REQUIRED)
-find_package(GEAR REQUIRED)
-find_package(GSL REQUIRED ) 
-find_package(LCIO REQUIRED ) 
-find_package(k4FWCore REQUIRED)
-
 # Modules
 gaudi_add_module(G2CDArbor
                  SOURCES src/G2CDArborAlg.cpp
diff --git a/Digitisers/SimHitMerge/CMakeLists.txt b/Digitisers/SimHitMerge/CMakeLists.txt
index 1a07af89..4c89a1b8 100644
--- a/Digitisers/SimHitMerge/CMakeLists.txt
+++ b/Digitisers/SimHitMerge/CMakeLists.txt
@@ -1,8 +1,4 @@
 
-find_package(DD4hep COMPONENTS DDG4 REQUIRED)
-find_package(EDM4HEP REQUIRED)
-find_package(k4FWCore REQUIRED)
-
 # Modules
 gaudi_add_module(SimHitMerge
                  SOURCES src/SimHitMergeAlg.cpp
diff --git a/Digitisers/SimpleDigi/CMakeLists.txt b/Digitisers/SimpleDigi/CMakeLists.txt
index 85862c3e..4e2687bc 100644
--- a/Digitisers/SimpleDigi/CMakeLists.txt
+++ b/Digitisers/SimpleDigi/CMakeLists.txt
@@ -1,11 +1,3 @@
-
-find_package(CLHEP REQUIRED;CONFIG)
-find_package(GEAR REQUIRED)
-find_package(GSL REQUIRED ) 
-find_package(LCIO REQUIRED ) 
-find_package(k4FWCore REQUIRED)
-find_package(EDM4HEP REQUIRED)
-
 # Modules
 gaudi_add_module(SimpleDigi 
                  SOURCES src/PlanarDigiAlg.cpp
diff --git a/Examples/CMakeLists.txt b/Examples/CMakeLists.txt
index e71a4770..9c00a9ea 100644
--- a/Examples/CMakeLists.txt
+++ b/Examples/CMakeLists.txt
@@ -1,10 +1,3 @@
-
-find_package(podio REQUIRED)
-find_package(LCIO REQUIRED)
-find_package(EDM4HEP REQUIRED)
-find_package(k4FWCore REQUIRED)
-find_package(DD4hep COMPONENTS DDRec DDParsers REQUIRED)
-
 # Headers and Libraries
 
 # Modules
diff --git a/Generator/CMakeLists.txt b/Generator/CMakeLists.txt
index 8350f8b1..0a244a3a 100644
--- a/Generator/CMakeLists.txt
+++ b/Generator/CMakeLists.txt
@@ -3,14 +3,6 @@
 find_package(Geant4 REQUIRED)
 include(${Geant4_USE_FILE})
 
-find_package(ROOT COMPONENTS RIO Tree TreePlayer MathCore Net Graf3d Graf Gpad EG REQUIRED)
-find_package(LCIO)
-find_package(podio)
-find_package(EDM4HEP)
-find_package(HepMC)
-find_package(CLHEP REQUIRED;CONFIG)
-find_package(k4FWCore REQUIRED)
-
 gaudi_add_module(GenAlgo
                  SOURCES src/IGenTool.cpp 
                          src/GenAlgo.cpp 
diff --git a/Reconstruction/DCHDedx/CMakeLists.txt b/Reconstruction/DCHDedx/CMakeLists.txt
index 2f207185..3303351e 100644
--- a/Reconstruction/DCHDedx/CMakeLists.txt
+++ b/Reconstruction/DCHDedx/CMakeLists.txt
@@ -1,8 +1,4 @@
 
-find_package(k4FWCore)
-find_package(EDM4HEP REQUIRED ) 
-find_package(DD4hep COMPONENTS DDCore DDRec REQUIRED)
-
 # Modules
 gaudi_add_module(DCHDedx
                  SOURCES src/RecDCHDedxAlg.cpp
diff --git a/Reconstruction/Digi_Calo/CMakeLists.txt b/Reconstruction/Digi_Calo/CMakeLists.txt
index 289c5a45..e3c5b9d4 100644
--- a/Reconstruction/Digi_Calo/CMakeLists.txt
+++ b/Reconstruction/Digi_Calo/CMakeLists.txt
@@ -1,11 +1,4 @@
 
-find_package(CLHEP REQUIRED;CONFIG)
-find_package(DD4hep COMPONENTS DDG4 REQUIRED)
-find_package(EDM4HEP REQUIRED )
-find_package(k4FWCore REQUIRED )
-
-find_package(CLHEP REQUIRED)
-
 ## Modules
 gaudi_add_module(Digi_Calo
                  SOURCES src/CaloDigiAlg.cpp
diff --git a/Reconstruction/PFA/Pandora/GaudiPandora/CMakeLists.txt b/Reconstruction/PFA/Pandora/GaudiPandora/CMakeLists.txt
index bf3b0eeb..80307e39 100644
--- a/Reconstruction/PFA/Pandora/GaudiPandora/CMakeLists.txt
+++ b/Reconstruction/PFA/Pandora/GaudiPandora/CMakeLists.txt
@@ -1,17 +1,4 @@
 
-find_package(LCIO REQUIRED ) 
-find_package(DD4hep COMPONENTS DDG4 REQUIRED)
-find_package(GEAR REQUIRED)
-find_package(CLHEP REQUIRED;CONFIG)
-
-find_package(EDM4HEP REQUIRED )
-find_package(k4FWCore REQUIRED )
-
-find_package(PandoraSDK REQUIRED ) 
-find_package(LCContent REQUIRED ) 
-
-find_package(ROOT COMPONENTS MathCore Physics GenVector Geom REQUIRED)
-
 # Modules
 gaudi_add_module(GaudiPandora
                  SOURCES src/PandoraPFAlg.cpp
diff --git a/Reconstruction/PFA/Pandora/MatrixPandora/CMakeLists.txt b/Reconstruction/PFA/Pandora/MatrixPandora/CMakeLists.txt
index 8faef547..84ba59b3 100644
--- a/Reconstruction/PFA/Pandora/MatrixPandora/CMakeLists.txt
+++ b/Reconstruction/PFA/Pandora/MatrixPandora/CMakeLists.txt
@@ -1,16 +1,3 @@
-
-find_package(DD4hep COMPONENTS DDG4 REQUIRED)
-find_package(CLHEP REQUIRED;CONFIG)
-find_package(LCIO REQUIRED ) 
-find_package(GEAR REQUIRED)
-find_package(EDM4HEP REQUIRED ) 
-find_package(k4FWCore REQUIRED ) 
-
-find_package(PandoraSDK REQUIRED ) 
-find_package(LCContent REQUIRED ) 
-
-find_package(ROOT REQUIRED COMPONENTS Eve Geom RGL EG)
-
 # Modules
 gaudi_add_module(MatrixPandora
                  SOURCES src/PandoraMatrixAlg.cpp
diff --git a/Reconstruction/SiliconTracking/CMakeLists.txt b/Reconstruction/SiliconTracking/CMakeLists.txt
index 7dd05180..9eb87350 100644
--- a/Reconstruction/SiliconTracking/CMakeLists.txt
+++ b/Reconstruction/SiliconTracking/CMakeLists.txt
@@ -1,11 +1,4 @@
 
-find_package(GEAR REQUIRED)
-find_package(GSL REQUIRED ) 
-find_package(LCIO REQUIRED )
-find_package(EDM4HEP REQUIRED ) 
-find_package(DD4hep COMPONENTS DDCore DDRec REQUIRED)
-find_package(k4FWCore)
-
 # Modules
 gaudi_add_module(SiliconTracking
                  SOURCES src/ForwardTrackingAlg.cpp
diff --git a/Reconstruction/Tracking/CMakeLists.txt b/Reconstruction/Tracking/CMakeLists.txt
index b60bca6a..3dd11b33 100644
--- a/Reconstruction/Tracking/CMakeLists.txt
+++ b/Reconstruction/Tracking/CMakeLists.txt
@@ -1,10 +1,4 @@
 
-find_package(GEAR REQUIRED)
-find_package(GSL REQUIRED ) 
-find_package(LCIO REQUIRED ) 
-find_package(EDM4HEP REQUIRED ) 
-find_package(DD4hep COMPONENTS DDCore DDRec REQUIRED)
-
 # Modules
 gaudi_add_module(Tracking
                  SOURCES src/Clupatra/ClupatraAlg.cpp
diff --git a/Service/GearSvc/CMakeLists.txt b/Service/GearSvc/CMakeLists.txt
index d8edef67..248cf3df 100644
--- a/Service/GearSvc/CMakeLists.txt
+++ b/Service/GearSvc/CMakeLists.txt
@@ -1,8 +1,4 @@
 
-find_package(GEAR REQUIRED)
-
-find_package(DD4hep COMPONENTS DDCore DDRec REQUIRED)
-
 gaudi_add_header_only_library(GearSvc)
 
 gaudi_add_module(GearSvcPlugins
diff --git a/Service/TrackSystemSvc/CMakeLists.txt b/Service/TrackSystemSvc/CMakeLists.txt
index 44b3eb9c..67710976 100644
--- a/Service/TrackSystemSvc/CMakeLists.txt
+++ b/Service/TrackSystemSvc/CMakeLists.txt
@@ -1,14 +1,5 @@
 # gaudi_subdir(TrackSystemSvc v0r0)
 
-find_package(CLHEP REQUIRED;CONFIG)
-find_package(ROOT 6.14 REQUIRED COMPONENTS Matrix Physics)
-find_package(GEAR REQUIRED)
-find_package(LCIO REQUIRED)
-find_package(EDM4HEP REQUIRED)
-#find_package(KalTest REQUIRED)
-#find_package(KalDet REQUIRED)
-find_package(DD4hep COMPONENTS DDCore DDRec REQUIRED)
-
 gaudi_add_library(TrackSystemSvcLib
                   SOURCES src/HelixFit.cc
                           src/HelixTrack.cc
diff --git a/Simulation/DetSimAna/CMakeLists.txt b/Simulation/DetSimAna/CMakeLists.txt
index 01b4d5d6..794bcc2f 100644
--- a/Simulation/DetSimAna/CMakeLists.txt
+++ b/Simulation/DetSimAna/CMakeLists.txt
@@ -1,11 +1,6 @@
 
 find_package(Geant4 REQUIRED ui_all vis_all)
 include(${Geant4_USE_FILE})
-find_package(DD4hep COMPONENTS DDG4 REQUIRED)
-
-# For EDM & I/O
-find_package(EDM4HEP REQUIRED)
-
 
 gaudi_add_module(DetSimAna
                  SOURCES src/Edm4hepWriterAnaElemTool.cpp
diff --git a/Simulation/DetSimCore/CMakeLists.txt b/Simulation/DetSimCore/CMakeLists.txt
index e9ae024a..9c225fc7 100644
--- a/Simulation/DetSimCore/CMakeLists.txt
+++ b/Simulation/DetSimCore/CMakeLists.txt
@@ -2,8 +2,6 @@
 find_package(Geant4 REQUIRED ui_all vis_all)
 include(${Geant4_USE_FILE})
 
-find_package(EDM4HEP REQUIRED)
-find_package(DD4hep COMPONENTS DDG4 REQUIRED)
 
 message(" Geant4_LIBRARIES: ${Geant4_LIBRARIES}")
 
diff --git a/Simulation/DetSimDedx/CMakeLists.txt b/Simulation/DetSimDedx/CMakeLists.txt
index 7760d417..fb8e4d3a 100644
--- a/Simulation/DetSimDedx/CMakeLists.txt
+++ b/Simulation/DetSimDedx/CMakeLists.txt
@@ -1,9 +1,6 @@
 
 find_package(Geant4 REQUIRED ui_all vis_all)
 include(${Geant4_USE_FILE})
-find_package(DD4hep COMPONENTS DDG4 REQUIRED)
-find_package(EDM4HEP REQUIRED )
-include_directories(${EDM4HEP_INCLUDE_DIR})
 
 gaudi_add_module(DetSimDedx
                  SOURCES src/DummyDedxSimTool.cpp
diff --git a/Simulation/DetSimFastModel/CMakeLists.txt b/Simulation/DetSimFastModel/CMakeLists.txt
index 420b93f0..50ceb1e3 100644
--- a/Simulation/DetSimFastModel/CMakeLists.txt
+++ b/Simulation/DetSimFastModel/CMakeLists.txt
@@ -1,7 +1,7 @@
 
 find_package(Geant4 REQUIRED ui_all vis_all)
 include(${Geant4_USE_FILE})
-find_package(DD4hep COMPONENTS DDG4 REQUIRED)
+
 
 gaudi_add_module(DetSimFastModel
                  SOURCES src/DummyFastSimG4Tool.cpp
diff --git a/Simulation/DetSimGeom/CMakeLists.txt b/Simulation/DetSimGeom/CMakeLists.txt
index f9cf4b54..aec48800 100644
--- a/Simulation/DetSimGeom/CMakeLists.txt
+++ b/Simulation/DetSimGeom/CMakeLists.txt
@@ -1,7 +1,6 @@
 
 find_package(Geant4 REQUIRED ui_all vis_all)
 include(${Geant4_USE_FILE})
-find_package(DD4hep COMPONENTS DDG4 REQUIRED)
 
 gaudi_add_module(DetSimGeom 
                  SOURCES src/WorldDetElemTool.cpp
diff --git a/Simulation/DetSimSD/CMakeLists.txt b/Simulation/DetSimSD/CMakeLists.txt
index b6b81ee1..eed28a78 100644
--- a/Simulation/DetSimSD/CMakeLists.txt
+++ b/Simulation/DetSimSD/CMakeLists.txt
@@ -1,10 +1,6 @@
 
 find_package(Geant4 REQUIRED ui_all vis_all)
 include(${Geant4_USE_FILE})
-find_package(DD4hep COMPONENTS DDG4 REQUIRED)
-
-set(DetSimSD_srcs
-)
 
 gaudi_add_module(DetSimSD 
                  SOURCES src/CalorimeterSensDetTool.cpp
diff --git a/Utilities/DataHelper/CMakeLists.txt b/Utilities/DataHelper/CMakeLists.txt
index 5300866d..0583b24b 100644
--- a/Utilities/DataHelper/CMakeLists.txt
+++ b/Utilities/DataHelper/CMakeLists.txt
@@ -1,12 +1,4 @@
 
-find_package(CLHEP REQUIRED;CONFIG)
-find_package(EDM4HEP REQUIRED)
-find_package(GSL REQUIRED )
-message("GSL: ${GSL_LIBRARIES} ")
-message("GSL INCLUDE_DIRS: ${GSL_INCLUDE_DIRS} ")
-
-#gaudi_install_headers(DataHelper)
-
 gaudi_add_library(DataHelperLib 
                   SOURCES src/CaloHitExtended.cc
                           src/Circle.cc
diff --git a/Utilities/KalDet/CMakeLists.txt b/Utilities/KalDet/CMakeLists.txt
index e85a9ccd..faacdc5b 100644
--- a/Utilities/KalDet/CMakeLists.txt
+++ b/Utilities/KalDet/CMakeLists.txt
@@ -3,13 +3,6 @@
 #    Desc: import from ILCSoft
 ##############################################################################
 
-find_package(CLHEP REQUIRED;CONFIG)
-find_package(LCIO)
-find_package(GEAR)
-find_package(ROOT COMPONENTS MathCore)
-find_package(EDM4HEP REQUIRED)
-find_package(DD4hep COMPONENTS DDCore DDRec REQUIRED)
-
 get_target_property(to_incl KalTestLib SOURCE_DIR)
 if (to_incl)
   LIST( APPEND DICT_INCLUDE_DIRS ${to_incl}/include)
diff --git a/Utilities/KalTest/CMakeLists.txt b/Utilities/KalTest/CMakeLists.txt
index 907e9877..d1a29b90 100644
--- a/Utilities/KalTest/CMakeLists.txt
+++ b/Utilities/KalTest/CMakeLists.txt
@@ -3,8 +3,6 @@
 #    Desc: import from ILCSoft
 ##############################################################################
 
-find_package(ROOT REQUIRED COMPONENTS MathCore)
-
 set( DICT_CINT_DEFINITIONS "HANDLE_DICT_EXCEPTIONS=IGNORED_FOR_CINT" )
 set( DICT_INPUT_DIRS geomlib kallib kaltracklib utils )
 set( DICT_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/rootdict )
diff --git a/Utilities/KiTrack/CMakeLists.txt b/Utilities/KiTrack/CMakeLists.txt
index a56283d6..6beed3c6 100644
--- a/Utilities/KiTrack/CMakeLists.txt
+++ b/Utilities/KiTrack/CMakeLists.txt
@@ -1,12 +1,4 @@
 
-find_package(CLHEP REQUIRED;CONFIG)
-find_package(ROOT REQUIRED)
-#find_package(DD4hep REQUIRED)
-find_package(GSL REQUIRED)
-find_package(EDM4HEP REQUIRED)
-find_package(LCIO REQUIRED)
-find_package(DD4hep COMPONENTS DDCore DDRec REQUIRED)
-
 gaudi_add_library(KiTrackLib 
                   SOURCES src/KiTrack/Automaton.cc 
                           src/KiTrack/HopfieldNeuralNet.cc 
diff --git a/cmake/CEPCSWDependencies.cmake b/cmake/CEPCSWDependencies.cmake
index 49025c46..92d8911e 100644
--- a/cmake/CEPCSWDependencies.cmake
+++ b/cmake/CEPCSWDependencies.cmake
@@ -2,9 +2,32 @@
 
 Find all the dependencies here, so in each package user don't need to find the packages again.
 
+- CLHEP
+- DD4hep
+- EDM4hep
 - Gaudi
+- Geant4
+- GEAR
+- GSL
+- HepMC
 - k4FWCore
-- EDM4hep
-- DD4hep
-
+- LCContent
+- LCIO
+- PandoraSDK
+- podio
+- ROOT
 #]]
+
+find_package(CLHEP REQUIRED;CONFIG)
+find_package(DD4hep COMPONENTS DDCore DDG4 DDParsers DDRec REQUIRED)
+find_package(EDM4HEP REQUIRED)
+find_package(Geant4 REQUIRED ui_all vis_all)
+find_package(GEAR REQUIRED)
+find_package(GSL REQUIRED)
+find_package(HepMC)
+find_package(k4FWCore REQUIRED)
+find_package(LCContent REQUIRED)
+find_package(LCIO REQUIRED)
+find_package(PandoraSDK REQUIRED)
+find_package(podio REQUIRED)
+find_package(ROOT COMPONENTS EG Graf Graf3d Gpad MathCore Net RIO Tree TreePlayer REQUIRED)
-- 
GitLab