Warning, /geant4/examples/advanced/purging_magnet/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(purging_magnet)
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 #
0025 set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
0026
0027 #----------------------------------------------------------------------------
0028 # Add option to debug
0029 #
0030 option(DEBUG_INTERPOLATING_FIELD "Debug setting" OFF)
0031 if(DEBUG_INTERPOLATING_FIELD)
0032 add_definitions(-DDEBUG_INTERPOLATING_FIELD)
0033 endif()
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(PurgMag PurgMag.cc ${sources} ${headers})
0047 target_link_libraries(PurgMag ${Geant4_LIBRARIES})
0048
0049 #----------------------------------------------------------------------------
0050 # Copy all scripts to the build directory, i.e. the directory in which we
0051 # build purging_magnet. This is so that we can run the executable directly because it
0052 # relies on these scripts being in the current working directory.
0053 #
0054 set(purging_magnet_SCRIPTS
0055 MacroTesting.mac vis.mac PurgMag3D.TABLE
0056 )
0057
0058 foreach(_script ${purging_magnet_SCRIPTS})
0059 configure_file(
0060 ${PROJECT_SOURCE_DIR}/${_script}
0061 ${PROJECT_BINARY_DIR}/${_script}
0062 COPYONLY
0063 )
0064 endforeach()
0065
0066 #----------------------------------------------------------------------------
0067 # Add program to the project targets
0068 # (this avoids the need of typing the program name after make)
0069 #
0070 add_custom_target(purging_magnet DEPENDS PurgMag)
0071
0072 #----------------------------------------------------------------------------
0073 # Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
0074 #
0075 install(TARGETS PurgMag DESTINATION bin)
0076