Geant4 Cross Reference |
>> 1 # $Id: CMakeLists.txt 68058 2013-03-13 14:47:43Z gcosmo $ 1 2 2 #--------------------------------------------- 3 #---------------------------------------------------------------------------- 3 # Setup the project 4 # Setup the project 4 cmake_minimum_required(VERSION 3.16...3.27) << 5 cmake_minimum_required(VERSION 2.6 FATAL_ERROR) 5 project(B1Con) 6 project(B1Con) 6 7 7 #--------------------------------------------- 8 #---------------------------------------------------------------------------- 8 # Find Geant4 package, activating all availabl 9 # Find Geant4 package, activating all available UI and Vis drivers by default 9 # You can set WITH_GEANT4_UIVIS to OFF via the 10 # You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake/cmake-gui 10 # to build a batch mode only executable 11 # to build a batch mode only executable 11 # 12 # 12 option(WITH_GEANT4_UIVIS "Build example with G 13 option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON) 13 if(WITH_GEANT4_UIVIS) 14 if(WITH_GEANT4_UIVIS) 14 find_package(Geant4 REQUIRED ui_all vis_all) 15 find_package(Geant4 REQUIRED ui_all vis_all) 15 else() 16 else() 16 find_package(Geant4 REQUIRED) 17 find_package(Geant4 REQUIRED) 17 endif() 18 endif() 18 19 19 #--------------------------------------------- 20 #---------------------------------------------------------------------------- 20 # Setup Geant4 include directories and compile 21 # Setup Geant4 include directories and compile definitions 21 # Setup include directory for this project 22 # Setup include directory for this project 22 # 23 # 23 include(${Geant4_USE_FILE}) 24 include(${Geant4_USE_FILE}) 24 include_directories(${PROJECT_SOURCE_DIR}/incl 25 include_directories(${PROJECT_SOURCE_DIR}/include) 25 26 26 27 27 #--------------------------------------------- 28 #---------------------------------------------------------------------------- 28 # Locate sources and headers for this project 29 # Locate sources and headers for this project 29 # NB: headers are included so they will show u 30 # NB: headers are included so they will show up in IDEs 30 # 31 # 31 file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*. 32 file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc) 32 file(GLOB headers ${PROJECT_SOURCE_DIR}/includ 33 file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh) 33 34 34 #--------------------------------------------- 35 #---------------------------------------------------------------------------- 35 # Add the executable, and link it to the Geant 36 # Add the executable, and link it to the Geant4 libraries 36 # 37 # 37 add_executable(exampleB1Con exampleB1Con.cc ${ 38 add_executable(exampleB1Con exampleB1Con.cc ${sources} ${headers}) 38 target_link_libraries(exampleB1Con ${Geant4_LI 39 target_link_libraries(exampleB1Con ${Geant4_LIBRARIES}) 39 40 40 #--------------------------------------------- 41 #---------------------------------------------------------------------------- 41 # Copy all scripts to the build directory, i.e 42 # Copy all scripts to the build directory, i.e. the directory in which we 42 # build B1. This is so that we can run the exe 43 # build B1. This is so that we can run the executable directly because it 43 # relies on these scripts being in the current 44 # relies on these scripts being in the current working directory. 44 # 45 # 45 set(EXAMPLEB1_SCRIPTS 46 set(EXAMPLEB1_SCRIPTS 46 exampleB1Con.in 47 exampleB1Con.in 47 exampleB1Con.out 48 exampleB1Con.out >> 49 init.mac 48 init_vis.mac 50 init_vis.mac 49 run1.mac 51 run1.mac 50 run2.mac 52 run2.mac 51 vis.mac 53 vis.mac 52 ) 54 ) 53 55 54 foreach(_script ${EXAMPLEB1_SCRIPTS}) 56 foreach(_script ${EXAMPLEB1_SCRIPTS}) 55 configure_file( 57 configure_file( 56 ${PROJECT_SOURCE_DIR}/${_script} 58 ${PROJECT_SOURCE_DIR}/${_script} 57 ${PROJECT_BINARY_DIR}/${_script} 59 ${PROJECT_BINARY_DIR}/${_script} 58 COPYONLY 60 COPYONLY 59 ) 61 ) 60 endforeach() 62 endforeach() 61 63 62 #--------------------------------------------- 64 #---------------------------------------------------------------------------- 63 # For internal Geant4 use - but has no effect 65 # For internal Geant4 use - but has no effect if you build this 64 # example standalone 66 # example standalone 65 # 67 # 66 add_custom_target(B1Con DEPENDS exampleB1Con) 68 add_custom_target(B1Con DEPENDS exampleB1Con) 67 69 68 #--------------------------------------------- 70 #---------------------------------------------------------------------------- 69 # Install the executable to 'bin' directory un 71 # Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX 70 # 72 # 71 install(TARGETS exampleB1Con DESTINATION bin) 73 install(TARGETS exampleB1Con DESTINATION bin) 72 74 73 75