From bd3e766794457c4fad1d820c8467f5342be19ba8 Mon Sep 17 00:00:00 2001
From: Andre Sailer <andre.philippe.sailer@cern.ch>
Date: Thu, 17 Oct 2019 11:22:31 +0200
Subject: [PATCH] CMake: behave as before if BUILD_SHARED_LIBS is not defined.
 Needed for examples and DD4hep external packageS

---
 cmake/DD4hepBuild.cmake | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/cmake/DD4hepBuild.cmake b/cmake/DD4hepBuild.cmake
index f5c95aa32..7c6089d97 100644
--- a/cmake/DD4hepBuild.cmake
+++ b/cmake/DD4hepBuild.cmake
@@ -613,11 +613,14 @@ function(dd4hep_add_plugin binary)
   dd4hep_debug("|++++> USES ${ARG_USES}")
   dd4hep_debug("|++++> INCLUDES ${ARG_INCLUDES}")
   dd4hep_debug("|++++> DEFINITIONS ${ARG_DEFINITIONS}")
-  add_library(${binary} ${SOURCES} ${ARG_GENERATED})
+  IF(NOT DEFINED BUILD_SHARED_LIBS)
+    SET(STATIC_OR_SHARED SHARED)
+  ENDIF()
+  add_library(${binary} ${STATIC_OR_SHARED} ${SOURCES} ${ARG_GENERATED})
   target_link_libraries(${binary} PUBLIC ${ARG_USES})
   target_include_directories(${binary} PUBLIC ${ARG_INCLUDES})
   target_compile_definitions(${binary} PUBLIC ${ARG_DEFINITIONS})
-  IF(BUILD_SHARED_LIBS)
+  IF(BUILD_SHARED_LIBS OR NOT DEFINED BUILD_SHARED_LIBS)
     dd4hep_generate_rootmap(${binary})
   ENDIF()
   if(NOT ${ARG_NOINSTALL})
-- 
GitLab