From 0f9467d1512ef1c15c630adabc9ecbbb4baed5c9 Mon Sep 17 00:00:00 2001
From: Andre Sailer <andre.philippe.sailer@cern.ch>
Date: Mon, 12 Aug 2019 18:15:43 +0200
Subject: [PATCH] PluginMgr: pass boost dependency on to MakeGaudiMap and
 dd4hep dependents

---
 GaudiPluginService/CMakeLists.txt |  5 +++--
 cmake/DD4hep.cmake                | 18 +++++++-----------
 cmake/DD4hepConfig.cmake.in       |  2 +-
 cmake/MakeGaudiMap.cmake          |  4 ++--
 4 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/GaudiPluginService/CMakeLists.txt b/GaudiPluginService/CMakeLists.txt
index c22228e33..b02354c25 100644
--- a/GaudiPluginService/CMakeLists.txt
+++ b/GaudiPluginService/CMakeLists.txt
@@ -18,7 +18,7 @@ target_compile_options(DD4hepGaudiPluginMgr PRIVATE -Wno-deprecated)
 target_compile_options(DD4hepGaudiPluginMgr PRIVATE -Wno-keyword-macro)
 target_compile_options(DD4hepGaudiPluginMgr PRIVATE -Wno-return-type-c-linkage)
 
-target_link_libraries(DD4hepGaudiPluginMgr ${CMAKE_DL_LIBS} Boost::filesystem Boost::system)
+target_link_libraries(DD4hepGaudiPluginMgr PUBLIC Boost::filesystem Boost::system ${CMAKE_DL_LIBS})
 SET_TARGET_PROPERTIES(DD4hepGaudiPluginMgr PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
 
 if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) 
@@ -27,7 +27,8 @@ if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
 endif()
 
 add_executable(listcomponents src/listcomponents.cpp )
-target_link_libraries(listcomponents DD4hepGaudiPluginMgr  ${CMAKE_DL_LIBS})
+add_executable(DD4hep::listcomponents ALIAS listcomponents)
+target_link_libraries(listcomponents PUBLIC DD4hepGaudiPluginMgr ${CMAKE_DL_LIBS})
 target_compile_options(listcomponents PRIVATE -Wno-deprecated)
 
 INSTALL(TARGETS listcomponents DD4hepGaudiPluginMgr EXPORT DD4hep
diff --git a/cmake/DD4hep.cmake b/cmake/DD4hep.cmake
index 807adba62..1b3426bbd 100644
--- a/cmake/DD4hep.cmake
+++ b/cmake/DD4hep.cmake
@@ -97,23 +97,19 @@ function(dd4hep_generate_rootmap_notapple library)
   set(libname ${CMAKE_SHARED_MODULE_PREFIX}${library}${CMAKE_SHARED_LIBRARY_SUFFIX})
   #message(STATUS "DD4hep_DIR = ${DD4hep_DIR}" )
 
-  add_custom_command(TARGET ${library}
+  GET_TARGET_PROPERTY(boost_filesystem_loc Boost::filesystem IMPORTED_LOCATION)
+  GET_FILENAME_COMPONENT(boost_dir ${boost_filesystem_loc} DIRECTORY) 
+
+  add_custom_command(OUTPUT ${rootmapfile}
+                     DEPENDS ${library}
                      POST_BUILD
                      COMMAND ${CMAKE_COMMAND} -Dlibname=${libname} -Drootmapfile=${rootmapfile}
                              -Dgenmap_install_dir=${LIBRARY_OUTPUT_PATH}
                              -DROOT_VERSION=${ROOT_VERSION}
                              -DDD4hep_DIR=${DD4hep_DIR}
+                             -DLD_PATH=${boost_dir}
                              -P ${DD4hep_DIR}/cmake/MakeGaudiMap.cmake)
-
-  #add_custom_command(OUTPUT ${rootmapfile}
-  #                   COMMAND ${CMAKE_COMMAND} -Dlibname=${libname} -Drootmapfile=${rootmapfile}
-  #                           -Dgenmap_install_dir=${LIBRARY_OUTPUT_PATH}
-  #                           -DROOT_VERSION=${ROOT_VERSION}
-  #                           -DDD4hep_DIR=${DD4hep_DIR}
-  #                           -P ${DD4hep_DIR}/cmake/MakeRootMap.cmake
-  #                   DEPENDS ${library})
-  ##add_custom_target(${library}Rootmap ALL DEPENDS ${rootmapfile})
-
+  add_custom_target(Components_${library} ALL DEPENDS ${rootmapfile})
   SET( install_destination "lib" )
   if( CMAKE_INSTALL_LIBDIR )
     SET( install_destination ${CMAKE_INSTALL_LIBDIR} )
diff --git a/cmake/DD4hepConfig.cmake.in b/cmake/DD4hepConfig.cmake.in
index d2f498ca7..284f91adf 100644
--- a/cmake/DD4hepConfig.cmake.in
+++ b/cmake/DD4hepConfig.cmake.in
@@ -54,7 +54,7 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
 endif()
 
 
-FIND_PACKAGE(Boost REQUIRED)
+FIND_PACKAGE(Boost REQUIRED COMPONENTS filesystem system)
 SET_TARGET_PROPERTIES(Boost::boost
   PROPERTIES
   INTERFACE_COMPILE_DEFINITIONS BOOST_SPIRIT_USE_PHOENIX_V3
diff --git a/cmake/MakeGaudiMap.cmake b/cmake/MakeGaudiMap.cmake
index f56058823..fd5c7d13b 100644
--- a/cmake/MakeGaudiMap.cmake
+++ b/cmake/MakeGaudiMap.cmake
@@ -2,7 +2,8 @@ message(STATUS " *** Gaudi listcomponents: Generate map for ${libname} ..." )
   #
   #  Running listcomponents from Gaudi
   #   
-  FIND_PROGRAM( Gaudi_listcomponents_CMD listcomponents PATHS ${genmap_install_dir}/../bin ${DD4hep_DIR}/bin )
+  FIND_PROGRAM( Gaudi_listcomponents_CMD listcomponents PATHS ${genmap_install_dir}/../bin ${DD4hep_DIR}/bin
+    NO_DEFAULT_PATH NO_CMAKE_PATH)
   ###MESSAGE( STATUS " *** MakeRootMap ${genmap_install_dir}/../bin $ENV{DD4hep_DIR}/bin ${DD4hep_DIR}" )
   MESSAGE( STATUS " *** MakeGaudiMap.cmake run command : ${Gaudi_listcomponents_CMD} -o ${rootmapfile} ${libname}
                  WORKING_DIRECTORY ${genmap_install_dir} "
@@ -12,7 +13,6 @@ message(STATUS " *** Gaudi listcomponents: Generate map for ${libname} ..." )
     ##EXECUTE_PROCESS( COMMAND echo DYLD_LIBRARY_PATH = $ENV{DYLD_LIBRARY_PATH} )
   else()
     SET ( ENV{LD_LIBRARY_PATH} ${genmap_install_dir}:$ENV{LD_LIBRARY_PATH} )
-    #SET ( ENV{LD_PRELOAD} /lib64/libglapi.so )
   endif()
   # EXECUTE_PROCESS( COMMAND echo LD_LIBRARY_PATH = $ENV{LD_LIBRARY_PATH} )
   EXECUTE_PROCESS( COMMAND 
-- 
GitLab