From ab71d1c5be9f024e9513c793afacb08d88022672 Mon Sep 17 00:00:00 2001
From: Markus FRANK <Markus.Frank@cern.ch>
Date: Fri, 8 Jan 2021 17:44:42 +0100
Subject: [PATCH] Fix to propagate definitions properly to depending
 compilation units

---
 CMakeLists.txt        | 30 +++++++++++++-----------------
 DDCore/CMakeLists.txt |  4 ++++
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 707b0886b..f4b7b10fe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -67,19 +67,18 @@ ENDIF()
 cmake_host_system_information(RESULT HOST_RAM_MB QUERY TOTAL_PHYSICAL_MEMORY)
 math(EXPR DD4HEP_HIGH_MEM_POOL_DEPTH "${HOST_RAM_MB} / 2000" OUTPUT_FORMAT DECIMAL)
 
-option(DD4HEP_USE_XERCESC       "Enable 'Detector Builders' based on XercesC"   OFF)
-option(DD4HEP_USE_GEANT4        "Enable the simulation part based on Geant4"    OFF)
-option(DD4HEP_IGNORE_GEANT4_TLS "Ignore the tls flag Geant4 was compiled with"  OFF)
-option(DD4HEP_USE_GEAR          "Build gear wrapper for backward compatibility" OFF)
-option(DD4HEP_USE_LCIO          "Build lcio extensions"                         OFF)
-option(DD4HEP_USE_GEANT4_UNITS  "Build using Geant4 units throughout"           OFF)
-option(DD4HEP_USE_EDM4HEP       "Build edm4hep extensions"                      OFF)
-option(DD4HEP_USE_HEPMC3        "Build hepmc3 extensions"                       OFF)
-option(DD4HEP_USE_TBB           "Build features that require TBB"               OFF)
-option(DD4HEP_LOAD_ASSIMP       "Download and build ASSIMP from github"         OFF)
-option(BUILD_TESTING            "Enable and build tests"                        ON)
-option(BUILD_SHARED_LIBS        "If OFF build STATIC Libraries"                 ON)
-option(DD4HEP_SET_RPATH         "Link libraries with built-in RPATH (run-time search path)" ON)
+option(DD4HEP_USE_XERCESC "Enable 'Detector Builders' based on XercesC"   OFF)
+option(DD4HEP_USE_GEANT4  "Enable the simulation part based on Geant4"    OFF)
+option(DD4HEP_IGNORE_GEANT4_TLS "Ignore the tls flag Geant4 was compiled with" OFF)
+option(DD4HEP_USE_GEAR    "Build gear wrapper for backward compatibility" OFF)
+option(DD4HEP_USE_LCIO    "Build lcio extensions"                         OFF)
+option(DD4HEP_USE_EDM4HEP "Build edm4hep extensions"                      OFF)
+option(DD4HEP_USE_HEPMC3  "Build hepmc3 extensions"                       OFF)
+option(DD4HEP_USE_TBB     "Build features that require TBB"               OFF)
+option(DD4HEP_LOAD_ASSIMP "Download and build ASSIMP from github"         OFF)
+option(BUILD_TESTING      "Enable and build tests"                        ON)
+option(BUILD_SHARED_LIBS  "If OFF build STATIC Libraries"                 ON)
+option(DD4HEP_SET_RPATH   "Link libraries with built-in RPATH (run-time search path)" ON)
 
 SET(DD4HEP_BUILD_PACKAGES "DDRec DDDetectors DDCond DDAlign DDCAD DDDigi DDG4 DDEve UtilityApps"
   CACHE STRING "List of DD4hep packages to build")
@@ -206,12 +205,9 @@ ELSE()
     dd4hep_print("|> Building ${DDPackage}")
     add_subdirectory(${DDPackage})
   ENDFOREACH()
-
   IF(DD4HEP_BUILD_DEBUG MATCHES "ON" OR (CMAKE_BUILD_TYPE MATCHES "DEBUG|Debug" AND NOT DD4HEP_BUILD_DEBUG MATCHES "OFF"))
     message(STATUS "BUILD DD4HEP and depending software with debug extensions")
-    set(DD4HEP_BUILD_DEBUG ON)
-  ELSE()
-    set(DD4HEP_BUILD_DEBUG OFF)
+    target_compile_definitions(DDCore PUBLIC DD4HEP_DEBUG=1)
   ENDIF()
 
   message(STATUS "BUILD Packages: ${DD4HEP_BUILD_PACKAGES}")
diff --git a/DDCore/CMakeLists.txt b/DDCore/CMakeLists.txt
index d351cf638..cd36c08a6 100644
--- a/DDCore/CMakeLists.txt
+++ b/DDCore/CMakeLists.txt
@@ -21,6 +21,7 @@ if(${CMAKE_CXX_STANDARD} LESS 17)
   list(FILTER DDCore_SOURCES EXCLUDE REGEX Filter\.cpp|SpecParRegistry\.cpp )
 endif()
 
+# Build the generic DD4hep dictionary
 dd4hep_add_dictionary( G__DD4hep
   SOURCES include/ROOT/Warnings.h
   include/DD4hep/*.h
@@ -44,18 +45,21 @@ dd4hep_add_dictionary( G__DD4hep
   DEFINITIONS DD4HEP_MUST_USE_DETECTORIMP_H
   )
 
+# Build the DD4hep dictionary for all geometry instantiations
 dd4hep_add_dictionary( G__DD4hepGeo
   SOURCES include/ROOT/Warnings.h src/GeoDictionary.h
   LINKDEF include/ROOT/LinkDef.h
   USES DDCore DDParsers ${XML_LIBRARIES}
   )
 
+# Build the DD4hep dictionary for property type instantiations
 dd4hep_add_dictionary( G__DD4hepProperties
   SOURCES include/ROOT/Warnings.h src/PropertyDictionary.h
   LINKDEF include/ROOT/LinkDef.h
   USES DDCore DDParsers ${XML_LIBRARIES}
   )
 
+# Build the DD4hep dictionary for the segmentation instantiations
 dd4hep_add_dictionary( G__DD4hepSegmentations
   SOURCES include/ROOT/Warnings.h src/SegmentationDictionary.h
   LINKDEF include/ROOT/LinkDef.h
-- 
GitLab