diff --git a/CMakeLists.txt b/CMakeLists.txt index 07b49b702e9b0427fc52c6d5946732c2cef68ee7..acbd814843e1ecb474ecf434718db03dacfb0163 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,31 +95,27 @@ 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}) - +find_package (ROOT 6.08 REQUIRED) DD4HEP_SETUP_ROOT_TARGETS() -################### -# Configure BOOST # -################### +# 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 ) -IF(DD4HEP_USE_LCIO) - FIND_PACKAGE(LCIO REQUIRED) - DD4HEP_SETUP_LCIO_TARGETS() -ENDIF() - - -IF(DD4HEP_USE_GEANT4) - find_package(Geant4 10.2.2 REQUIRED COMPONENTS gdml ui_all vis_all) +# Configure Geant4 +if(DD4HEP_USE_GEANT4) + find_package( Geant4 10.2.2 REQUIRED gdml ui_all vis_all ) DD4HEP_SETUP_GEANT4_TARGETS() endif() +if(DD4HEP_USE_LCIO) + find_package(LCIO REQUIRED) + DD4HEP_SETUP_LCIO_TARGETS() +endif() + ###################### # Set compiler flags # ###################### @@ -152,9 +148,9 @@ add_subdirectory(DDG4) # Note the order: DDEve partially depends on variables from DDG4! add_subdirectory(DDEve) -include(CTest) - +enable_testing() if(BUILD_TESTING) + include(CTest) add_subdirectory(DDTest) endif() add_subdirectory(UtilityApps) @@ -218,6 +214,6 @@ endif() INSTALL(EXPORT DD4hep NAMESPACE DD4hep:: FILE DD4hepConfig-targets.cmake - DESTINATION lib + DESTINATION cmake EXPORT_LINK_INTERFACE_LIBRARIES ) \ No newline at end of file diff --git a/GaudiPluginService/CMakeLists.txt b/GaudiPluginService/CMakeLists.txt index 2432be23d6e7fbed474e692fe83852464f9f7786..c22228e33064be55a5d70de5050a7e9340f32397 100644 --- a/GaudiPluginService/CMakeLists.txt +++ b/GaudiPluginService/CMakeLists.txt @@ -30,8 +30,6 @@ add_executable(listcomponents src/listcomponents.cpp ) target_link_libraries(listcomponents DD4hepGaudiPluginMgr ${CMAKE_DL_LIBS}) target_compile_options(listcomponents PRIVATE -Wno-deprecated) -install(TARGETS listcomponents DD4hepGaudiPluginMgr +INSTALL(TARGETS listcomponents DD4hepGaudiPluginMgr EXPORT DD4hep RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ) -INSTALL(TARGETS listcomponents DD4hepGaudiPluginMgr EXPORT DD4hep DESTINATION lib) \ No newline at end of file + LIBRARY DESTINATION lib) \ No newline at end of file diff --git a/cmake/DD4hepConfig.cmake.in b/cmake/DD4hepConfig.cmake.in index a676b21aa0fd986527e41d0d3afd360769f599f3..ce9cc9ed37a1549b19f9175a04d2098147d6918f 100644 --- a/cmake/DD4hepConfig.cmake.in +++ b/cmake/DD4hepConfig.cmake.in @@ -64,14 +64,19 @@ SET_TARGET_PROPERTIES(Boost::boost INTERFACE_COMPILE_DEFINITIONS BOOST_SPIRIT_USE_PHOENIX_V3 ) +find_package(Geant4 10.2.2 REQUIRED gdml ui_all vis_all) +DD4HEP_SETUP_GEANT4_TARGETS() + FIND_PACKAGE(ROOT REQUIRED) DD4HEP_SETUP_ROOT_TARGETS() -find_package(Geant4 10.2.2 REQUIRED COMPONENTS gdml ui_all vis_all) -DD4HEP_SETUP_GEANT4_TARGETS() +if(DD4HEP_USE_LCIO) + find_package(LCIO REQUIRED) + DD4HEP_SETUP_LCIO_TARGETS() +endif() if(NOT CMAKE_PROJECT_NAME STREQUAL DD4hep) - include("${DD4hep_ROOT}/lib/DD4hepConfig-targets.cmake") + include("${DD4hep_ROOT}/cmake/DD4hepConfig-targets.cmake") endif() # ---------- include dirs ----------------------------------------------------- @@ -79,17 +84,6 @@ endif() GET_TARGET_PROPERTY(DD4hep_INCLUDE_DIRS DD4hep::DDCore INTERFACE_INCLUDE_DIRECTORIES) MESSAGE(STATUS "include dirs ${DD4hep_INCLUDE_DIRS}") - -#---------------------------------------------------------------------------- -# Setup components and options -set(_dd4hep_options ) - -foreach(_opt ${_root_options}) - set(DD4hep_${_opt}_FOUND TRUE) -endforeach() - - - # ---------- libraries -------------------------------------------------------- # do not store find results in cache #set( DD4hep_LIBRARY_DIRS ${DD4hep_DIR}/lib ) @@ -98,22 +92,17 @@ endforeach() set(DD4hep_LIBRARIES DD4hep::DDParsers DD4hep::DDCore DD4hep::DDRec) -include( ${DD4hep_DIR}/cmake/DD4hepMacros.cmake ) - -# only standard libraries should be passed as arguments to CHECK_PACKAGE_LIBS -# additional components are set by cmake in variable PKG_FIND_COMPONENTS -# first argument should be the package name - -CHECK_PACKAGE_LIBS(DD4hep DDCore) +#include( ${DD4hep_DIR}/cmake/DD4hepMacros.cmake ) +SET(DD4hep_COMPONENT_LIBRARIES) IF(DD4hep_FIND_COMPONENTS) dd4hep_print( "|++> DD4hep: Looking for Components: ${DD4hep_FIND_COMPONENTS}" ) FOREACH(comp ${DD4hep_FIND_COMPONENTS}) #CHECK_PACKAGE_LIBS is looking for components too, just need to check if they were found, if requested - STRING( TOUPPER ${comp} _ulibname ) - if(NOT DD4hep_${_ulibname}_FOUND) + IF(NOT TARGET DD4hep::${comp}) MESSAGE(FATAL_ERROR "|++> Did not find required component: ${comp}") ENDIF() + LIST(APPEND DD4hep_COMPONENT_LIBRARIES DD4hep::${comp}) ENDFOREACH() ENDIF() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 69542c19e07a6ca062b27b0b3c361125a8f00705..adcbed9a5866fdd38fcfe0569fdcfb2043b9f59b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -54,7 +54,6 @@ add_subdirectory(ClientTests) add_subdirectory(Conditions) add_subdirectory(DDG4) add_subdirectory(DDDigi) -#add_subdirectory(OpticalSurfaces) ## needs root version >= 6.18 add_subdirectory(Persistency) add_subdirectory(SimpleDetector) add_subdirectory(DDG4_MySensDet) @@ -63,3 +62,4 @@ add_subdirectory(DDCodex) add_subdirectory(DDDB) add_subdirectory(DDCMS) +add_subdirectory(OpticalSurfaces) diff --git a/examples/OpticalSurfaces/CMakeLists.txt b/examples/OpticalSurfaces/CMakeLists.txt index 45005061caf459cbb05444197e7a977f2a3cc9d9..d8ecc1f965f7f9293b8ea9e2ae57af1e4ec96e82 100644 --- a/examples/OpticalSurfaces/CMakeLists.txt +++ b/examples/OpticalSurfaces/CMakeLists.txt @@ -11,20 +11,28 @@ cmake_minimum_required(VERSION 3.3 FATAL_ERROR) include ( ${DD4hep_DIR}/cmake/DD4hep.cmake ) +message(STATUS "OpticalSurfaces: ROOT version: ${ROOT_VERSION}") + +if(NOT ${ROOT_VERSION} VERSION_GREATER_EQUAL 6.18.00) + MESSAGE(STATUS "Not building optical surface test") + return() +endif() +MESSAGE(STATUS "building optical surface test") + #-------------------------------------------------------------------------- dd4hep_configure_output() -dd4hep_package ( OpticalSurfaces MAJOR 0 MINOR 0 PATCH 1 - USES [ROOT REQUIRED COMPONENTS Geom GenVector MathCore] - [DD4hep REQUIRED COMPONENTS DDCore DDCond] - OPTIONAL XERCESC - INCLUDE_DIRS include + +link_libraries( + DD4hep::DDCore DD4hep::DDCond + ROOT::Core ROOT::Geom ROOT::GenVector ROOT::MathCore ) + set(OpticalSurfaces_INSTALL ${CMAKE_INSTALL_PREFIX}/examples/OpticalSurfaces) -dd4hep_add_plugin( OpticalSurfacesExample SOURCES src/*.cpp ) -dd4hep_install_dir( compact scripts DESTINATION ${OpticalSurfaces_INSTALL} ) +new_dd4hep_add_plugin(OpticalSurfacesExample SOURCES src/*.cpp ) +install(TARGETS OpticalSurfacesExample LIBRARY DESTINATION lib) +install(DIRECTORY compact scripts DESTINATION ${OpticalSurfaces_INSTALL} ) dd4hep_configure_scripts( OpticalSurfaces DEFAULT_SETUP WITH_TESTS) -# -message (STATUS "OpticalSurfaces: ROOT version: ${ROOT_VERSION}") + # #---Testing: Load ROOT GDMLMatrix objects from compact # and register them to the TGeoManager