Warning, /geant4/examples/advanced/HGCal_testbeam/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
0005 project(HGCal_testbeam)
0006
0007 #----------------------------------------------------------------------------
0008 # Find Geant4 package, activating all available UI and Vis drivers by default
0009 # You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake/cmake-gui
0010 # to build a batch mode only executable
0011 #
0012 option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
0013 if(WITH_GEANT4_UIVIS)
0014 find_package(Geant4 REQUIRED ui_all vis_all)
0015 else()
0016 find_package(Geant4 REQUIRED)
0017 endif()
0018
0019 #----------------------------------------------------------------------------
0020 # Find ROOT (required package only for reading input particles from file)
0021 #
0022 find_package(ROOT QUIET NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
0023 if (ROOT_FOUND)
0024 message(STATUS "Found ROOT: ${ROOT_DIR}. Particles read from file can be used as generator.")
0025 add_definitions(-DWITHROOT)
0026 include_directories(${ROOT_INCLUDE_DIRS})
0027 endif()
0028
0029
0030 #----------------------------------------------------------------------------
0031 # Setup Geant4 include directories and compile definitions
0032 #
0033 include(${Geant4_USE_FILE})
0034
0035 #----------------------------------------------------------------------------
0036 # Locate sources and headers for this project
0037 #
0038 include_directories(${PROJECT_SOURCE_DIR}/include
0039 ${Geant4_INCLUDE_DIR})
0040 file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
0041 file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
0042
0043 #----------------------------------------------------------------------------
0044 # Add the executable, and link it to the Geant4 libraries
0045 #
0046 add_executable(HGCal_testbeam hgcal_testbeam.cc ${sources} ${headers})
0047 target_link_libraries(HGCal_testbeam ${Geant4_LIBRARIES})
0048 if (ROOT_FOUND)
0049 target_link_libraries(HGCal_testbeam ${ROOT_LIBRARIES})
0050 set_target_properties(HGCal_testbeam PROPERTIES CXX_STANDARD 17)
0051 endif()
0052
0053 #----------------------------------------------------------------------------
0054 # Copy all scripts to the build directory, i.e. the directory in which we
0055 # build HGCal)testbeam. This is so that we can run the executable directly because it
0056 # relies on these scripts being in the current working directory.
0057 #
0058 set(HGCAL_SCRIPTS
0059 init_vis.mac
0060 run.mac
0061 vis.mac
0062 )
0063
0064 foreach(_script ${HGCAL_SCRIPTS})
0065 configure_file(
0066 ${PROJECT_SOURCE_DIR}/${_script}
0067 ${PROJECT_BINARY_DIR}/${_script}
0068 COPYONLY
0069 )
0070 endforeach()
0071
0072 if (ROOT_FOUND)
0073 configure_file(
0074 ${PROJECT_SOURCE_DIR}/readFromFile.mac
0075 ${PROJECT_BINARY_DIR}/readFromFile.mac
0076 COPYONLY
0077 )
0078 endif()
0079
0080 #----------------------------------------------------------------------------
0081 # Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
0082 #
0083 install(TARGETS HGCal_testbeam DESTINATION bin)
0084
0085