From 2a6c6773afa90c14c9aab59af3d89e1270068ebf Mon Sep 17 00:00:00 2001
From: Whitney Armstrong <warmstrong@anl.gov>
Date: Wed, 6 Dec 2017 10:29:44 -0600
Subject: [PATCH] Added proper library check for npdet_to_step 	modified:  
 CMakeLists.txt 	modified:   src/npdet_to_step.cxx

---
 src/tools/CMakeLists.txt        | 35 +++++++++++++++++++++------------
 src/tools/src/npdet_to_step.cxx |  5 ++---
 2 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt
index e38b2a77..71571f3f 100644
--- a/src/tools/CMakeLists.txt
+++ b/src/tools/CMakeLists.txt
@@ -10,25 +10,34 @@ find_package( DD4hep REQUIRED COMPONENTS DDCore DDG4 )
 find_package(ROOT REQUIRED COMPONENTS Geom GenVector MathCore)
 include(${ROOT_USE_FILE})
 
-set(exe_name npdet_to_step)
 
+set(exe_name npdet_fields)
 add_executable(${exe_name} src/${exe_name}.cxx)
-
 target_include_directories(${exe_name} PUBLIC
-    PRIVATE include
-    )
-
+  PRIVATE include )
 target_compile_features(${exe_name}
+  PUBLIC cxx_auto_type
+  PUBLIC cxx_trailing_return_types
+  PRIVATE cxx_variadic_templates )
+target_link_libraries(${exe_name} PUBLIC DDCore DDG4 ROOT::Core ROOT::Hist ROOT::GenVector ROOT::Gpad)
+install(TARGETS ${exe_name}
+  EXPORT NPDetTargets
+  RUNTIME DESTINATION bin )
+
+
+# npdet_to_step needs ROOT's GeoCad library
+if(TARGET ROOT::GeoCad)
+  set(exe_name npdet_to_step)
+  add_executable(${exe_name} src/${exe_name}.cxx)
+  target_include_directories(${exe_name} PUBLIC
+    PRIVATE include )
+  target_compile_features(${exe_name}
     PUBLIC cxx_auto_type
     PUBLIC cxx_trailing_return_types
-    PRIVATE cxx_variadic_templates
-    )
-
+    PRIVATE cxx_variadic_templates )
   target_link_libraries(${exe_name} PUBLIC DDCore DDG4 ROOT::Core ROOT::Hist ROOT::GenVector ROOT::Gpad ROOT::GeoCad)
-
-install(TARGETS ${exe_name}
+  install(TARGETS ${exe_name}
     EXPORT NPDetTargets
-    RUNTIME DESTINATION bin
-    )
-
+    RUNTIME DESTINATION bin )
+endif(TARGET ROOT::GeoCad)
 
diff --git a/src/tools/src/npdet_to_step.cxx b/src/tools/src/npdet_to_step.cxx
index faa1cd5a..09ce8865 100644
--- a/src/tools/src/npdet_to_step.cxx
+++ b/src/tools/src/npdet_to_step.cxx
@@ -161,9 +161,8 @@ int main (int argc, char *argv[]) {
   detector.fromCompact(s.infile);
 
   TGeoToStep * mygeom= new TGeoToStep( &(detector.manager()) );
-  //mygeom->CreateGeometry();
-  detector.manager().Export("geometry.gdml");
-
+  mygeom->CreateGeometry();
+  //detector.manager().Export("geometry.gdml");
   std::cout << "saved as geometry.stp\n";
   return 0;
 } 
-- 
GitLab