Back to home page

EIC code displayed by LXR

 
 

    


Warning, /geant4/examples/extended/persistency/P02/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(P02)
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 "P02 requires ROOT 6")
0033   endif()
0034 endif()
0035 
0036 # Include ROOT's CMake functions for dictionary generation
0037 include("${ROOT_DIR}/modules/RootNewMacros.cmake")
0038 
0039 #----------------------------------------------------------------------------
0040 # P01 requires shared libraries
0041 #
0042 if(NOT Geant4_shared_FOUND)
0043   message(FATAL_ERROR "P02 must use shared libraries")
0044 endif()
0045 
0046 
0047 #----------------------------------------------------------------------------
0048 # Locate sources and headers for this project
0049 #
0050 include_directories(${PROJECT_SOURCE_DIR}/include
0051                     ${Geant4_INCLUDE_DIR}
0052                     ${ROOT_INCLUDE_DIRS})
0053 file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
0054 file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
0055 
0056 #----------------------------------------------------------------------------
0057 # Generate dictionaries, add ROOT libraries propoertiries
0058 #
0059 REFLEX_GENERATE_DICTIONARY(ExP02Classes include/ExP02Classes.hh SELECTION xml/selection.xml)
0060 add_library(ExP02ClassesDict SHARED ${sources} ExP02Classes.cxx)
0061 set(libsuffix .so)
0062 set(ROOT_LIBRARY_PROPERTIES ${ROOT_LIBRARY_PROPERTIES} SUFFIX ${libsuffix})
0063 set_target_properties(ExP02ClassesDict PROPERTIES ${ROOT_LIBRARY_PROPERTIES})
0064 target_link_libraries(ExP02ClassesDict  ${Geant4_LIBRARIES} ${ROOT_LIBRARIES})
0065 
0066 #----------------------------------------------------------------------------
0067 # Add the executable, and link it to the Geant4 libraries
0068 #
0069 add_executable(exampleP02 exampleP02.cc ${sources} ${headers})
0070 target_link_libraries(exampleP02 ExP02ClassesDict ${Geant4_LIBRARIES} ${ROOT_LIBRARIES})
0071 
0072 #----------------------------------------------------------------------------
0073 # Copy all scripts to the build directory, i.e. the directory in which we
0074 # build P02. This is so that we can run the executable directly because it
0075 # relies on these scripts being in the current working directory.
0076 #
0077 set(P02_SCRIPTS
0078     run.mac vis.mac geo.root
0079   )
0080 
0081 foreach(_script ${P02_SCRIPTS})
0082   configure_file(
0083     ${PROJECT_SOURCE_DIR}/${_script}
0084     ${PROJECT_BINARY_DIR}/${_script}
0085     COPYONLY
0086     )
0087 endforeach()
0088 
0089 #----------------------------------------------------------------------------
0090 # Add program to the project targets
0091 # (this avoids the need of typing the program name after make)
0092 #
0093 add_custom_target(P02 DEPENDS exampleP02)
0094 
0095 #----------------------------------------------------------------------------
0096 # Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
0097 #
0098 install(TARGETS exampleP02 DESTINATION bin)
0099 install(TARGETS ExP02ClassesDict DESTINATION lib)
0100 install(FILES ${PROJECT_BINARY_DIR}/ExP02Classes_rdict.pcm DESTINATION lib)
0101 
0102