From e65c88fdd159fa8cb4e365c7f723d6183c74ad2a Mon Sep 17 00:00:00 2001
From: Markus Frank <markus.frank@cern.ch>
Date: Fri, 13 Nov 2015 14:19:09 +0000
Subject: [PATCH] Fix rootmap and env-check problems on MAC

---
 cmake/DD4hep.cmake      | 3 ++-
 cmake/DD4hepBuild.cmake | 3 ++-
 cmake/MakeRootMap.cmake | 4 ++--
 cmake/thisdd4hep.sh     | 8 ++++----
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/cmake/DD4hep.cmake b/cmake/DD4hep.cmake
index 803086169..dd7231fbc 100644
--- a/cmake/DD4hep.cmake
+++ b/cmake/DD4hep.cmake
@@ -112,11 +112,12 @@ else()
 endif()
 
   set(libname ${CMAKE_SHARED_MODULE_PREFIX}${library}${CMAKE_SHARED_LIBRARY_SUFFIX})
-
+message(STATUS "DD4hep_DIR = ${DD4hep_DIR}" )
   add_custom_command(OUTPUT ${rootmapfile}
                      COMMAND ${CMAKE_COMMAND} -Dlibname=${libname} -Drootmapfile=${rootmapfile}
                              -Dgenmap_install_dir=${LIBRARY_OUTPUT_PATH}
                              -DROOT_VERSION_MAJOR=${ROOT_VERSION_MAJOR}
+                             -DDD4hep_DIR=${DD4hep_DIR}
                              -P ${DD4hep_DIR}/cmake/MakeRootMap.cmake
                      DEPENDS ${library})
 
diff --git a/cmake/DD4hepBuild.cmake b/cmake/DD4hepBuild.cmake
index 823139f8b..37e86396e 100644
--- a/cmake/DD4hepBuild.cmake
+++ b/cmake/DD4hepBuild.cmake
@@ -15,6 +15,7 @@ cmake_minimum_required(VERSION 2.8.3 FATAL_ERROR)
 message ( STATUS "INCLUDING DD4hepBuild...." )
 include ( CMakeParseArguments )
 set ( DD4hepBuild_included ON )
+####set ( DD4HEP_DEBUG_CMAKE ON )
 
 #---------------------------------------------------------------------------------------------------
 macro(dd4hep_to_parent_scope val)
@@ -574,7 +575,7 @@ function ( dd4hep_handle_optional_sources tag optionals missing uses sources )
     dd4hep_find_package( ${USE_NAME} pkg_found 
       ARGS ${USE_REQUIRED} ${USE_COMPONENT} ${USE_COMPONENTS} 
       TYPE ${USE_TYPE} )
-    if ( "{pkg_found}" STREQUAL "OFF" )
+    if ( "${pkg_found}" STREQUAL "OFF" )
       dd4hep_print ( "|    ${tag}  ...optional: Skip sources ${USE_SOURCES} [requires ${USE_NAME}]" )
     elseif ( "${pkg_found}" STREQUAL "ON" )
       dd4hep_print ( "|    ${tag}  ...optional: ADD sources ${USE_SOURCES} [dependent on ${USE_NAME}]" )
diff --git a/cmake/MakeRootMap.cmake b/cmake/MakeRootMap.cmake
index 1753b7a30..47c6b621b 100644
--- a/cmake/MakeRootMap.cmake
+++ b/cmake/MakeRootMap.cmake
@@ -3,7 +3,8 @@ if( ${ROOT_VERSION_MAJOR} GREATER 5 )
   #
   #  Running listcomponents from Gaudi
   #
-  FIND_PROGRAM( ROOT_genmap_CMD listcomponents PATHS ${genmap_install_dir}/../bin )
+  FIND_PROGRAM( ROOT_genmap_CMD listcomponents PATHS ${genmap_install_dir}/../bin ${DD4hep_DIR}/bin )
+  ###MESSAGE( STATUS " *** MakeROOTMap ${genmap_install_dir}/../bin $ENV{DD4hep_DIR}/bin ${DD4hep_DIR}" )
   MESSAGE( STATUS " *** MakeROOTMap[components].cmake run command : ${ROOT_genmap_CMD} -o ${rootmapfile} ${libname} 
                  WORKING_DIRECTORY ${genmap_install_dir} "
     )  
@@ -23,7 +24,6 @@ else()
   #  Running genmap from ROOT 5
   #
   FIND_PROGRAM( ROOT_genmap_CMD genmap PATHS $ENV{ROOTSYS}/bin $ENV{PATH} )
-
   MESSAGE( STATUS " *** MakeROOTMap.cmake run command : ${ROOT_genmap_CMD} -debug -i ${libname} -o ${rootmapfile}
                  WORKING_DIRECTORY ${genmap_install_dir} "
     )
diff --git a/cmake/thisdd4hep.sh b/cmake/thisdd4hep.sh
index 3db3902af..6095e76a7 100644
--- a/cmake/thisdd4hep.sh
+++ b/cmake/thisdd4hep.sh
@@ -73,7 +73,7 @@ ROOTENV_INIT=${ROOTSYS}/bin/thisroot.sh;
 test -r ${ROOTENV_INIT} && { cd $(dirname ${ROOTENV_INIT}); . ./$(basename ${ROOTENV_INIT}) ; cd $OLDPWD ; }
 #
 #----Geant4 LIBRARY_PATH------------------------------------------------------
-if [ ${Geant4_DIR ]; then
+if [ ${Geant4_DIR} ]; then
     G4LIB_DIR=`dirname ${Geant4_DIR}`;
     export G4INSTALL=`dirname ${G4LIB_DIR}`;
     export G4ENV_INIT=${G4INSTALL}/bin/geant4.sh
@@ -82,14 +82,14 @@ if [ ${Geant4_DIR ]; then
     #---- if geant4 was built with external CLHEP we have to extend the dynamic search path
     if [ @GEANT4_USE_CLHEP@ ] ; then
 	dd4hep_add_library_path @CLHEP_LIBRARY_PATH@;
-    fi
+    fi;
     dd4hep_add_library_path ${G4LIB_DIR};
     unset G4ENV_INIT;
     unset G4LIB_DIR;
-fi
+fi;
 #
 #----XercesC LIBRARY_PATH-----------------------------------------------------
-if test [ $XERCESCINSTALL ]; then
+if [ ${XERCESCINSTALL} ]; then
     #dd4hep_add_path    PATH ${XERCESCINSTALL}/bin;
     dd4hep_add_library_path ${XERCESCINSTALL}/lib;
 fi;
-- 
GitLab