From df6455130d91c3987c7ce59dc51b0fbd16110524 Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Fri, 15 Sep 2023 10:36:26 +0200 Subject: [PATCH] Check if the CLHEP target exists before creating it, if it does warn --- cmake/DD4hepBuild.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/DD4hepBuild.cmake b/cmake/DD4hepBuild.cmake index ab12d75a7..bcd3407f7 100644 --- a/cmake/DD4hepBuild.cmake +++ b/cmake/DD4hepBuild.cmake @@ -826,7 +826,11 @@ MACRO(DD4HEP_SETUP_GEANT4_TARGETS) if(Geant4_builtin_clhep_FOUND) dd4hep_debug("Using Geant4 internal CLHEP") - ADD_LIBRARY(CLHEP::CLHEP INTERFACE IMPORTED GLOBAL) + if(TARGET CLHEP::CLHEP) + message(WARNING "CLHEP::CLHEP already exists, this may cause problems if there are two different installations of CLHEP, one from Geant4 and one external") + else() + ADD_LIBRARY(CLHEP::CLHEP INTERFACE IMPORTED GLOBAL) + endif() SET_TARGET_PROPERTIES(CLHEP::CLHEP PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${Geant4_INCLUDE_DIRS}"