diff --git a/CMakeLists.txt b/CMakeLists.txt index adafb71444b902d80605e0e4c0cc3dd335d8d2bf..6938459e4493c0ef52a75fb849b20219687119a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,25 +88,38 @@ dd4hep_configure_output( OUTPUT "${PROJECT_BINARY_DIR}" INSTALL "${CMAKE_INSTALL ######################## # Configure ROOT -find_package ( ROOT 6.08 REQUIRED COMPONENTS Geom GenVector Eve Gui Graf3d RGL EG) -include(${ROOT_USE_FILE}) -message ( STATUS "ROOT_VERSION: ${ROOT_VERSION}" ) +find_package(ROOT 6.08 REQUIRED) # COMPONENTS Geom GenVector Eve Gui Graf3d RGL EG +#include(${ROOT_USE_FILE}) -# Configure BOOST -find_package( Boost 1.49 REQUIRED ) -add_definitions( -DBOOST_SPIRIT_USE_PHOENIX_V3 ) -set ( ENV{Boost_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ) -# Configure Geant4 -if(DD4HEP_USE_GEANT4) - find_package( Geant4 10.2.2 REQUIRED gdml ui_all vis_all ) - include( ${Geant4_USE_FILE} ) +ADD_LIBRARY(ROOT::Base SHARED IMPORTED GLOBAL) - IF((NOT ${Geant4_TLS_MODEL} STREQUAL "global-dynamic") AND NOT ${DD4HEP_IGNORE_GEANT4_TLS}) - MESSAGE(FATAL_ERROR "Geant4 was built with ${Geant4_TLS_MODEL}, DD4hep requires 'global-dynamic'! Ignore this ERROR with DD4HEP_IGNORE_GEANT4_TLS=True ") - ENDIF() +#ROOT CXX Flags are a string with quotes, not a list, so we need to convert to a list... +string(REPLACE " " ";" ROOT_CXX_FLAGS ${ROOT_CXX_FLAGS}) + + +SET_TARGET_PROPERTIES(ROOT::Base + PROPERTIES + INTERFACE_LINK_LIBRARIES "${ROOT_LIBRARIES}" + INTERFACE_COMPILE_OPTIONS "${ROOT_CXX_FLAGS}" + INTERFACE_INCLUDE_DIRECTORIES ${ROOT_INCLUDE_DIRS} + IMPORTED_LOCATION ${ROOT_LIBRARIES} + ) + +MESSAGE(STATUS "ROOT Libraries ${ROOT_LIBRARIES}") +MESSAGE(STATUS "ROOT CXX_FLAGS ${ROOT_CXX_FLAGS}") +MESSAGE(STATUS "ROOT INCL DIRS ${ROOT_INCLUDE_DIRS}") +MESSAGE(STATUS "ROOT_VERSION: ${ROOT_VERSION}" ) + +# Configure BOOST +find_package(Boost 1.49 REQUIRED filesystem system) + +SET_TARGET_PROPERTIES(Boost::boost + PROPERTIES + INTERFACE_COMPILE_DEFINITIONS BOOST_SPIRIT_USE_PHOENIX_V3 + ) +#add_definitions( -DBOOST_SPIRIT_USE_PHOENIX_V3 ) -endif() ###################### # Set compiler flags # @@ -135,19 +148,13 @@ add_subdirectory(DDDetectors) add_subdirectory(DDCond) add_subdirectory(DDAlign) add_subdirectory(DDDigi) -if ( DD4HEP_USE_GEANT4 ) - if(Geant4_builtin_clhep_FOUND) - set(CLHEP "") - else() - set(CLHEP CLHEP) - endif() - add_subdirectory(DDG4) -endif() +add_subdirectory(DDG4) + # Note the order: DDEve partially depends on variables from DDG4! -add_subdirectory(DDEve) +#add_subdirectory(DDEve) -dd4hep_enable_tests( DDTest ) -add_subdirectory(UtilityApps) +# dd4hep_enable_tests( DDTest ) +# add_subdirectory(UtilityApps) ####################### # Treatment for Apple # @@ -187,7 +194,7 @@ display_std_variables() # generate and install following configuration files # ###################################################### -dd4hep_generate_package_configuration_files( DD4hepConfig.cmake ) +#dd4hep_generate_package_configuration_files( DD4hepConfig.cmake ) if(APPLE) SET ( ENV{DD4HEP_LIBRARY_PATH} $ENV{DYLD_LIBRARY_PATH} ) else() @@ -203,3 +210,9 @@ if(APPLE) fill_dd4hep_library_path() message(STATUS "DD4HEP_LIBRARY_PATH= $ENV{DD4HEP_LIBRARY_PATH}") endif() + + +INSTALL(EXPORT DD4hep + NAMESPACE DD4hep:: + DESTINATION ${CMAKE_INSTALL_PREFIX} + FILE DD4hepConfig.cmake) \ No newline at end of file diff --git a/DDAlign/CMakeLists.txt b/DDAlign/CMakeLists.txt index 8d4a0ad77535b8405d1feade033936fbc1ca895a..9f5d4382be84a1352dcf4be14ac7334417d7bb1f 100644 --- a/DDAlign/CMakeLists.txt +++ b/DDAlign/CMakeLists.txt @@ -8,13 +8,25 @@ # For the list of contributors see $DD4hepINSTALL/doc/CREDITS. # #========================================================================== -dd4hep_package( DDAlign - USES DDCore - INCLUDE_DIRS include - INSTALL_INCLUDES include/DDAlign) -#---DDCond library -------------------------------------------------------------- -dd4hep_add_package_library(DDAlign SOURCES src/*.cpp ) +file(GLOB DDAlign_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) -#---DDAlign plugins ------------------------------------------------------------- -dd4hep_add_plugin(DDAlignPlugins SOURCES src/plugins/*.cpp ) +add_library(DDAlign SHARED ${DDAlign_SOURCES} ) + +target_include_directories(DDAlign + PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/> + $<INSTALL_INTERFACE:include> + ) + +target_link_libraries(DDAlign + PUBLIC + DDCore + ) + +new_dd4hep_add_plugin(DDAlignPlugins + SOURCES src/plugins/*.cpp + LINK_LIBRARIES DDAlign + ) + +INSTALL(TARGETS DDAlign EXPORT DD4hep DESTINATION lib) diff --git a/DDCond/CMakeLists.txt b/DDCond/CMakeLists.txt index 94117c201fe52baf099661a6893e2ce84e04df2a..4c3ebf53df174a81c5ed151548c26b446d7046f3 100644 --- a/DDCond/CMakeLists.txt +++ b/DDCond/CMakeLists.txt @@ -8,23 +8,36 @@ # For the list of contributors see $DD4hepINSTALL/doc/CREDITS. # #========================================================================== -dd4hep_package( DDCond - USES DDCore BOOST - INCLUDE_DIRS include - INSTALL_INCLUDES include/DDCond) - #---Generate ROOT dictionary----------------------------------------------------- -dd4hep_add_dictionary( G__DDCond - SOURCES include/ROOT/Warnings.h - src/ConditionsDictionary.h - LINKDEF include/ROOT/LinkDef.h + +#find_package (ROOT 6.08 REQUIRED COMPONENTS Geom GenVector Eve Gui Graf3d RGL EG) # COMPONENTS Geom GenVector Eve Gui Graf3d RGL EG +new_dd4hep_add_dictionary( G__DDCond + SOURCES src/ConditionsDictionary.h + DEPENDS DDCore DDParsers ) +file(GLOB DDCond_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) +MESSAGE(STATUS "DDCond_SOURCES ${DDCond_SOURCES}") #---DDCond library -------------------------------------------------------------- -dd4hep_add_package_library(DDCond - SOURCES src/*.cpp - GENERATED G__DDCond.cxx +add_library(DDCond SHARED ${DDCond_SOURCES} + G__DDCond.cxx + ) + +target_link_libraries(DDCond + PUBLIC + DDCore ) +target_include_directories(DDCond + PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/> + $<INSTALL_INTERFACE:include> + ) + + #---DDCond components ----------------------------------------------------------- -dd4hep_add_plugin(DDCondPlugins SOURCES src/plugins/*.cpp src/Type1/*.cpp ) +new_dd4hep_add_plugin(DDCondPlugins + SOURCES src/plugins/*.cpp src/Type1/*.cpp + LINK_LIBRARIES DDCond) + +INSTALL(TARGETS DDCond EXPORT DD4hep DESTINATION lib) \ No newline at end of file diff --git a/DDCore/CMakeLists.txt b/DDCore/CMakeLists.txt index 013d7947444c5abcebd978796814f5a215de8792..3361b4ee55ff0db7970630935341d52c53a6cc60 100644 --- a/DDCore/CMakeLists.txt +++ b/DDCore/CMakeLists.txt @@ -9,20 +9,14 @@ # For the list of contributors see $DD4hepINSTALL/doc/CREDITS. # #================================================================================= -dd4hep_package( DDCore - USES DDParsers - [ROOT REQUIRED COMPONENTS Geom GenVector] - OPTIONAL XERCESC - INCLUDE_DIRS include - INSTALL_INCLUDES include/DDSegmentation - include/DD4hep - include/XML - include/JSON - include/Parsers - include/ROOT) +SET(PACKAGE DDCore) + +# Find again to fill ROOT_LIBRARIES with components +find_package (ROOT 6.08 REQUIRED COMPONENTS Geom GenVector) +MESSAGE(STATUS "ROOT COMPONENTS ${ROOT_LIBRARIES}") #---Generate ROOT dictionary------------------------------------------------------ -dd4hep_add_dictionary( G__DD4hep +new_dd4hep_add_dictionary( G__DD4hep SOURCES include/ROOT/Warnings.h include/DD4hep/*.h include/DD4hep/detail/*.h @@ -39,51 +33,107 @@ dd4hep_add_dictionary( G__DD4hep include/XML/UnicodeValues.h include/XML/tinyxml.h include/XML/tinystring.h - LINKDEF include/ROOT/LinkDef.h ) + LINKDEF include/ROOT/LinkDef.h + DEPENDS DDParsers ${XML_LIBRARIES} + ) -#---Generate ROOT dictionary------------------------------------------------------ -dd4hep_add_dictionary( G__DD4hepGeo - SOURCES include/ROOT/Warnings.h - src/GeoDictionary.h - LINKDEF include/ROOT/LinkDef.h ) +new_dd4hep_add_dictionary( G__DD4hepGeo + SOURCES include/ROOT/Warnings.h src/GeoDictionary.h + LINKDEF include/ROOT/LinkDef.h + DEPENDS DDParsers ${XML_LIBRARIES} + ) -#---Generate ROOT dictionary------------------------------------------------------ -dd4hep_add_dictionary( G__DD4hepProperties - SOURCES include/ROOT/Warnings.h - src/PropertyDictionary.h - LINKDEF include/ROOT/LinkDef.h ) +new_dd4hep_add_dictionary( G__DD4hepProperties + SOURCES include/ROOT/Warnings.h src/PropertyDictionary.h + LINKDEF include/ROOT/LinkDef.h + DEPENDS DDParsers ${XML_LIBRARIES} + ) -#---Generate ROOT dictionary------------------------------------------------------ -dd4hep_add_dictionary( G__DD4hepSegmentations - SOURCES include/ROOT/Warnings.h - src/SegmentationDictionary.h - LINKDEF include/ROOT/LinkDef.h ) - -#---Generate DDCore Library------------------------------------------------------- -dd4hep_add_package_library ( DDCore - SOURCES src/*.cpp src/segmentations/*.cpp src/XML/*.cpp - OPTIONAL [BOOST SOURCES src/JSON/*.cpp] - GENERATED G__DD4hep.cxx - G__DD4hepProperties.cxx +new_dd4hep_add_dictionary( G__DD4hepSegmentations + SOURCES include/ROOT/Warnings.h src/SegmentationDictionary.h + LINKDEF include/ROOT/LinkDef.h + DEPENDS DDParsers ${XML_LIBRARIES} + ) + +file(GLOB DDCore_SOURCES src/*.cpp src/segmentations/*.cpp src/XML/*.cpp) +if(Boost_FOUND) + file(GLOB DDCore_BOOST_SOURCES src/JSON/*.cpp) +endif() + +add_library(DDCore SHARED ${DDCore_SOURCES} ${DDCore_BOOST_SOURCES} + G__DD4hep.cxx G__DD4hepSegmentations.cxx + G__DD4hepProperties.cxx G__DD4hepGeo.cxx - INCLUDE_DIRS ${GaudiPluginService_INCLUDE_DIRS} - LINK_LIBRARIES DDParsers ${GaudiPluginService_LIBRARIES} ) -# Generate DDCore plugins--------------------------------------------------------- -dd4hep_add_plugin ( DDCorePlugins SOURCES src/plugins/*.cpp ) +target_include_directories(DDCore + PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/> + $<INSTALL_INTERFACE:include> + ) + +MESSAGE(STATUS "ROOT COMPONENTS ${ROOT_LIBRARIES}") + +target_link_libraries(DDCore + PUBLIC + DD4hepGaudiPluginMgr + DDParsers + ROOT::Base + ${ROOT_LIBRARIES} # to include the ROOT components + ${XML_LIBRARIES} # XercesC or not + ) + +TARGET_COMPILE_FEATURES(DDCore + PUBLIC cxx_alignof + #cxx_std_${CMAKE_CXX_STANDARD} # Needs cmake 3.8 + ) + +#FIXME: install header file folders +# dd4hep_package( DDCore +# USES [ROOT REQUIRED COMPONENTS Geom GenVector] +# DDParsers +# OPTIONAL XERCESC +# INCLUDE_DIRS include +# INSTALL_INCLUDES include/DDSegmentation +# include/DD4hep +# include/XML +# include/JSON +# include/Parsers +# include/ROOT ) + +# # Generate DDCore plugins--------------------------------------------------------- +new_dd4hep_add_plugin(DDCorePlugins SOURCES src/plugins/*.cpp + LINK_LIBRARIES DDCore) -#--------------------------- Specialized GDML plugin ---------------------------- # This plugins depends on the ROOT GDML readers. Hence, extra library -dd4hep_add_plugin(DDGDMLPlugins - OPTIONAL [ROOT REQUIRED COMPONENTS Gdml SOURCES src/gdml/*.cpp] -) +IF(${ROOT_gdml_FOUND}) + new_dd4hep_add_plugin(DDGDMLPlugins + SOURCES src/gdml/*.cpp + LINK_LIBRARIES DDCore ROOT::Base + ) +ELSE() + MESSAGE(WARN "ROOT does not include GDML, not building DDCore GDML Plugins") +ENDIF() + #--------------------------- Specialized PYTHON plugin ---------------------------- -dd4hep_add_plugin(DDPythonPlugins - OPTIONAL [ROOT REQUIRED COMPONENTS PyROOT SOURCES src/python/*.cpp] -) +IF(ROOT_python_FOUND) + find_package (ROOT 6.08 REQUIRED COMPONENTS PyROOT) + MESSAGE(STATUS "DDpython: ROOT COMPONENTS ${ROOT_LIBRARIES}") + new_dd4hep_add_plugin(DDPythonPlugins + SOURCES src/python/*.cpp + LINK_LIBRARIES DDCore ROOT::Base ${ROOT_LIBRARIES} + ) +ELSE() + MESSAGE(WARN "ROOT does not include PyRoot, not building DDCore DDPython Plugins") +ENDIF() + # # #---Package installation procedure(s) ---------------------------------------------- dd4hep_install_files(FILES python/*.py DESTINATION python) + +INSTALL(TARGETS DDCore EXPORT DD4hep DESTINATION lib) + +#Reset ROOT_LIBRARIES +find_package (ROOT 6.08 REQUIRED) \ No newline at end of file diff --git a/DDDetectors/CMakeLists.txt b/DDDetectors/CMakeLists.txt index fa491430c73dec541698e7240935eef78db08f2f..733fd959af8d70b7907b7680c2dcb1b28781d385 100644 --- a/DDDetectors/CMakeLists.txt +++ b/DDDetectors/CMakeLists.txt @@ -1,5 +1,4 @@ #========================================================================== -# $Id: $ # # AIDA Detector description implementation #-------------------------------------------------------------------------- @@ -17,8 +16,9 @@ # Date: 13/11/2014 # #-------------------------------------------------------------------------- -dd4hep_package( DDDetectors USES DDRec ) -#---Add Plugin Library----------------------------------------------------- -dd4hep_add_plugin ( DDDetectors SOURCES src/*.cpp ) -#---Package installation procedure(s) ------------------------------------- -dd4hep_install_dir ( compact DESTINATION DDDetectors ) + +new_dd4hep_add_plugin(DDDetectors + SOURCES src/*.cpp + LINK_LIBRARIES DDRec + INCLUDE_DIRS include +) diff --git a/DDG4/CMakeLists.txt b/DDG4/CMakeLists.txt index e27e862ab3ac8ef5137a8208287f295416d8359a..327df5f77293305e0a600381151e1fb8c113ada1 100644 --- a/DDG4/CMakeLists.txt +++ b/DDG4/CMakeLists.txt @@ -8,68 +8,164 @@ # For the list of contributors see $DD4hepINSTALL/doc/CREDITS. # #========================================================================== -dd4hep_package( DDG4 - USES DDCore - [GEANT4 REQUIRED COMPONENTS gdml ui_all vis_all] - [ROOT REQUIRED COMPONENTS Geom GenVector RIO] - BOOST - OPTIONAL ${CLHEP} [XercesC QUIET] - INCLUDE_DIRS include - INSTALL_INCLUDES include/DDG4 ) +# configure Geant4 +IF(NOT DD4HEP_USE_GEANT4) + MESSAGE(STATUS "Not Using geant4, not building DDG4") + RETURN() +ENDIF() + + + +find_package(Geant4 10.2.2 REQUIRED gdml ui_all vis_all) +#include( ${Geant4_USE_FILE} ) # do not use the use file, this is not very considerate... + +IF((NOT ${Geant4_TLS_MODEL} STREQUAL "global-dynamic") AND NOT ${DD4HEP_IGNORE_GEANT4_TLS}) + MESSAGE(FATAL_ERROR "Geant4 was built with ${Geant4_TLS_MODEL}, DD4hep requires 'global-dynamic'! Ignore this ERROR with DD4HEP_IGNORE_GEANT4_TLS=True ") +ENDIF() + +if(Geant4_builtin_clhep_FOUND) + set(CLHEP "") +else() + set(CLHEP CLHEP) +endif() + +# dd4hep_package( DDG4 +# USES [GEANT4 REQUIRED COMPONENTS gdml ui_all vis_all] +# [ROOT REQUIRED COMPONENTS Geom GenVector RIO] +# BOOST DDCore +# OPTIONAL ${CLHEP} [XercesC QUIET] +# INCLUDE_DIRS include +# INSTALL_INCLUDES include/DDG4 ) + dd4hep_print ( "|++> CLHEP_LIBRARIES ${CLHEP_LIBRARIES} ${CLHEP_LIBRARY}" ) + #---Add Library--------------------------------------------------------------------- -dd4hep_add_package_library(DDG4 SOURCES src/*.cpp ) +file(GLOB DDG4_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) +add_library(DDG4 SHARED ${DDG4_SOURCES}) +target_link_libraries(DDG4 + PUBLIC + ${Geant4_LIBRARIES} + ${Geant4_COMPONENT_LIBRARIES} + DDCore + ROOT::Base + ) + +#Ensure our own includes come before those of the system +target_include_directories(DDG4 BEFORE + PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/> + $<INSTALL_INTERFACE:include> + $<TARGET_PROPERTY:DDCore,INTERFACE_INCLUDE_DIRECTORIES> +) + +target_include_directories(DDG4 SYSTEM + PUBLIC + ${Geant4_INCLUDE_DIRS} +) + +#Geant4 CXX Flags are a string with quotes, not a list, so we need to convert to a list... +string(REPLACE " " ";" Geant4_Flags ${Geant4_CXX_FLAGS} ${Geant4_CXX_FLAGS_${CMAKE_BUILD_TYPE}}) + +# 10.2.2 at least not in 10.5 (check where it switches) +#Geant4_DEFINITIONS already include -D, we jave to get rid of that +SET(G4_DEF_TEMP "") +foreach(def ${Geant4_DEFINITIONS}) + string(REPLACE "-D" "" def ${def}) + LIST(APPEND G4_DEF_TEMP ${def}) +endforeach() +SET(Geant4_DEFINITIONS ${G4_DEF_TEMP}) +target_compile_options(DDG4 + PUBLIC + ${Geant4_Flags} +) + +target_compile_definitions(DDG4 + PUBLIC + ${Geant4_DEFINITIONS} +) + #--------------------------- Legacy libraries (for Frank) ------------------------- -dd4hep_add_plugin(DDG4Legacy SOURCES legacy/*.cpp) +new_dd4hep_add_plugin(DDG4Legacy SOURCES legacy/*.cpp + LINK_LIBRARIES DDG4 + ) #----------------------------------------------------------------------------------- -dd4hep_add_dictionary( G__DDG4 - SOURCES ${DDCore_INCLUDE_DIRS}/include/ROOT/Warnings.h python/DDG4Dict.C - LINKDEF ${DDCore_INCLUDE_DIRS}/include/ROOT/LinkDef.h +new_dd4hep_add_dictionary( G__DDG4 + SOURCES python/DDG4Dict.C + DEPENDS DDCore DDParsers DDG4 + INCLUDES ${Geant4_INCLUDE_DIRS} + DEFINITIONS ${Geant4_DEFINITIONS} ) #--------------------------- Plugin library for the simulation framework --------- -dd4hep_add_plugin(DDG4Plugins - GENERATED G__DDG4.cxx - SOURCES plugins/*.cpp +new_dd4hep_add_plugin(DDG4Plugins + SOURCES plugins/*.cpp G__DDG4.cxx + LINK_LIBRARIES DDG4 ) #--------------------------- Plugin library for the simulation framework --------- -dd4hep_add_dictionary(G__DDG4Python - SOURCES ${DDCore_INCLUDE_DIRS}/include/ROOT/Warnings.h src/python/DDG4Python.C - LINKDEF ${DDCore_INCLUDE_DIRS}/include/ROOT/LinkDef.h - OPTIONAL [PYTHON REQUIRED] - ) + +FIND_PACKAGE(PythonLibs QUIET) +if(PYTHONLIBS_FOUND) + MESSAGE(STATUS "Python found, creating DDG4Python Dictionary") + new_dd4hep_add_dictionary(G__DDG4Python + SOURCES src/python/DDG4Python.C + DEPENDS DDCore DDParsers DDG4 ROOT::Base + INCLUDES ${Geant4_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS} + DEFINITIONS ${Geant4_DEFINITIONS} + ) + new_dd4hep_add_dictionary(G__DDPython + SOURCES tpython/DDPython.C + INCLUDES ${PYTHON_INCLUDE_DIRS} + ) + if(ROOT_python_FOUND) + FIND_PACKAGE(ROOT REQUIRED COMPONENTS PyROOT) + #--------------------------- Specialized python plugins -------------------------- + MESSAGE(STATUS "ROOT Has Python, creating DDPython library and plugins") + add_library(DDPython SHARED G__DDPython.cxx tpython/DDPython.cpp) + target_link_libraries(DDPython DDG4 ROOT::Base ${PYTHON_LIBRARIES} ${ROOT_LIBRARIES}) + target_include_directories(DDPython PUBLIC ${PYTHON_INCLUDE_DIRS}) + new_dd4hep_add_plugin(DDG4Python + SOURCES src/python/*.cpp G__DDG4Python.cxx + LINK_LIBRARIES DDG4 DDPython + ) + #---Helper to overcome deficiency of the python executable concerning multi-threading + add_executable(pyddg4 pyddg4.cpp) + target_link_libraries(pyddg4 PUBLIC DDPython ROOT::Base ${ROOT_LIBRARIES}) + INSTALL(TARGETS DDPython EXPORT DD4hep DESTINATION lib) + endif() +else() + MESSAGE(STATUS "Python not found, not creating DDG4 4Python Dictionaries") +endif() + #--------------------------- Plugin library for the simulation framework --------- -dd4hep_add_dictionary(G__DDPython - SOURCES ${DDCore_INCLUDE_DIRS}/include/ROOT/Warnings.h tpython/DDPython.C - LINKDEF ${DDCore_INCLUDE_DIRS}/include/ROOT/LinkDef.h - OPTIONAL [PYTHON REQUIRED] - ) -#--------------------------- Specialized python plugins -------------------------- -dd4hep_add_regular_library(DDPython - GENERATED G__DDPython.cxx - USES [ROOT REQUIRED COMPONENTS PyROOT] - OPTIONAL [PYTHON REQUIRED SOURCES tpython/DDPython.cpp]) -#--------------------------- Specialized python plugins -------------------------- -dd4hep_add_plugin(DDG4Python - GENERATED G__DDG4Python.cxx - LINK_LIBRARIES DDPython - OPTIONAL [PYTHON REQUIRED SOURCES src/python/*.cpp]) #--------------------------- LCIO Plugins for new simulation framework ----------- -dd4hep_add_plugin(DDG4LCIO - OPTIONAL [LCIO REQUIRED SOURCES lcio/*.cpp] ) -#--------------------------- DDRec dependent Plugins ----------------------------- -#dd4hep_add_plugin(DDG4Reco -# OPTIONAL [DDRec REQUIRED SOURCES reco/*.cpp] ) +IF(DD4HEP_USE_LCIO) + FIND_PACKAGE(LCIO REQUIRED) + new_dd4hep_add_plugin(DDG4LCIO + SOURCES lcio/*.cpp + LINK_LIBRARIES ${LCIO_LIBRARIES} + ) +ENDIF() +# #--------------------------- DDRec dependent Plugins ----------------------------- +IF(DDRec) + new_dd4hep_add_plugin(DDG4Reco + SOURCES reco/*.cpp + LINK_LIBRARIES DDRec + ) +ENDIF() +#----------------------------------------------------------------------------------- +add_executable(g4gdmlDisplay g4gdmlDisplay.cpp) #----------------------------------------------------------------------------------- -dd4hep_add_executable(g4gdmlDisplay SOURCES g4gdmlDisplay.cpp) +add_executable(g4FromXML g4FromXML.cpp) #----------------------------------------------------------------------------------- -dd4hep_add_executable(g4FromXML SOURCES g4FromXML.cpp) -#---Helper to overcome deficiency of the python executable concerning multi-threading -dd4hep_add_executable(pyddg4 - LINK_LIBRARIES DDPython - USES [ROOT REQUIRED COMPONENTS PyROOT] - OPTIONAL [PYTHON REQUIRED SOURCES pyddg4.cpp]) +target_link_libraries(g4gdmlDisplay DDG4) +target_link_libraries(g4FromXML DDG4) + #---Package installation procedure(s) ---------------------------------------------- dd4hep_install_dir(examples DESTINATION examples/DDG4) dd4hep_install_files(FILES python/*.py python/*.C DESTINATION python) -install(PROGRAMS python/DDSim/bin/ddsim DESTINATION bin ) +install(PROGRAMS python/DDSim/bin/ddsim DESTINATION bin) dd4hep_install_dir(python/DDSim DESTINATION python) + +INSTALL(TARGETS DDG4 EXPORT DD4hep DESTINATION lib) + +#Reset ROOT_LIBRARIES +find_package (ROOT 6.08 REQUIRED) \ No newline at end of file diff --git a/DDParsers/CMakeLists.txt b/DDParsers/CMakeLists.txt index 9fcb0fc6adf233b72ec5e94bdd6229552bd33895..39df6c3a1197cad275c91125ecdf501b9c9bb341 100644 --- a/DDParsers/CMakeLists.txt +++ b/DDParsers/CMakeLists.txt @@ -9,16 +9,44 @@ # For the list of contributors see $DD4hepINSTALL/doc/CREDITS. # #================================================================================= -dd4hep_package( DDParsers - USES [ROOT REQUIRED] - OPTIONAL XERCESC - INCLUDE_DIRS include - INSTALL_INCLUDES include/Evaluator include/Parsers ) - -dd4hep_add_package_library ( DDParsers - INCLUDE_DIRS - LINK_LIBRARIES - SOURCES src/Parsers/*.cpp src/Evaluator/*.cpp - OPTIONAL [BOOST SOURCES src/Spirit/*.cpp] +# dd4hep_package( DDParsers +# USES [ROOT REQUIRED] +# OPTIONAL XERCESC +# INCLUDE_DIRS include +# INSTALL_INCLUDES include/Evaluator include/Parsers ) + +# dd4hep_add_package_library ( DDParsers +# INCLUDE_DIRS +# LINK_LIBRARIES +# SOURCES src/Parsers/*.cpp src/Evaluator/*.cpp +# OPTIONAL [BOOST SOURCES src/Spirit/*.cpp] +# ) + + +file(GLOB DDParsers_SOURCES src/Parsers/*.cpp src/Evaluator/*.cpp) +if(Boost_FOUND) + file(GLOB DDParsers_SPIRIT_SOURCES src/Spirit/*.cpp) +endif() + +add_library(DDParsers SHARED ${DDParsers_SOURCES} ${DDParsers_SPIRIT_SOURCES}) +#target_compile_definitions(DDParsers PUBLIC BOOST_SPIRIT_USE_PHOENIX_V3) + +target_include_directories(DDParsers + PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> + $<INSTALL_INTERFACE:include> + ) + +target_include_directories(DDParsers + SYSTEM + PUBLIC + $<BUILD_INTERFACE:${ROOT_INCLUDE_DIRS}> + ) + +target_link_libraries(DDParsers PUBLIC + $<BUILD_INTERFACE:Boost::boost> + ${XML_LIBRARIES} + # $<BUILD_INTERFACE:${ROOT_LIBRARIES}> ) +INSTALL(TARGETS DDParsers EXPORT DD4hep DESTINATION lib) \ No newline at end of file diff --git a/DDRec/CMakeLists.txt b/DDRec/CMakeLists.txt index 1711c07a056fde0dee5a68534c80b186644d2522..d582b4b31e4c1b408def726e10ece21c17e6a3c5 100644 --- a/DDRec/CMakeLists.txt +++ b/DDRec/CMakeLists.txt @@ -10,41 +10,76 @@ # Author: F.Gaede (Desy) # #========================================================================== -dd4hep_package(DDRec - USES DDCore boost - [ROOT REQUIRED COMPONENTS Geom] - INCLUDE_DIRS include - INSTALL_INCLUDES include/DDRec) #---Add Library------------------------------------------------------------- -if(DD4HEP_USE_GEAR) - add_definitions("-D DD4HEP_USE_GEAR") -endif() -dd4hep_add_dictionary( G__DDRec - SOURCES ${DDCore_INCLUDE_DIRS}/include/ROOT/Warnings.h src/RecDictionary.h +new_dd4hep_add_dictionary( G__DDRec + SOURCES ../DDCore/include/ROOT/Warnings.h src/RecDictionary.h LINKDEF include/ROOT/LinkDef.h + DEPENDS DDCore DDParsers ) -dd4hep_add_package_library(DDRec - SOURCES include/ROOT/Warnings.h - SOURCES src/*.cpp - GENERATED G__DDRec.cxx - OPTIONAL [GEAR COMPONENTS geartgeo SOURCES src/gear/DDGear.cpp DEFINITIONS DD4HEP_USE_GEAR ] -) -dd4hep_add_plugin(DDRecPlugins - SOURCES src/plugins/*.cpp - OPTIONAL [GEAR SOURCES src/gear/createGearForILD.cpp src/gear/createGearForCLIC.cpp src/gear/createGearForSiD.cpp DEFINITIONS DD4HEP_USE_GEAR] + +file(GLOB DDRec_SOURCES src/*.cpp ) + +#SOURCES include/ROOT/Warnings.h + +if(DD4HEP_USE_GEAR) + FIND_PACAKGE(Gear REQUIRED COMPONENTS geartgeo) + SET(GEAR_SOURCE_FILE src/gear/DDGear.cpp) + SET_SOURCE_FILE_PROPERTIES(${GEAR_SOURCE_FILE} + COMPILE_DEFINITIONS DD4HEP_USE_GEAR + ) +endif() + +ADD_LIBRARY(DDRec SHARED + ${DDRec_SOURCES} + ${GEAR_SOURCE_FILE} + G__DDRec.cxx + ) + +TARGET_INCLUDE_DIRECTORIES(DDRec + PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> + $<INSTALL_INTERFACE:include> + ) + +TARGET_LINK_LIBRARIES(DDRec PUBLIC + DDCore + ${GEAR_LIBRARIES} + ${GEAR_COMPONENT_LIBRARIES} + ) + + +if(GEAR_FOUND) + SET(DDREC_PLUGIN_GEAR + src/gear/createGearForILD.cpp + src/gear/createGearForCLIC.cpp + src/gear/createGearForSiD.cpp) + SET(DDREC_PLUGIN_DEFINITIONS DD4HEP_USE_GEAR) +endif() + + +new_dd4hep_add_plugin(DDRecPlugins + SOURCES src/plugins/*.cpp ${DDREC_PLUGIN_GEAR} + LINK_LIBRARIES DDRec + DEFINITIONS ${DDREC_PLUGIN_DEFINITIONS} ) if(DD4HEP_USE_GEAR) - dd4hep_add_executable( convertToGear - SOURCES src/convertToGear.cc - USES [GEAR REQUIRED COMPONENTS geartgeo] ) + FIND_PACKAGE(Gear REQUIRED COMPONENTS geartgeo) + add_executable(convertToGear src/convertToGear.cc) + target_link_libraries(convertToGear ${GEAR_LIBRARIES} ${GEAR_COMPONENT_LIBRARIES} DDRec) + target_compile_definitions(convertToGear PUBLIC DD4HEP_USE_GEAR) else() - dd4hep_add_executable( convertToGear - OPTIONAL [GEAR COMPONENTS geartgeo SOURCES src/convertToGear.cc DEFINITIONS DD4HEP_USE_GEAR] ) + FIND_PACKAGE(Gear COMPONENTS geartgeo QUIET) + IF(GEAR_FOUND) + add_executable(convertToGear src/convertToGear.cc) + target_link_libraries(convertToGear ${GEAR_LIBRARIES} ${GEAR_COMPONENT_LIBRARIES} DDRec) + target_compile_definitions(convertToGear PUBLIC DD4HEP_USE_GEAR) + endif() endif() -dd4hep_install_files(FILES python/*.py DESTINATION python) +# dd4hep_install_files(FILES python/*.py DESTINATION python) +INSTALL(TARGETS DDRec EXPORT DD4hep DESTINATION lib) \ No newline at end of file diff --git a/GaudiPluginService/CMakeLists.txt b/GaudiPluginService/CMakeLists.txt index f036275cb12a1c01d8387edf5d86af97e9d30a5f..8086e11ea83793b17cbf74e51f6406a4f4e224f3 100644 --- a/GaudiPluginService/CMakeLists.txt +++ b/GaudiPluginService/CMakeLists.txt @@ -1,13 +1,15 @@ cmake_minimum_required(VERSION 3.3 FATAL_ERROR) project(GaudiPluginService) -find_package(Boost COMPONENTS filesystem system REQUIRED) -include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${Boost_INCLUDE_DIR}) - add_library(DD4hepGaudiPluginMgr SHARED src/PluginServiceV1.cpp src/PluginServiceV2.cpp interface/DD4hepV1.cpp interface/DD4hepV2.cpp) -add_definitions(-DGaudi=DD4hep_Flavor -DUSE_BOOST_FILESYSTEM) +target_compile_definitions(DD4hepGaudiPluginMgr PUBLIC Gaudi=DD4hep_Flavor USE_BOOST_FILESYSTEM) + +target_include_directories(DD4hepGaudiPluginMgr PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> + ) + if( APPLE ) - add_definitions( -DAPPLE) + target_compile_definitions(DD4hepGaudiPluginMgr APPLE) endif() target_compile_options(DD4hepGaudiPluginMgr PRIVATE -Wno-shadow) target_compile_options(DD4hepGaudiPluginMgr PRIVATE -Wno-unused) @@ -16,7 +18,7 @@ target_compile_options(DD4hepGaudiPluginMgr PRIVATE -Wno-deprecated) target_compile_options(DD4hepGaudiPluginMgr PRIVATE -Wno-keyword-macro) target_compile_options(DD4hepGaudiPluginMgr PRIVATE -Wno-return-type-c-linkage) -target_link_libraries(DD4hepGaudiPluginMgr ${CMAKE_DL_LIBS} ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ) +target_link_libraries(DD4hepGaudiPluginMgr ${CMAKE_DL_LIBS} Boost::filesystem Boost::system) SET_TARGET_PROPERTIES(DD4hepGaudiPluginMgr PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION}) if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) @@ -25,9 +27,11 @@ if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) endif() add_executable(listcomponents src/listcomponents.cpp ) -target_link_libraries(listcomponents DD4hepGaudiPluginMgr ${CMAKE_DL_LIBS} ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ) +target_link_libraries(listcomponents DD4hepGaudiPluginMgr ${CMAKE_DL_LIBS}) target_compile_options(listcomponents PRIVATE -Wno-deprecated) install(TARGETS listcomponents DD4hepGaudiPluginMgr RUNTIME DESTINATION bin - LIBRARY DESTINATION lib ) + LIBRARY DESTINATION lib + ) +INSTALL(TARGETS listcomponents DD4hepGaudiPluginMgr EXPORT DD4hep DESTINATION lib) \ No newline at end of file diff --git a/cmake/DD4hepBuild.cmake b/cmake/DD4hepBuild.cmake index b91e8e3b52777701e8e04cece2c55ef4d48c576d..0063ff3295d1d3f4f06198d39723fc638d48e896 100644 --- a/cmake/DD4hepBuild.cmake +++ b/cmake/DD4hepBuild.cmake @@ -940,8 +940,50 @@ function( dd4hep_package packageName ) else() dd4hep_fatal ( "Missing package dependencies: ${PACKAGE_MISSING}" ) endif() + set (used_incs ${PACKAGE_INCLUDE_DIRS} ) + set (used_libs ${PACKAGE_LINK_LIBRARIES} ) + # + # Define the include directories including dependent packages + # + list(APPEND used_incs ${CMAKE_CURRENT_SOURCE_DIR}/include ) + foreach( inc ${ARG_INCLUDE_DIRS} ) + list( APPEND used_incs ${CMAKE_CURRENT_SOURCE_DIR}/${inc} ) + endforeach() + # + # Build the list of link libraries required to build the package library and plugins etc. + # + dd4hep_make_unique_list ( used_libs VALUES ${used_libs} ${ARG_LINK_LIBRARIES} ) + dd4hep_make_unique_list ( used_incs VALUES ${used_incs} ) + # + # Save the variables in the context of the current source directory (ie. THIS package) + # + set ( use "ON" ) + set_property ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY PACKAGE_INCLUDE_DIRS ${used_incs} ) + set_property ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY PACKAGE_LINK_LIBRARIES ${used_libs} ) + + set_property ( GLOBAL PROPERTY ${PKG_NAME}_LIBRARIES ${used_libs} ) + set_property ( GLOBAL PROPERTY DD4HEP_USE_${PKG_NAME} ${use} ) + set_property ( GLOBAL PROPERTY ${PKG_NAME}_INCLUDE_DIRS ${used_incs} ) + set_property ( GLOBAL PROPERTY ${PKG_NAME}_USES ${PACKAGE_USES} ) + # + # Add package to 'internal' package list + # + get_property ( all_packages GLOBAL PROPERTY DD4HEP_ALL_PACKAGES ) + set ( all_packages ${PKG_NAME} ${all_packages} ) + set_property ( GLOBAL PROPERTY DD4HEP_ALL_PACKAGES ${all_packages} ) + get_property ( use GLOBAL PROPERTY DD4HEP_USE_${PKG_NAME} ) + # + # Some debugging: + # + dd4hep_debug ( "Property: DD4HEP_USE_${PKG_NAME}=${use}" ) + dd4hep_debug ( "Used Libs: ${used_libs}" ) + dd4hep_debug ( "Used Incs: ${used_incs}" ) + # + # Define the installation pathes of the headers. + # + dd4hep_install_dir ( ${ARG_INSTALL_INCLUDES} DESTINATION include ) + # endif() - # endfunction() #--------------------------------------------------------------------------------------------------- @@ -1485,3 +1527,124 @@ function ( fill_dd4hep_library_path ) SET( ENV{DD4HEP_LIBRARY_PATH} ${CMAKE_BINARY_DIR}/lib:$ENV{DD4HEP_LIBRARY_PATH} ) endfunction() + + +#--------------------------------------------------------------------------------------------------- +# new_dd4hep_add_dictionary +# +# +# \author A.Sailer +# \version 1.0 +# +#--------------------------------------------------------------------------------------------------- +function( new_dd4hep_add_dictionary dictionary ) + cmake_parse_arguments(ARG "" "" "SOURCES;EXCLUDE;LINKDEF;OPTIONS;OPTIONAL;DEPENDS;DEFINITIONS;INCLUDES;OUTPUT" ${ARGN} ) + dd4hep_print ( "|++> Building dictionary ... ${dictionary}" ) + # if ( NOT "${ARG_OPTIONAL}" STREQUAL "" ) + # dd4hep_handle_optional_sources ( ${tag} "${ARG_OPTIONAL}" optional_missing optional_uses optional_sources ) + # endif() + + file(GLOB headers ${ARG_SOURCES}) + file(GLOB excl_headers ${ARG_EXCLUDE}) + + foreach( f ${excl_headers} ) + list( REMOVE_ITEM headers ${f} ) + dd4hep_print ( "|++ exclude: ${f}" ) + endforeach() + + set(inc_dirs ${CMAKE_CURRENT_SOURCE_DIR}/include) + foreach(inc ${ARG_INCLUDES}) + LIST(APPEND inc_dirs ${inc}) + endforeach() + + set(comp_defs) + foreach(def ${ARG_DEFINITIONS}) + LIST(APPEND comp_defs ${def}) + endforeach() + + MESSAGE(STATUS "DEPENDENCIES ${ARG_DEPENDS}") + foreach(DEP ${ARG_DEPENDS}) + # Get INCLUDE DIRECTORIES from Dependencies + MESSAGE(STATUS "Appending $<TARGET_PROPERTY:${DEP},INTERFACE_INCLUDE_DIRECTORIES>") + LIST(APPEND inc_dirs $<TARGET_PROPERTY:${DEP},INTERFACE_INCLUDE_DIRECTORIES>) + # Get COMPILE DEFINITIONS from Dependencies + LIST(APPEND comp_defs $<TARGET_PROPERTY:${DEP},INTERFACE_COMPILE_DEFINITIONS>) + endforeach() + + # + file ( GLOB linkdefs ${ARG_LINKDEF} ) + # + dd4hep_print("|++ Linkdef: '${linkdefs}'" ) + dd4hep_print("|++ Definition: '${comp_defs}'" ) + dd4hep_print("|++ Include: '${inc_dirs}'" ) + dd4hep_print("|++ Files: '${headers}'" ) + dd4hep_print("|++ Unparsed: '${ARG_UNPARSED_ARGUMENTS}'" ) + dd4hep_print("|++ Sources: '${CMAKE_CURRENT_SOURCE_DIR}'" ) + # + set ( output_dir ${CMAKE_CURRENT_BINARY_DIR}/../lib ) + if ( NOT "${ARG_OUTPUT}" STREQUAL "" ) + set ( output_dir ${ARG_OUTPUT} ) + endif() + + SET(COMP_DEFS ) + SET(SPACE_I " -I") + file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${dictionary}_arguments + CONTENT "${ROOT_rootcling_CMD} -cint -f ${dictionary}.cxx -s ${output_dir}/${dictionary} -inlineInputHeader -c -p ${ARG_OPTIONS} -std=c++${CMAKE_CXX_STANDARD} \ + $<$<BOOL:${comp_defs}>:-D$<JOIN:${comp_defs}, -D>> \ + $<$<BOOL:${inc_dirs}>:-I$<JOIN:${inc_dirs}, -I>> \ + $<JOIN:${headers}, > $<JOIN:${linkdefs}, >" + ) + add_custom_command(OUTPUT ${dictionary}.cxx ${output_dir}/${dictionary}_rdict.pcm + COMMAND bash ${dictionary}_arguments + DEPENDS ${headers} ${linkdefs} + ) + add_custom_target(${dictionary} + DEPENDS ${dictionary}.cxx ${output_dir}/${dictionary}_rdict.pcm + ) + + set_source_files_properties(${dictionary}.cxx ${output_dir}/${dictionary}_rdict.pcm + PROPERTIES + GENERATED TRUE) + + # Install the binary to the destination directory + install(FILES ${output_dir}/${dictionary}_rdict.pcm DESTINATION lib) + +endfunction() + + +#--------------------------------------------------------------------------------------------------- +# +# new_dd4hep_add_plugin +# +# Arguments +# --------- +# binary -> plugin name +# SOURCES -> list of source files. Will be expanded to absolute names +# +# The following variables EXTEND the package defaults +# INCLUDE_DIRS -> Additional include directories need to compile the binary +# LINK_LIBRARIES -> Additional libraries needed to link the binary +# USES -> Required package dependencies +# DEFINITIONS -> Optional compiler definitions to compile the sources +# +# \author A.Sailer +# \version 1.0 +# +#--------------------------------------------------------------------------------------------------- +function(new_dd4hep_add_plugin binary) + cmake_parse_arguments(ARG "NOINSTALL" "" "SOURCES;GENERATED;LINK_LIBRARIES;INCLUDE_DIRS;USES;DEFINITIONS" ${ARGN}) + if ( ${ARG_NOINSTALL} ) + set(NOINSTALL NOINSTALL) + endif() + file(GLOB SOURCES ${ARG_SOURCES}) + + ADD_LIBRARY(${binary} SHARED ${SOURCES}) + TARGET_LINK_LIBRARIES(${binary} PUBLIC ${ARG_LINK_LIBRARIES}) + TARGET_INCLUDE_DIRECTORIES(${binary} PUBLIC ${ARG_INCLUDE_DIRS}) + TARGET_COMPILE_DEFINITIONS(${binary} PUBLIC ${ARG_DEFINITIONS}) + # what do these options mean? + #GENERATED ${ARG_GENERATED} + #NOINSTALL + # Generate ROOTMAP if the plugin will be built: + dd4hep_generate_rootmap( ${binary} ) +endfunction(new_dd4hep_add_plugin)