Warning, /geant4/examples/extended/optical/OpNovice/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(OpNovice)
0005 #add_definitions(-DGEANT4_USE_GDML)
0006 add_compile_definitions(GEANT4_USE_GDML)
0007 #make using gdml the default
0008 OPTION( GEANT4_USE_GDML "Use gdml Option" ON)
0009 # printout the value of GEANT4_USE_GDML
0010 MESSAGE("?GEANT4_USE_GDML " ${GEANT4_USE_GDML})
0011 #----------------------------------------------------------------------------
0012 # Find Geant4 package, activating all available UI and Vis drivers by default
0013 # You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake/cmake-gui
0014 # to build a batch mode only executable
0015 #
0016 option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
0017 if(WITH_GEANT4_UIVIS)
0018 find_package(Geant4 REQUIRED ui_all vis_all)
0019 else()
0020 find_package(Geant4 REQUIRED)
0021 endif()
0022
0023 #----------------------------------------------------------------------------
0024 # Setup Geant4 include directories and compile definitions
0025 #
0026 include(${Geant4_USE_FILE})
0027
0028 #----------------------------------------------------------------------------
0029 # Locate sources and headers for this project
0030 #
0031 include_directories(${PROJECT_SOURCE_DIR}/include
0032 ${Geant4_INCLUDE_DIR})
0033 file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
0034 file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
0035 if (GEANT4_USE_GDML)
0036 file(GLOB detectors ${PROJECT_SOURCE_DIR}/gdml/*.gdml)
0037 endif()
0038 file(GLOB macros ${PROJECT_SOURCE_DIR}/*.mac)
0039 file(GLOB inputs ${PROJECT_SOURCE_DIR}/*.in)
0040 if (NOT GEANT4_USE_GDML)
0041 list(REMOVE_ITEM sources ${PROJECT_SOURCE_DIR}/src/OpNoviceGDMLDetectorConstructionMessenger.cc)
0042 list(REMOVE_ITEM sources ${PROJECT_SOURCE_DIR}/src/OpNoviceGDMLDetectorConstruction.cc)
0043 list(REMOVE_ITEM headers ${PROJECT_SOURCE_DIR}/include/OpNoviceGDMLDetectorConstructionMessenger.hh)
0044 list(REMOVE_ITEM headers ${PROJECT_SOURCE_DIR}/include/OpNoviceGDMLDetectorConstruction.hh)
0045 endif()
0046 #----------------------------------------------------------------------------
0047 # Add the executable, and link it to the Geant4 libraries
0048 #
0049 add_executable(OpNovice OpNovice.cc ${sources} ${headers})
0050 target_link_libraries(OpNovice ${Geant4_LIBRARIES} )
0051
0052 #----------------------------------------------------------------------------
0053 # Copy all scripts to the build directory, i.e. the directory in which we
0054 # build OpNovice. This is so that we can run the executable directly because it
0055 # relies on these scripts being in the current working directory.
0056 #
0057 set(OpNovice_SCRIPTS
0058 OpNovice.out
0059 OpNovice.in
0060 optPhoton.mac
0061 gui.mac
0062 vis.mac
0063 )
0064
0065 foreach(_script ${OpNovice_SCRIPTS})
0066 configure_file(
0067 ${PROJECT_SOURCE_DIR}/${_script}
0068 ${PROJECT_BINARY_DIR}/${_script}
0069 COPYONLY
0070 )
0071 endforeach()
0072
0073 #----------------------------------------------------------------------------
0074 # Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
0075 #
0076 install(TARGETS OpNovice DESTINATION bin)
0077 if (GEANT4_USE_GDML)
0078 install(FILES ${detectors} ${macros} ${inputs} DESTINATION bin)
0079 else()
0080 install(FILES ${macros} ${inputs} DESTINATION bin)
0081 endif()