Warning, /east/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 #----------------------------------------------------------------------------
0002 # Setup the project
0003 cmake_minimum_required(VERSION 3.8)
0004 if(${CMAKE_VERSION} VERSION_LESS 3.12)
0005 cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
0006 endif()
0007 project(eAST VERSION 0.1.0)
0008
0009
0010 ## This enables us to use CMAKE_INSTALL_FULL_DATADIR in the code
0011 ## (should resolve to ${CMAKE_INSTALL_PREFIX}/share)
0012 include(GNUInstallDirs)
0013 add_definitions(-DCMAKE_INSTALL_FULL_DATADIR="${CMAKE_INSTALL_FULL_DATADIR}")
0014 ## Also hand over the source directory for people who don't do make install
0015 add_definitions(-DCMAKE_PROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}")
0016
0017 #----------------------------------------------------------------------------
0018 # Find Geant4 package, activating all available UI and Vis drivers by default
0019 # You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake/cmake-gui
0020 # to build a batch mode only executable
0021 #
0022 option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
0023 if(WITH_GEANT4_UIVIS)
0024 find_package(Geant4 10.7 REQUIRED ui_all vis_all)
0025 else()
0026 find_package(Geant4 10.7 REQUIRED)
0027 endif()
0028
0029 #----------------------------------------------------------------------------
0030 # Setup Geant4 include directories and compile definitions
0031 # Setup include directory for this project
0032 #
0033 include(${Geant4_USE_FILE})
0034
0035 #----------------------------------------------------------------------------
0036 # You can set eAST_USE_HepMC3 to OFF via the command line or ccmake/cmake-gui
0037 option(eAST_USE_HepMC3 "Build example with HepMC support, requires HepMC3" ON)
0038 if(eAST_USE_HepMC3)
0039 message ( "---- You can specify a HepMC3 installation using \"-DHepMC3=[path/to/lib]\" " )
0040 # message ( "---- HepMC3=" ${HepMC3} )
0041 find_package(HepMC3 3.2.0 REQUIRED HINTS ${HepMC3} ${HepMC3_DIR} )
0042 message ( "-- HepMC3 library found at ${HEPMC3_LIB}" )
0043 # message ( "-- HepMC3 headers found in ${HEPMC3_INCLUDE_DIR}" )
0044 add_definitions(-DeAST_USE_HepMC3)
0045 endif()
0046
0047 #----------------------------------------------------------------------------
0048 # Locate sources and headers for this project
0049 # NB: headers are included so they will show up in IDEs
0050 #
0051 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Core/include
0052 ${CMAKE_CURRENT_SOURCE_DIR}/PhysicsList/Base/include
0053 ${CMAKE_CURRENT_SOURCE_DIR}/PrimGenInterface/include
0054 ${CMAKE_CURRENT_SOURCE_DIR}/Components/Base/include
0055 ${CMAKE_CURRENT_SOURCE_DIR}/Components/Beampipe/include
0056 ${Geant4_INCLUDE_DIR})
0057 file(GLOB sources ${PROJECT_SOURCE_DIR}/Core/src/*.cc
0058 ${PROJECT_SOURCE_DIR}/PhysicsList/Base/src/*.cc
0059 ${PROJECT_SOURCE_DIR}/PrimGenInterface/src/*.cc
0060 ${PROJECT_SOURCE_DIR}/Components/Base/src/*.cc
0061 ${PROJECT_SOURCE_DIR}/Components/Beampipe/src/*.cc
0062 )
0063 file(GLOB headers ${PROJECT_SOURCE_DIR}/Core/include/*.hh
0064 ${PROJECT_SOURCE_DIR}/PhysicsList/Base/include/*.hh
0065 ${PROJECT_SOURCE_DIR}/PrimGenInterface/include/*.hh
0066 ${PROJECT_SOURCE_DIR}/Components/Base/include/*.hh
0067 ${PROJECT_SOURCE_DIR}/Components/Beampipe/include/*.hh
0068 )
0069
0070 # In order to keep using glob, we have to manually remove optional sources
0071 if(eAST_USE_HepMC3)
0072 include_directories ( ${HEPMC3_INCLUDE_DIR} )
0073 list(APPEND headers "${PROJECT_SOURCE_DIR}/PrimGenInterface/include/HepMC_3_2_4_ReaderFactory.h")
0074 else()
0075 list(REMOVE_ITEM sources "${PROJECT_SOURCE_DIR}/PrimGenInterface/src/eASTHepMC3Interface.cc")
0076 list(REMOVE_ITEM headers "${PROJECT_SOURCE_DIR}/PrimGenInterface/include/eASTHepMC3Interface.hh")
0077 list(REMOVE_ITEM headers "${PROJECT_SOURCE_DIR}/PrimGenInterface/include/HepMC_3_2_4_ReaderFactory.h")
0078 endif()
0079
0080 #----------------------------------------------------------------------------
0081 # Add the field maps
0082 #
0083 file(DOWNLOAD
0084 https://github.com/eic/BeastMagneticField/raw/master/data/EIC_Magnetic_Field_Map_2021_05_07_radial_coords_%5Bcm%5D_%5BT%5D.120000.lines.Bmap
0085 ${PROJECT_SOURCE_DIR}/Solenoid/data/EIC_Magnetic_Field_Map_2021_05_07_radial_coords__cm___T_.120000.lines.Bmap
0086 )
0087 file(DOWNLOAD
0088 https://github.com/eic/BeastMagneticField/raw/master/data/EIC_v.0.1.0_Magnetic_Field_Map_2021_05_28_radial_coords_%5Bcm%5D_%5BT%5D.401301.line.Bmap
0089 ${PROJECT_SOURCE_DIR}/Solenoid/data/EIC_v.0.1.0_Magnetic_Field_Map_2021_05_28_radial_coords__cm___T_.401301.line.Bmap
0090 )
0091
0092 #----------------------------------------------------------------------------
0093 # Add the executable, and link it to external libraries
0094 #
0095 add_executable(eAST Core/eAST.cc ${sources} ${headers})
0096 if(eAST_USE_HepMC3)
0097 target_link_libraries(eAST ${Geant4_LIBRARIES} ${HEPMC3_LIB} )
0098 else()
0099 target_link_libraries(eAST ${Geant4_LIBRARIES})
0100 endif()
0101
0102 #----------------------------------------------------------------------------
0103 # Copy all scripts to the build directory, i.e. the directory in which we
0104 # build RS. This is so that we can run the executable directly because it
0105 # relies on these scripts being in the current working directory.
0106 #
0107 set(RS_SCRIPTS
0108 gps_point.mac run.mac vis.mac ecce.mac athena.mac
0109 )
0110
0111 foreach(_script ${RS_SCRIPTS})
0112 configure_file(
0113 ${PROJECT_SOURCE_DIR}/Core/${_script}
0114 ${PROJECT_BINARY_DIR}/${_script}
0115 COPYONLY
0116 )
0117 endforeach()
0118
0119 #----------------------------------------------------------------------------
0120 # Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
0121 #
0122 install(TARGETS eAST
0123 EXPORT east-export
0124 DESTINATION bin)
0125
0126
0127 #----------------------------------------------------------------------------
0128 # Install data to CMAKE_INSTALL_FULL_DATADIR/east
0129 install(
0130 DIRECTORY ${PROJECT_SOURCE_DIR}/Solenoid/data
0131 DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/east/Solenoid )
0132
0133 install(
0134 DIRECTORY ${PROJECT_SOURCE_DIR}/Core/data
0135 DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/east/Core )
0136
0137 install(
0138 DIRECTORY ${PROJECT_SOURCE_DIR}/Components/Beampipe/data
0139 DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/east/Components/Beampipe )
0140
0141 # Install scripts to CMAKE_INSTALL_FULL_DATADIR/east
0142 foreach(_script ${RS_SCRIPTS})
0143 install(
0144 FILES ${PROJECT_SOURCE_DIR}/Core/${_script}
0145 DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/east
0146 )
0147 endforeach()
0148
0149
0150
0151 #----------------------------------------------------------------------------
0152 ## Generate and install cmake configuration file
0153 install(EXPORT east-export
0154 FILE
0155 eastConfig.cmake
0156 NAMESPACE
0157 east::
0158 DESTINATION
0159 cmake
0160 )
0161
0162
0163