From 9dad6a85d962c0e0d65c7e3ace4290371f301beb Mon Sep 17 00:00:00 2001
From: Markus Frank <markus.frank@cern.ch>
Date: Wed, 20 Feb 2013 15:16:50 +0000
Subject: [PATCH] Support for rootmaps

---
 DDCore/src/StandardPlugins.cpp | 50 ++++++++++++++++++++++++++++++++++
 cmake/DD4hep.cmake             | 33 ++++++++++++++++++++++
 2 files changed, 83 insertions(+)
 create mode 100644 DDCore/src/StandardPlugins.cpp
 create mode 100644 cmake/DD4hep.cmake

diff --git a/DDCore/src/StandardPlugins.cpp b/DDCore/src/StandardPlugins.cpp
new file mode 100644
index 000000000..aa8b0af37
--- /dev/null
+++ b/DDCore/src/StandardPlugins.cpp
@@ -0,0 +1,50 @@
+// $Id:$
+//====================================================================
+//  AIDA Detector description implementation for LCD
+//--------------------------------------------------------------------
+//
+//  Standard plugins necessary for nearly everything.
+// 
+//  Author     : M.Frank
+//
+//====================================================================
+
+// Framework include files
+#include "DD4hep/Factories.h"
+#include "DD4hep/LCDD.h"
+// ROOT includes
+#include "TGeoManager.h"
+#include "TGeoVolume.h"
+
+using namespace std;
+using namespace DD4hep::Geometry;
+
+static long display(LCDD& /* lcdd */,int argc,char** argv)    {
+  TGeoManager* mgr = gGeoManager;
+  const char* opt = "ogl";
+  if ( argc > 0 )   {
+    opt = argv[0];
+  }
+  if ( mgr ) {
+    mgr->SetVisLevel(4);
+    mgr->SetVisOption(1);
+    TGeoVolume* vol = mgr->GetTopVolume();
+    if ( vol ) {
+      vol->Draw(opt);
+      return 1;
+    }
+  }
+  return 0;
+}
+DECLARE_APPLY(DD4hepGeometryDisplay,display);
+
+static long load_compact(LCDD& lcdd,int argc,char** argv)    {
+  for(size_t j=0; j<argc; ++j) {
+    string input = argv[j];
+    cout << "Processing compact input file : " << input << endl;
+    lcdd.fromCompact(input);
+  }
+  return 1;
+}
+DECLARE_APPLY(DD4hepCompactLoader,load_compact);
+
diff --git a/cmake/DD4hep.cmake b/cmake/DD4hep.cmake
new file mode 100644
index 000000000..4b101c910
--- /dev/null
+++ b/cmake/DD4hep.cmake
@@ -0,0 +1,33 @@
+#---------------------------------------------------------------------------------------------------
+# dd4hep_generate_rootmap(library)
+#
+# Create the .rootmap file needed by the plug-in system.
+#---------------------------------------------------------------------------------------------------
+function(dd4hep_generate_rootmap library)
+  find_package(ROOT QUIET)
+  set(rootmapfile ${CMAKE_SHARED_MODULE_PREFIX}${library}.rootmap)
+
+  set(libname ${CMAKE_SHARED_MODULE_PREFIX}${library}${CMAKE_SHARED_MODULE_SUFFIX})
+  add_custom_command(OUTPUT ${rootmapfile}
+                     COMMAND cd ${LIBRARY_OUTPUT_PATH} && genmap
+		             ${ROOT_genmap_CMD} -i ${libname} -o ${rootmapfile}
+                     DEPENDS ${library})
+  add_custom_target(${library}Rootmap ALL DEPENDS ${rootmapfile})
+  # Notify the project level target
+  #gaudi_merge_files_append(Rootmap ${library}Rootmap ${CMAKE_CURRENT_BINARY_DIR}/${library}.rootmap)
+endfunction()
+
+#---------------------------------------------------------------------------------------------------
+# dd4hep_install_library(library)
+#
+# Install library
+#---------------------------------------------------------------------------------------------------
+function(dd4hep_install_library library)
+  set(installfile ${library}.install)
+  set(libname ${CMAKE_SHARED_MODULE_PREFIX}${library}${CMAKE_SHARED_MODULE_SUFFIX})
+  add_custom_command(OUTPUT ${rootmapfile}
+                     COMMAND echo
+		             ${library} ${LIBRARY_OUTPUT_DIR}
+                     DEPENDS ${library})
+  add_custom_target(${library}Install ALL DEPENDS ${installfile})
+endfunction()
-- 
GitLab