Back to home page

EIC code displayed by LXR

 
 

    


Warning, /geant4/examples/advanced/CaTS/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 cmake_minimum_required(VERSION 3.16...3.27)
0002 set(name CaTS)
0003 project(${name} VERSION 0.1.0)
0004 
0005 option(WITH_ROOT "Build example with ROOT" ON)
0006 option(WITH_G4OPTICKS "Build example with OPTICKS" OFF)
0007 option(G4ANALYSIS_USE "Build example with Analysis" ON)
0008 
0009 #----------------------------------------------------------------------------
0010 # Find Geant4 package, activating all available UI and Vis drivers by default
0011 # You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake/cmake-gui
0012 # to build a batch mode only executable
0013 #
0014 option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
0015 if(WITH_GEANT4_UIVIS)
0016   find_package(Geant4 REQUIRED ui_all vis_all)
0017 else()
0018   find_package(Geant4 REQUIRED)
0019 endif()
0020 #----------------------------------------------------------------------------
0021 # Setup Geant4 include directories and compile definitions
0022 #
0023 include(${Geant4_USE_FILE})
0024 #----------------------------------------------------------------------------
0025 # CaTS requires shared libraries
0026 #
0027 if(NOT Geant4_shared_FOUND)
0028   message(FATAL_ERROR "CaTS must use shared libraries")
0029 endif()
0030 
0031 if(WITH_G4OPTICKS)
0032   message(STATUS "WITH_G4OPTICKS is set")
0033   include(OpticksBuildOptions)
0034   find_package( G4OK CONFIG REQUIRED )
0035 else()
0036   message(STATUS "WITH_G4OPTICKS is not set")
0037   list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/modules")
0038   include(CaTSCXXFlags)
0039 endif()
0040 
0041 if(WITH_ROOT)
0042   find_package(ROOT REQUIRED)
0043 # ROOT version 6 required
0044    if(ROOT_FOUND)
0045      STRING(REGEX MATCH "6.*" VERSION6MATCH ${ROOT_VERSION})
0046      if(NOT VERSION6MATCH)
0047        message(FATAL_ERROR "${name} requires ROOT 6")
0048      endif()
0049    endif()
0050 # Include ROOT's CMake functions for dictionary generation
0051 #  since root6.20, the file is renamed and included by default, so include
0052 #  only when we find the *old* name
0053    if(EXISTS "${ROOT_DIR}/modules/RootNewMacros.cmake")
0054      include("${ROOT_DIR}/modules/RootNewMacros.cmake")
0055    endif()
0056 endif()
0057 file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
0058 file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
0059 if(WITH_ROOT)
0060 #----------------------------------------------------------------------------
0061 # Locate sources and headers for this project
0062 #
0063    include_directories(${PROJECT_SOURCE_DIR}/include
0064      ${Geant4_INCLUDE_DIR}
0065      ${ROOT_INCLUDE_DIRS})
0066 #----------------------------------------------------------------------------
0067 # Generate dictionaries, add ROOT libraries properties
0068 #
0069    REFLEX_GENERATE_DICTIONARY(CaTSClasses include/CaTSClasses.hh SELECTION xml/selection.xml)
0070    add_library(CaTSClassesDict SHARED ${sources} CaTSClasses.cxx)
0071    set(libsuffix .so)
0072    set(ROOT_LIBRARY_PROPERTIES ${ROOT_LIBRARY_PROPERTIES} SUFFIX ${libsuffix})
0073    set_target_properties(CaTSClassesDict PROPERTIES ${ROOT_LIBRARY_PROPERTIES})
0074    target_link_libraries(CaTSClassesDict  ${Geant4_LIBRARIES} ${ROOT_LIBRARIES})
0075 else()
0076   include_directories(${PROJECT_SOURCE_DIR}/include
0077   ${Geant4_INCLUDE_DIR})
0078 endif()
0079 
0080 file(GLOB detectors ${PROJECT_SOURCE_DIR}/gdml/*.gdml)
0081 file(GLOB schemas ${PROJECT_SOURCE_DIR}/gdml/*.xsd)
0082 file(GLOB scripts ${PROJECT_SOURCE_DIR}/scripts/*)
0083 file(GLOB macros ${PROJECT_SOURCE_DIR}/macros/*.mac)
0084 file(GLOB runscripts ${PROJECT_SOURCE_DIR}/scripts/run.sh  ${PROJECT_SOURCE_DIR}/scripts/check.sh)
0085 
0086 if(WITH_G4OPTICKS)
0087    add_executable(${name} ${name}.cc ${sources} ${headers}) 
0088    target_compile_definitions( ${name} PRIVATE WITH_G4OPTICKS WITH_ROOT)
0089    target_link_libraries(${name}  CaTSClassesDict Opticks::G4OK ${Geant4_LIBRARIES} ${ROOT_LIBRARIES}  )
0090 else()
0091   add_executable(${name} ${name}.cc ${sources} ${headers})  
0092   target_compile_definitions( ${name} PRIVATE  WITH_ROOT)
0093   target_link_libraries(${name}  CaTSClassesDict ${Geant4_LIBRARIES} ${ROOT_LIBRARIES} )
0094 endif()
0095 if(WITH_ROOT)
0096    add_executable(readPhotonHits readPhotonHits.cc  ${sources} ${headers})
0097    target_link_libraries(readPhotonHits CaTSClassesDict  ${Geant4_LIBRARIES} ${ROOT_LIBRARIES} )
0098    add_executable(readCalorimeterHits  readCalorimeterHits.cc   ${sources} ${headers})
0099    target_link_libraries(readCalorimeterHits CaTSClassesDict  ${Geant4_LIBRARIES} ${ROOT_LIBRARIES} )
0100    add_executable(readMscHits readMscHits.cc  ${sources} ${headers})
0101    target_link_libraries(readMscHits CaTSClassesDict  ${Geant4_LIBRARIES} ${ROOT_LIBRARIES} )
0102    add_executable(readDRCalorimeterHits  readDRCalorimeterHits.cc   ${sources} ${headers})
0103    target_link_libraries(readDRCalorimeterHits CaTSClassesDict  ${Geant4_LIBRARIES} ${ROOT_LIBRARIES} )
0104    link_directories( ${ROOT_LIBRARY_DIR} )
0105 endif()
0106 
0107 install(TARGETS ${name} DESTINATION bin)
0108 install(FILES ${detectors} ${schemas}  ${scripts} ${macros}  DESTINATION bin)
0109 install(FILES ${detectors} DESTINATION bin/gdml)
0110 install(FILES ${macros} DESTINATION bin/macros)
0111 install(PROGRAMS ${runscripts}  DESTINATION bin)
0112 if(WITH_ROOT)
0113   install(TARGETS CaTSClassesDict DESTINATION bin)
0114   install(TARGETS readPhotonHits DESTINATION bin)
0115   install(TARGETS readCalorimeterHits DESTINATION bin)
0116   install(TARGETS readDRCalorimeterHits DESTINATION bin)
0117   install(TARGETS readMscHits DESTINATION bin)
0118   install(FILES ${PROJECT_BINARY_DIR}/CaTSClasses_rdict.pcm DESTINATION bin)
0119 endif()
0120 
0121 message(STATUS "G4ANALYSIS_USE: ${G4ANALYSIS_USE}")
0122 message(STATUS "WITH_G4OPTICKS: ${G4OPTICKS}")
0123 message(STATUS "WITH_ROOT:  ${ROOT}")