From 2c91cf97be8d11cd7e2c9e9dfb57ddd4eb346ab3 Mon Sep 17 00:00:00 2001
From: oafedulidis <oafedulidis@ep1.rub.de>
Date: Tue, 16 Jan 2024 16:45:31 +0100
Subject: [PATCH] added query to check if root is sourced, if not will look for
 install from repository

---
 CMakeLists.txt                | 13 ++++++++++++-
 FitParams/CMakeLists.txt      |  4 ++--
 KMatrixExtract/CMakeLists.txt |  2 +-
 MinFunctions/CMakeLists.txt   |  2 +-
 PwaDynamics/CMakeLists.txt    |  2 +-
 ggUtils/CMakeLists.txt        |  2 +-
 gslUtils/CMakeLists.txt       |  2 +-
 7 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index ed0f63de..476c9785 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,9 +4,20 @@ project(Pawian)
 set(CXX_STANDARD 17)
 set(CXX_STANDARD_REQUIRED ON)
 
+if(DEFINED ENV{ROOTSYS})  
+  set(ROOT_INCLUDE_DIRS "$ENV{ROOTSYS}/include")
+  set(ROOT_LIBRARIES "$ENV{ROOTSYS}/lib")
+  MESSAGE(STATUS "found env var ROOTSYS")
+  MESSAGE(STATUS "root include path is: ${ROOT_INCLUDE_DIRS}")
+  MESSAGE(STATUS "root lib path is: ${ROOT_LIBRARIES}")
+else()
+  MESSAGE(STATUS "ROOTSYS not defined using find_package(ROOT)")
+  find_package(ROOT)
+endif()
+
 find_package(Boost)
 find_package(Boost COMPONENTS program_options unit_test_framework serialization filesystem timer REQUIRED)
-find_package(ROOT)
+
 find_package(GSL REQUIRED)
 
 #include_directories(
diff --git a/FitParams/CMakeLists.txt b/FitParams/CMakeLists.txt
index 7a797937..97b03d68 100644
--- a/FitParams/CMakeLists.txt
+++ b/FitParams/CMakeLists.txt
@@ -15,7 +15,7 @@ target_include_directories(FitParams
 )
 
 target_link_libraries(FitParams  
-  ROOT::Minuit2
+  ${ROOT_LIBRARIES}/libMinuit2.so
 )
 
 install(TARGETS FitParams
@@ -38,7 +38,7 @@ target_link_libraries(StreamerTestApp
   ConfigParser
   qft++Extension
   ErrLogger
-  ROOT::Minuit2
+  ${ROOT_LIBRARIES}/libMinuit2.so
 )
 
 add_executable(PwaCovMatrixApp
diff --git a/KMatrixExtract/CMakeLists.txt b/KMatrixExtract/CMakeLists.txt
index 1c088fdd..5f6198e3 100644
--- a/KMatrixExtract/CMakeLists.txt
+++ b/KMatrixExtract/CMakeLists.txt
@@ -16,7 +16,7 @@ target_include_directories(KMatrixExtract
 )
 
 target_link_libraries(KMatrixExtract    
-  ROOT::Minuit2 
+  ${ROOT_LIBRARIES}/libMinuit2.so 
 )
 
 install(TARGETS KMatrixExtract
diff --git a/MinFunctions/CMakeLists.txt b/MinFunctions/CMakeLists.txt
index 0f8eeee3..f3361de9 100644
--- a/MinFunctions/CMakeLists.txt
+++ b/MinFunctions/CMakeLists.txt
@@ -25,7 +25,7 @@ target_link_libraries(MinFunctions
   PwaDynamics
   PspGen
   PwaUtils
-  ROOT::Minuit2
+  ${ROOT_LIBRARIES}/libMinuit2.so
   ${Boost_LIBRARIES}
 )
 
diff --git a/PwaDynamics/CMakeLists.txt b/PwaDynamics/CMakeLists.txt
index 6156927d..18a06db3 100644
--- a/PwaDynamics/CMakeLists.txt
+++ b/PwaDynamics/CMakeLists.txt
@@ -20,7 +20,7 @@ target_link_libraries(PwaDynamics
   qft++
   qft++Extension
   ErrLogger
-  ROOT::Minuit2
+  ${ROOT_LIBRARIES}/libMinuit2.so
 )
 
 install(TARGETS PwaDynamics
diff --git a/ggUtils/CMakeLists.txt b/ggUtils/CMakeLists.txt
index 358f59af..c6c7efd8 100644
--- a/ggUtils/CMakeLists.txt
+++ b/ggUtils/CMakeLists.txt
@@ -16,7 +16,7 @@ target_include_directories(ggUtils
 )
 
 target_link_libraries(ggUtils
-  ROOT::Minuit2
+  ${ROOT_LIBRARIES}/libMinuit2.so
 )
 
 install(TARGETS ggUtils
diff --git a/gslUtils/CMakeLists.txt b/gslUtils/CMakeLists.txt
index ea99d478..0495bd87 100644
--- a/gslUtils/CMakeLists.txt
+++ b/gslUtils/CMakeLists.txt
@@ -22,7 +22,7 @@ target_link_libraries(gslUtils
   qft++
   qft++Extension
   ErrLogger
-  ROOT::Minuit2
+  ${ROOT_LIBRARIES}/libMinuit2.so
   GSL::gsl
   GSL::gslcblas
 )
-- 
GitLab