From 1993465725753bd2746d66dfd22730bc27728c34 Mon Sep 17 00:00:00 2001
From: Markus Frank <Markus.Frank@cern.ch>
Date: Fri, 9 Aug 2019 18:24:28 +0200
Subject: [PATCH] Fix plugin service linkage for MAC

---
 DDG4/examples/initAClick.C         |  3 ++-
 cmake/DD4hepBuild.cmake            | 10 ++++++----
 cmake/MakeGaudiMap.cmake           |  3 ++-
 examples/LHeD/scripts/initAClick.C |  3 ++-
 4 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/DDG4/examples/initAClick.C b/DDG4/examples/initAClick.C
index 03a044dd9..b0a51fd04 100644
--- a/DDG4/examples/initAClick.C
+++ b/DDG4/examples/initAClick.C
@@ -63,7 +63,7 @@ int initAClick(const char* command=0)  {
   std::string defs    = "";
   std::string libs    = " -L"+rootsys+"/lib";
   std::string inc     = " -I"+dd4hep+"/examples/DDG4/examples -I"+dd4hep + " -I"+dd4hep+"/include";
-  libs += " -L"+dd4hep+"/lib -lDDCore -lDDG4";
+  libs += " -L"+dd4hep+"/lib -lDD4hepGaudiPluginMgr -lDDCore -lDDG4";
   if ( !geant4.empty() )  {
     inc  += " -I"+geant4+"/include/Geant4";
 #ifdef __APPLE__
@@ -83,6 +83,7 @@ int initAClick(const char* command=0)  {
 #ifndef __APPLE__
   libs += " -lCore -lMathCore -pthread -lm -ldl -rdynamic";
 #endif
+  gSystem->Load("libDD4hepGaudiPluginMgr");
   gSystem->AddIncludePath(inc.c_str());
   gSystem->AddLinkedLibs(libs.c_str());
   std::cout << "+++ Includes:   " << gSystem->GetIncludePath() << std::endl;
diff --git a/cmake/DD4hepBuild.cmake b/cmake/DD4hepBuild.cmake
index df95cccd7..b91e8e3b5 100644
--- a/cmake/DD4hepBuild.cmake
+++ b/cmake/DD4hepBuild.cmake
@@ -1461,9 +1461,13 @@ endfunction()
 #
 #---------------------------------------------------------------------------------------------------
 function ( fill_dd4hep_library_path )
-
   string(REGEX REPLACE "/lib/libCore.*" "" ROOT_ROOT ${ROOT_Core_LIBRARY})
-  SET( ENV{DD4HEP_LIBRARY_PATH} ${ROOT_ROOT}/lib:${Boost_LIBRARY_DIRS} )
+  SET( ENV{DD4HEP_LIBRARY_PATH} ${ROOT_ROOT}/lib )
+  if ( NOT "${Boost_LIBRARY_DIRS}" STREQUAL "" )
+    SET( ENV{DD4HEP_LIBRARY_PATH} $ENV{DD4HEP_LIBRARY_PATH}:${Boost_LIBRARY_DIRS} )
+  else()
+    dd4hep_print("|++> The boost library path cannot be determined. Problems maybe ahead.")
+  endif()
   if ( ${DD4HEP_USE_GEANT4} )
     string(REGEX REPLACE "/lib/Geant4.*" "" Geant4_ROOT ${Geant4_DIR})
     SET( ENV{DD4HEP_LIBRARY_PATH} ${Geant4_ROOT}/lib:$ENV{DD4HEP_LIBRARY_PATH} )
@@ -1480,6 +1484,4 @@ function ( fill_dd4hep_library_path )
   endif()
 
   SET( ENV{DD4HEP_LIBRARY_PATH} ${CMAKE_BINARY_DIR}/lib:$ENV{DD4HEP_LIBRARY_PATH} )
-
-
 endfunction()
diff --git a/cmake/MakeGaudiMap.cmake b/cmake/MakeGaudiMap.cmake
index 47ef97ce8..30cfd7fd7 100644
--- a/cmake/MakeGaudiMap.cmake
+++ b/cmake/MakeGaudiMap.cmake
@@ -9,8 +9,9 @@ message(STATUS " *** Gaudi listcomponents: Generate map for ${libname} ..." )
     ) 
 
   if(APPLE)
-    SET ( ENV{DYLD_LIBRARY_PATH} ${genmap_install_dir}:$ENV{DYLD_LIBRARY_PATH}:$ENV{DD4HEP_LIBRARY_PATH} )
+    SET ( ENV{DYLD_LIBRARY_PATH} ${genmap_install_dir}:$ENV{DYLD_LIBRARY_PATH}:$ENV{DD4HEP_LIBRARY_PATH}:${Boost_LIBRARY_DIRS} )
     EXECUTE_PROCESS( COMMAND echo DYLD_LIBRARY_PATH = $ENV{DYLD_LIBRARY_PATH} )
+    EXECUTE_PROCESS( COMMAND echo Boost_LIBRARY_DIRS = ${Boost_LIBRARY_DIRS} )
   else()
     SET ( ENV{LD_LIBRARY_PATH} ${genmap_install_dir}:$ENV{LD_LIBRARY_PATH} )
     #SET ( ENV{LD_PRELOAD} /lib64/libglapi.so )
diff --git a/examples/LHeD/scripts/initAClick.C b/examples/LHeD/scripts/initAClick.C
index 34f957206..8f155ade5 100644
--- a/examples/LHeD/scripts/initAClick.C
+++ b/examples/LHeD/scripts/initAClick.C
@@ -63,7 +63,7 @@ int initAClick(const char* command=0)  {
   std::string defs    = "";
   std::string libs    = " -L"+rootsys+"/lib";
   std::string inc     = " -I"+dd4hep+"/examples/LHeD/scripts -I"+dd4hep + " -I"+dd4hep+"/include"+clhep+"/include -I"+geant4+"/include";
-  libs += " -L"+dd4hep+"/lib -lDDCore -lDDG4";
+  libs += " -L"+dd4hep+"/lib -lDD4hepGaudiPluginMgr -lDDCore -lDDG4";
   if ( !geant4.empty() )  {
     inc  += " -I"+geant4+"/include/Geant4";
 #ifdef __APPLE__
@@ -83,6 +83,7 @@ int initAClick(const char* command=0)  {
 #ifndef __APPLE__
   libs += " -lCore -lMathCore -pthread -lm -ldl -rdynamic";
 #endif
+  gSystem->Load("libDD4hepGaudiPluginMgr");
   gSystem->AddIncludePath(inc.c_str());
   gSystem->AddLinkedLibs(libs.c_str());
   std::cout << "+++ Includes:   " << gSystem->GetIncludePath() << std::endl;
-- 
GitLab