Back to home page

EIC code displayed by LXR

 
 

    


Warning, /geant4/examples/extended/persistency/P01/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 #----------------------------------------------------------------------------
0002 # Setup the project
0003 cmake_minimum_required(VERSION 3.16...3.27)
0004 project(P01)
0005 
0006 #----------------------------------------------------------------------------
0007 # Find Geant4 package, activating all available UI and Vis drivers by default
0008 # You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake/cmake-gui
0009 # to build a batch mode only executable
0010 #
0011 option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
0012 if(WITH_GEANT4_UIVIS)
0013   find_package(Geant4 REQUIRED ui_all vis_all)
0014 else()
0015   find_package(Geant4 REQUIRED)
0016 endif()
0017 
0018 #----------------------------------------------------------------------------
0019 # Setup Geant4 include directories and compile definitions
0020 #
0021 include(${Geant4_USE_FILE})
0022 
0023 #----------------------------------------------------------------------------
0024 # Find ROOT (required package)
0025 #
0026 find_package(ROOT REQUIRED)
0027 
0028 # ROOT version 6 required
0029 if(ROOT_FOUND)
0030   STRING(REGEX MATCH "6.*" VERSION6MATCH ${ROOT_VERSION})
0031   if(NOT VERSION6MATCH)
0032     message(FATAL_ERROR "P01 requires ROOT 6")
0033   endif()
0034 endif()
0035 
0036 # Include ROOT's CMake functions for dictionary generation
0037 #  since root6.20, the file is renamed and included by default, so include
0038 #  only when we find the *old* name
0039 if(EXISTS "${ROOT_DIR}/modules/RootNewMacros.cmake")
0040    include("${ROOT_DIR}/modules/RootNewMacros.cmake")
0041 endif()
0042 
0043 #----------------------------------------------------------------------------
0044 # P01 requires shared libraries
0045 #
0046 if(NOT Geant4_shared_FOUND)
0047   message(FATAL_ERROR "P01 must use shared libraries")
0048 endif()
0049 
0050 #----------------------------------------------------------------------------
0051 # Locate sources and headers for this project
0052 #
0053 include_directories(${PROJECT_SOURCE_DIR}/include
0054                     ${Geant4_INCLUDE_DIR}
0055                     ${ROOT_INCLUDE_DIRS})
0056 file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
0057 file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
0058 
0059 #----------------------------------------------------------------------------
0060 # Generate dictionaries, add ROOT libraries properties
0061 #
0062 REFLEX_GENERATE_DICTIONARY(ExP01Classes include/ExP01Classes.hh SELECTION xml/selection.xml)
0063 add_library(ExP01ClassesDict SHARED ${sources} ExP01Classes.cxx)
0064 set(libsuffix .so)
0065 set(ROOT_LIBRARY_PROPERTIES ${ROOT_LIBRARY_PROPERTIES} SUFFIX ${libsuffix})
0066 set_target_properties(ExP01ClassesDict PROPERTIES ${ROOT_LIBRARY_PROPERTIES})
0067 target_link_libraries(ExP01ClassesDict  ${Geant4_LIBRARIES} ${ROOT_LIBRARIES})
0068 
0069 #----------------------------------------------------------------------------
0070 # Add the executable, and link it to the Geant4 libraries
0071 #
0072 add_executable(exampleP01 exampleP01.cc ${sources} ${headers})
0073 target_link_libraries(exampleP01 ExP01ClassesDict ${Geant4_LIBRARIES} ${ROOT_LIBRARIES})
0074 add_executable(readHits readHits.cc  ${sources} ${headers})
0075 target_link_libraries(readHits ExP01ClassesDict ${Geant4_LIBRARIES} ${ROOT_LIBRARIES})
0076 
0077 #----------------------------------------------------------------------------
0078 # Copy all scripts to the build directory, i.e. the directory in which we
0079 # build P01. This is so that we can run the executable directly because it
0080 # relies on these scripts being in the current working directory.
0081 #
0082 set(P01_SCRIPTS
0083     run.mac vis.mac
0084   )
0085 
0086 foreach(_script ${P01_SCRIPTS})
0087   configure_file(
0088     ${PROJECT_SOURCE_DIR}/${_script}
0089     ${PROJECT_BINARY_DIR}/${_script}
0090     COPYONLY
0091     )
0092 endforeach()
0093 
0094 #----------------------------------------------------------------------------
0095 # Add program to the project targets
0096 # (this avoids the need of typing the program name after make)
0097 #
0098 add_custom_target(P01 DEPENDS exampleP01 readHits )
0099 
0100 #----------------------------------------------------------------------------
0101 # Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
0102 #
0103 install(TARGETS exampleP01 DESTINATION bin)
0104 install(TARGETS readHits DESTINATION bin)
0105 install(TARGETS ExP01ClassesDict DESTINATION lib)
0106 install(FILES ${PROJECT_BINARY_DIR}/ExP01Classes_rdict.pcm DESTINATION lib)