diff --git a/CMakeLists.txt b/CMakeLists.txt index 3489ca922e7e517161bdbd017211173528537ee0..1666dce50bb4d9a554bc7c05ac004ce075740552 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,33 +92,56 @@ find_package(ROOT 6.08 REQUIRED) # COMPONENTS Geom GenVector Eve Gui Graf3d RGL #include(${ROOT_USE_FILE}) -ADD_LIBRARY(ROOT::Base SHARED IMPORTED GLOBAL) +ADD_LIBRARY(ROOT::Interface INTERFACE IMPORTED GLOBAL) #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 +SET_TARGET_PROPERTIES(ROOT::Interface PROPERTIES - INTERFACE_LINK_LIBRARIES "${ROOT_LIBRARIES}" INTERFACE_COMPILE_OPTIONS "${ROOT_CXX_FLAGS}" INTERFACE_INCLUDE_DIRECTORIES ${ROOT_INCLUDE_DIRS} - IMPORTED_LOCATION ${ROOT_LIBRARIES} ) +foreach(LIB Core RIO Net Hist Graf Graf3d Gpad Tree Rint Postscript Matrix Physics MathCore Thread MultiProc) + ADD_LIBRARY(ROOT::${LIB} SHARED IMPORTED GLOBAL) + MESSAGE(STATUS "ROOT lib location ${LIB} ${ROOT_${LIB}_LIBRARY}") + SET_TARGET_PROPERTIES(ROOT::${LIB} + PROPERTIES + INTERFACE_COMPILE_OPTIONS "${ROOT_CXX_FLAGS}" + INTERFACE_INCLUDE_DIRECTORIES ${ROOT_INCLUDE_DIRS} + IMPORTED_LOCATION ${ROOT_${LIB}_LIBRARY} + ) + TARGET_LINK_LIBRARIES(ROOT::Interface INTERFACE ROOT::${LIB}) +endforeach() + +foreach(LIB PyROOT Geom GenVector) + ADD_LIBRARY(ROOT::${LIB} SHARED IMPORTED GLOBAL) + MESSAGE(STATUS "ROOT lib location ${LIB} ${G4_LIB_TEMP_${LIB}}") + SET_TARGET_PROPERTIES(ROOT::${LIB} + PROPERTIES + INTERFACE_COMPILE_OPTIONS "${ROOT_CXX_FLAGS}" + INTERFACE_INCLUDE_DIRECTORIES ${ROOT_INCLUDE_DIRS} + IMPORTED_LOCATION ${ROOT_${LIB}_LIBRARY} + ) +endforeach() + 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}" ) +GET_PROPERTY(IMP_LOC TARGET ROOT::Core PROPERTY IMPORTED_LOCATION) +MESSAGE(STATUS "ROOT_IMP_LOC: ${IMP_LOC}" ) -# Configure BOOST -find_package(Boost 1.49 REQUIRED filesystem system) +################### +# Configure BOOST # +################### +find_package(Boost 1.49 REQUIRED COMPONENTS filesystem system) SET_TARGET_PROPERTIES(Boost::boost PROPERTIES INTERFACE_COMPILE_DEFINITIONS BOOST_SPIRIT_USE_PHOENIX_V3 ) -#add_definitions( -DBOOST_SPIRIT_USE_PHOENIX_V3 ) ###################### diff --git a/DDCond/CMakeLists.txt b/DDCond/CMakeLists.txt index 4c3ebf53df174a81c5ed151548c26b446d7046f3..0487ddb8073410f089c62ebd2474acbe127841dd 100644 --- a/DDCond/CMakeLists.txt +++ b/DDCond/CMakeLists.txt @@ -17,7 +17,6 @@ new_dd4hep_add_dictionary( G__DDCond ) file(GLOB DDCond_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) -MESSAGE(STATUS "DDCond_SOURCES ${DDCond_SOURCES}") #---DDCond library -------------------------------------------------------------- add_library(DDCond SHARED ${DDCond_SOURCES} G__DDCond.cxx diff --git a/DDCore/CMakeLists.txt b/DDCore/CMakeLists.txt index 3361b4ee55ff0db7970630935341d52c53a6cc60..c387528ff7816f0d922c836a45002e67ba37cec8 100644 --- a/DDCore/CMakeLists.txt +++ b/DDCore/CMakeLists.txt @@ -11,10 +11,6 @@ #================================================================================= 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------------------------------------------------------ new_dd4hep_add_dictionary( G__DD4hep SOURCES include/ROOT/Warnings.h @@ -73,14 +69,12 @@ target_include_directories(DDCore $<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 + ROOT::Interface + ROOT::Geom ROOT::Geom GenVector ${XML_LIBRARIES} # XercesC or not ) @@ -110,7 +104,7 @@ new_dd4hep_add_plugin(DDCorePlugins SOURCES src/plugins/*.cpp IF(${ROOT_gdml_FOUND}) new_dd4hep_add_plugin(DDGDMLPlugins SOURCES src/gdml/*.cpp - LINK_LIBRARIES DDCore ROOT::Base + LINK_LIBRARIES DDCore ROOT::Interface ) ELSE() MESSAGE(WARN "ROOT does not include GDML, not building DDCore GDML Plugins") @@ -118,11 +112,9 @@ ENDIF() #--------------------------- Specialized PYTHON plugin ---------------------------- 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} + LINK_LIBRARIES DDCore ROOT::Interface ROOT::PyROOT ) ELSE() MESSAGE(WARN "ROOT does not include PyRoot, not building DDCore DDPython Plugins") @@ -134,6 +126,3 @@ ENDIF() 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/DDG4/CMakeLists.txt b/DDG4/CMakeLists.txt index 327df5f77293305e0a600381151e1fb8c113ada1..b610abec3916a1c31e9f2a3a01a7f92546ade952 100644 --- a/DDG4/CMakeLists.txt +++ b/DDG4/CMakeLists.txt @@ -14,9 +14,7 @@ IF(NOT DD4HEP_USE_GEANT4) RETURN() ENDIF() - - -find_package(Geant4 10.2.2 REQUIRED gdml ui_all vis_all) +find_package(Geant4 10.2.2 REQUIRED COMPONENTS 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}) @@ -29,6 +27,63 @@ else() set(CLHEP CLHEP) endif() +MESSAGE(STATUS "Geant4 Libraries ${Geant4_LIBRARIES}") +MESSAGE(STATUS "Geant4 CXX_FLAGS ${Geant4_CXX_FLAGS}") +MESSAGE(STATUS "Geant4 INCL DIRS ${Geant4_INCLUDE_DIRS}") +MESSAGE(STATUS "Geant4_VERSION: ${Geant4_VERSION}" ) + +# Geant4::10.2.2 at least, not in 10.5 (check where it switches) +#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}}) +SET(Geant4_CXX_FLAGS ${Geant4_Flags}) + +#Geant4_DEFINITIONS already include -D, we jave to get rid of that so we can join things when creating dictionaries +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}) +UNSET(G4_DEF_TEMP) + +#get_filename_component(Geant4_LOCATION ${Geant4_INCLUDE_DIRS} DIRECTORY) +SET(Geant4_LOCATION "/cvmfs/ilc.desy.de/sw/x86_64_gcc49_sl6/geant4/10.03.p02/lib64") + +ADD_LIBRARY(Geant4::Interface INTERFACE IMPORTED GLOBAL) + +SET_TARGET_PROPERTIES(Geant4::Interface + PROPERTIES + INTERFACE_COMPILE_OPTIONS "${Geant4_CXX_FLAGS}" + INTERFACE_COMPILE_DEFINITIONS "${Geant4_DEFINITIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${Geant4_INCLUDE_DIRS}" + ) + +IF(CLHEP) + MESSAGE(STATUS "Adding CLHEP to Geant4::Interface Dependencies") + TARGET_LINK_LIBRARIES(Geant4::Interface INTERFACE ${CLHEP}) +ENDIF() + +foreach(LIB ${Geant4_LIBRARIES}) + find_library(G4_LIB_TEMP_${LIB} ${LIB} PATHS ${Geant4_LOCATION}) + ADD_LIBRARY(Geant4::${LIB} SHARED IMPORTED GLOBAL) + MESSAGE(STATUS "Geant4 lib location ${LIB} ${G4_LIB_TEMP_${LIB}}") + SET_TARGET_PROPERTIES(Geant4::${LIB} + PROPERTIES + INTERFACE_COMPILE_OPTIONS "${Geant4_CXX_FLAGS}" + INTERFACE_COMPILE_DEFINITIONS "${Geant4_DEFINITIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${Geant4_INCLUDE_DIRS}" + IMPORTED_LOCATION ${G4_LIB_TEMP_${LIB}} + ) + TARGET_LINK_LIBRARIES(Geant4::Interface INTERFACE Geant4::${LIB}) +endforeach() + +MESSAGE(STATUS "Geant4 Libraries ${Geant4_LIBRARIES};${Geant4_COMPONENT_LIBRARIES}") +MESSAGE(STATUS "Geant4 Location ${Geant4_LOCATION}") +MESSAGE(STATUS "Geant4 Defintitions ${Geant4_DEFINITIONS}") +MESSAGE(STATUS "Geant4 CXX_FLAGS ${Geant4_CXX_FLAGS}") +MESSAGE(STATUS "Geant4 INCL DIRS ${Geant4_INCLUDE_DIRS}") +MESSAGE(STATUS "Geant4_VERSION: ${Geant4_VERSION}" ) + # dd4hep_package( DDG4 # USES [GEANT4 REQUIRED COMPONENTS gdml ui_all vis_all] # [ROOT REQUIRED COMPONENTS Geom GenVector RIO] @@ -44,44 +99,20 @@ 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 + #${Geant4_LIBRARIES} + #${Geant4_COMPONENT_LIBRARIES} + ROOT::Interface + Geant4::Interface ) + #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} + $<TARGET_PROPERTY:DDCore,INTERFACE_INCLUDE_DIRECTORIES> # FIXME: Check if this works when using imported target ) #--------------------------- Legacy libraries (for Frank) ------------------------- @@ -107,7 +138,7 @@ 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 + DEPENDS DDCore DDParsers DDG4 ROOT::Interface INCLUDES ${Geant4_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS} DEFINITIONS ${Geant4_DEFINITIONS} ) @@ -116,11 +147,10 @@ if(PYTHONLIBS_FOUND) 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_link_libraries(DDPython DDG4 ROOT::Interface ${PYTHON_LIBRARIES} ROOT::PyROOT) target_include_directories(DDPython PUBLIC ${PYTHON_INCLUDE_DIRS}) new_dd4hep_add_plugin(DDG4Python SOURCES src/python/*.cpp G__DDG4Python.cxx @@ -128,7 +158,7 @@ if(PYTHONLIBS_FOUND) ) #---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}) + target_link_libraries(pyddg4 PUBLIC DDPython ROOT::Interface ROOT::PyROOT) INSTALL(TARGETS DDPython EXPORT DD4hep DESTINATION lib) endif() else() @@ -166,6 +196,3 @@ 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 39df6c3a1197cad275c91125ecdf501b9c9bb341..70fb7bbb7ad896a96d38b3a69d25d7c0dac2dfe5 100644 --- a/DDParsers/CMakeLists.txt +++ b/DDParsers/CMakeLists.txt @@ -29,7 +29,7 @@ if(Boost_FOUND) endif() add_library(DDParsers SHARED ${DDParsers_SOURCES} ${DDParsers_SPIRIT_SOURCES}) -#target_compile_definitions(DDParsers PUBLIC BOOST_SPIRIT_USE_PHOENIX_V3) +target_compile_definitions(DDParsers PUBLIC BOOST_SPIRIT_USE_PHOENIX_V3) target_include_directories(DDParsers PUBLIC @@ -41,12 +41,11 @@ target_include_directories(DDParsers SYSTEM PUBLIC $<BUILD_INTERFACE:${ROOT_INCLUDE_DIRS}> + $<TARGET_PROPERTY:Boost::boost,INTERFACE_INCLUDE_DIRECTORIES> ) 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/cmake/DD4hepBuild.cmake b/cmake/DD4hepBuild.cmake index 0063ff3295d1d3f4f06198d39723fc638d48e896..eb7faba676c9997b46e94aed6265b9f25e61f455 100644 --- a/cmake/DD4hepBuild.cmake +++ b/cmake/DD4hepBuild.cmake @@ -1562,10 +1562,8 @@ function( new_dd4hep_add_dictionary dictionary ) 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>) @@ -1574,12 +1572,12 @@ function( new_dd4hep_add_dictionary dictionary ) # 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}'" ) + dd4hep_debug("|++ Linkdef: '${linkdefs}'" ) + dd4hep_debug("|++ Definition: '${comp_defs}'" ) + dd4hep_debug("|++ Include: '${inc_dirs}'" ) + dd4hep_debug("|++ Files: '${headers}'" ) + dd4hep_debug("|++ Unparsed: '${ARG_UNPARSED_ARGUMENTS}'" ) + dd4hep_debug("|++ Sources: '${CMAKE_CURRENT_SOURCE_DIR}'" ) # set ( output_dir ${CMAKE_CURRENT_BINARY_DIR}/../lib ) if ( NOT "${ARG_OUTPUT}" STREQUAL "" )