From 8cc279570ba99a42ead32adf9a070957ea253687 Mon Sep 17 00:00:00 2001
From: Ben Couturier <ben.couturier@cern.ch>
Date: Mon, 21 Sep 2020 12:05:18 +0200
Subject: [PATCH] Modified DDEve to only build WebDisplay when ROOT7 Eve is
 available

---
 DDEve/CMakeLists.txt                | 12 +++++++++---
 DDEve/{src => root7}/WebDisplay.cpp |  0
 UtilityApps/CMakeLists.txt          |  9 ++++++---
 3 files changed, 15 insertions(+), 6 deletions(-)
 rename DDEve/{src => root7}/WebDisplay.cpp (100%)

diff --git a/DDEve/CMakeLists.txt b/DDEve/CMakeLists.txt
index 255e350d8..9f865d1d2 100644
--- a/DDEve/CMakeLists.txt
+++ b/DDEve/CMakeLists.txt
@@ -17,7 +17,7 @@ target_include_directories(DDEve_Interface
   $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
   $<INSTALL_INTERFACE:include>
 )
-target_link_libraries(DDEve_Interface INTERFACE ROOT::Core ROOT::Rint ROOT::Eve ROOT::Gui ROOT::Graf3d ROOT::RGL ROOT::EG ROOT::ROOTEve)
+target_link_libraries(DDEve_Interface INTERFACE ROOT::Core ROOT::Rint ROOT::Eve ROOT::Gui ROOT::Graf3d ROOT::RGL ROOT::EG)
 
 dd4hep_add_dictionary(G__DDEve
   SOURCES ../DDCore/include/ROOT/Warnings.h include/DDEve/*.h
@@ -29,14 +29,20 @@ dd4hep_add_dictionary(G__DDEve
   USES DD4hep::DDCore
   )
 
+if(TARGET ROOT::ROOTEve)
+  dd4hep_print("Building the web display using ROOT7")
+  SET(DDEVE_ROOT7_SOURCES root7/WebDisplay.cpp)
+  SET(DDEVE_ROOT7_LINK ROOT::ROOTEve)
+endif()
+
 if(TARGET LCIO::LCIO)
   SET(DDEVE_LCIO_SOURCES lcio/LCIOEventHandler.cpp)
   SET(DDEVE_LCIO_LINK LCIO::LCIO)
 endif()
 
-dd4hep_add_plugin(DDEvePlugins SOURCES src/*.cpp ${DDEVE_LCIO_SOURCES}
+dd4hep_add_plugin(DDEvePlugins SOURCES src/*.cpp ${DDEVE_LCIO_SOURCES} ${DDEVE_ROOT7_SOURCES}
   GENERATED G__DDEve.cxx
-  USES      DD4hep::DDCore DD4hep::DDEve_Interface ${DDEVE_LCIO_LINK}
+  USES      DD4hep::DDCore DD4hep::DDEve_Interface ${DDEVE_LCIO_LINK} ${DDEVE_ROOT7_LINK}
   )
 
 if(DD4HEP_USE_GEANT4)
diff --git a/DDEve/src/WebDisplay.cpp b/DDEve/root7/WebDisplay.cpp
similarity index 100%
rename from DDEve/src/WebDisplay.cpp
rename to DDEve/root7/WebDisplay.cpp
diff --git a/UtilityApps/CMakeLists.txt b/UtilityApps/CMakeLists.txt
index 6fcdac99f..d68277a78 100644
--- a/UtilityApps/CMakeLists.txt
+++ b/UtilityApps/CMakeLists.txt
@@ -13,9 +13,6 @@ SET_PROPERTY(DIRECTORY . PROPERTY PACKAGE_NAME UtilityApps)
 add_executable(geoDisplay src/display.cpp)
 target_link_libraries(geoDisplay DD4hep::DDCore)
 #-----------------------------------------------------------------------------------
-add_executable(geoWebDisplay src/webdisplay.cpp)
-target_link_libraries(geoWebDisplay DD4hep::DDCore)
-#-----------------------------------------------------------------------------------
 add_executable(geoConverter src/converter.cpp)
 target_link_libraries(geoConverter DD4hep::DDCore)
 #-----------------------------------------------------------------------------------
@@ -44,6 +41,12 @@ if(TARGET Geant4::Interface)
   LIST(APPEND OPTIONAL_EXECUTABLES dumpdetector)
 endif()
 
+# the web display tool depends on the ROOT7 version of DDEve
+if(TARGET ROOT::ROOTEve)
+  add_executable(geoWebDisplay src/webdisplay.cpp)
+  target_link_libraries(geoWebDisplay DD4hep::DDCore)
+endif()
+
 # #-----------------------------------------------------------------------------------
 if(BUILD_TESTING)
   if(DD4HEP_USE_LCIO)
-- 
GitLab