Skip to content
Snippets Groups Projects
CMakeLists.txt 5.33 KiB
Newer Older
#==========================================================================
Markus Frank's avatar
Markus Frank committed
#  AIDA Detector description implementation 
#--------------------------------------------------------------------------
Markus Frank's avatar
Markus Frank committed
# Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
# All rights reserved.
#
# For the licensing terms see $DD4hepINSTALL/LICENSE.
# For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
#
#==========================================================================
SET_PROPERTY(DIRECTORY . PROPERTY PACKAGE_NAME DDG4)

# configure Geant4
IF(NOT DD4HEP_USE_GEANT4)
  dd4hep_print("|++> Not Using geant4, not building DDG4")
#---Add Library---------------------------------------------------------------------
file(GLOB DDG4_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
add_library(DDG4 SHARED ${DDG4_SOURCES})
target_link_libraries(DDG4
  PUBLIC
  )

#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>
)

#---------------------------  Legacy libraries (for Frank) -------------------------
dd4hep_add_plugin(DDG4Legacy  SOURCES legacy/*.cpp USES DDG4)
#-----------------------------------------------------------------------------------
dd4hep_add_dictionary( G__DDG4
  SOURCES python/DDG4Dict.C
  USES    DD4hep::DDCore DD4hep::DDParsers DD4hep::DDG4 Geant4::Interface
#---------------------------  Plugin library for the simulation framework  ---------
dd4hep_add_plugin(DDG4Plugins
  SOURCES   plugins/*.cpp
  USES      DD4hep::DDG4 DD4hep::DDParsers ${XML_LIBRARIES} ROOT::Core ${CLHEP} 
#---------------------------  Plugin library for the simulation framework  ---------
find_package(Python COMPONENTS Development)
if(TARGET Python::Python)
  dd4hep_print("|++> Python found, creating DDG4Python Dictionary")
  dd4hep_add_dictionary(G__DDG4Python
    SOURCES src/python/DDG4Python.C
    USES    DD4hep::DDCore DD4hep::DDParsers DD4hep::DDG4 ROOT::Core Geant4::Interface
  dd4hep_add_dictionary(G__DDPython
    SOURCES  tpython/DDPython.C
    USES     Python::Python
  if(TARGET ROOT::PyROOT)
    #---------------------------  Specialized python plugins  --------------------------
    dd4hep_print("|++> ROOT Has Python, creating DDPython library and plugins")
    add_library(DDPython SHARED G__DDPython.cxx tpython/DDPython.cpp)
    add_library(DD4hep::DDPython ALIAS DDPython)
    target_link_libraries(DDPython DD4hep::DDG4 ROOT::Core Python::Python ROOT::PyROOT)
    IF(${CMAKE_CXX_STANDARD} GREATER 16)
      # python header not cxx17 compatible, gives error in clang
      target_compile_options(DDPython PUBLIC -Wno-register)
    ENDIF()
    dd4hep_add_plugin(DDG4Python 
      SOURCES   src/python/*.cpp
      GENERATED G__DDG4Python.cxx
      )
    #---Helper to overcome deficiency of the python executable concerning multi-threading
    add_executable(pyddg4 pyddg4.cpp)
    target_link_libraries(pyddg4 PUBLIC DD4hep::DDPython ROOT::Core ROOT::PyROOT)

    # install these libraries
    set_target_properties(DDPython DDG4Python PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})
    INSTALL(TARGETS DDPython pyddg4 DDG4Python EXPORT DD4hep
  dd4hep_print("|+++++> Python not found, not creating DDG4 Python Dictionaries")
#---------------------------  Plugin library for the simulation framework  ---------
#---------------------------  LCIO Plugins for new simulation framework  -----------
  dd4hep_add_plugin(DDG4LCIO
  install(TARGETS DDG4LCIO EXPORT DD4hep LIBRARY DESTINATION lib)
  set_target_properties(DDG4LCIO PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})

ENDIF()
# #---------------------------  DDRec dependent Plugins  -----------------------------
#This does not compile at the moment
# IF(TARGET DDRec)
#   dd4hep_add_plugin(DDG4Reco
#     SOURCES reco/*.cpp
#     USES DDCore DDG4 DDRec
#   install(TARGETS DDG4Reco EXPORT DD4hep LIBRARY DESTINATION lib)
# ENDIF()
#-----------------------------------------------------------------------------------
add_executable(g4gdmlDisplay g4gdmlDisplay.cpp)
#-----------------------------------------------------------------------------------
add_executable(g4FromXML g4FromXML.cpp)
#-----------------------------------------------------------------------------------
target_link_libraries(g4gdmlDisplay DDG4)
target_link_libraries(g4FromXML DDG4)

#---Package installation procedure(s) ----------------------------------------------
file(GLOB DDG4_python python/*.py python/*.C)
install(FILES ${DDG4_python} DESTINATION python)

install(PROGRAMS python/DDSim/bin/ddsim DESTINATION bin)
install(DIRECTORY python/DDSim DESTINATION python)
install(DIRECTORY examples DESTINATION examples/DDG4)

set_target_properties(DDG4 DDG4Plugins DDG4Legacy PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION})

install(TARGETS DDG4 DDG4Plugins DDG4Legacy g4gdmlDisplay g4FromXML
  EXPORT DD4hep
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin)
install(DIRECTORY include/DDG4 DESTINATION include)