Warning, /geant4/examples/advanced/dna/cellularPhantom/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.21)
0004 project(cellularPhantom)
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 # Dowload geometry data file
0025 set(GEOMETRY_NEEDS_DOWNLOAD TRUE)
0026 set(GEOMETRY_NEEDS_UNPACK_DELETE TRUE)
0027 set(GEOMETRY_FILE_NAME "phantoms.tar.gz")
0028 set(GEOMETRY_FOlDER_NAME "phantoms")
0029 set(GEOMETRY_LOCAL_FILENAME "${PROJECT_BINARY_DIR}/${GEOMETRY_FILE_NAME}")
0030 set(GEOMETRY_DATASETS_URL
0031 "https://cern.ch/geant4-data/datasets/examples/advanced/dna/cellularPhantom/0/${GEOMETRY_FILE_NAME}")
0032 set(HASH_MD5 "b663329eaa7d93396689506a798a4577")
0033
0034 if (EXISTS "${GEOMETRY_FOlDER_NAME}")
0035 set(GEOMETRY_NEEDS_DOWNLOAD FALSE)
0036 endif ()
0037
0038
0039 if (GEOMETRY_NEEDS_DOWNLOAD)
0040 message(STATUS "phantoms-data: attempting download: ${GEOMETRY_DATASETS_URL} ...")
0041 file(DOWNLOAD "${GEOMETRY_DATASETS_URL}" "${GEOMETRY_LOCAL_FILENAME}"
0042 INACTIVITY_TIMEOUT 500
0043 TIMEOUT 500
0044 STATUS DownloadStatus
0045 )
0046
0047 list(GET DownloadStatus 0 DownloadReturnStatus)
0048 if (DownloadReturnStatus)
0049 message(FATAL_ERROR "phantoms-data: download FAILED: ${DownloadReturnStatus},
0050 This example needs internet for the phantoms data file,
0051 even configuring done and complied.
0052 Please, check your connection.
0053 ")
0054 else ()
0055 message(STATUS "phantoms-data: download OK")
0056 endif ()
0057 endif ()
0058
0059
0060 if (EXISTS "${GEOMETRY_FOlDER_NAME}")
0061 set(GEOMETRY_NEEDS_UNPACK_DELETE FALSE)
0062 endif ()
0063
0064 if (GEOMETRY_NEEDS_UNPACK_DELETE)
0065 message(STATUS "Going to unpack: phantoms.tar.gz")
0066 execute_process(
0067 COMMAND ${CMAKE_COMMAND} -E tar xfz "${GEOMETRY_LOCAL_FILENAME}"
0068 OUTPUT_QUIET
0069 RESULT_VARIABLE __phantoms_untar_result
0070 )
0071 if (__phantoms_untar_result)
0072 message(FATAL_ERROR "phantoms-data: failed to untar file : ${GEOMETRY_LOCAL_FILENAME}")
0073 else ()
0074 message(STATUS "phantoms-data: untarred in '${PROJECT_BINARY_DIR}/phantoms' OK")
0075 endif ()
0076 message(STATUS "Going to delete: ${GEOMETRY_LOCAL_FILENAME}")
0077 execute_process(
0078 COMMAND rm "${GEOMETRY_LOCAL_FILENAME}"
0079 )
0080 endif ()
0081
0082 #----------------------------------------------------------------------------
0083 # Locate sources and headers for this project
0084 #
0085 include_directories(${PROJECT_SOURCE_DIR}/include
0086 ${Geant4_INCLUDE_DIR})
0087 file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
0088 file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
0089
0090 #----------------------------------------------------------------------------
0091 # Add the executable, and link it to the Geant4 libraries
0092 #
0093 add_executable(cellularPhantom cellularPhantom.cc ${sources} ${headers})
0094 target_link_libraries(cellularPhantom ${Geant4_LIBRARIES})
0095
0096 #----------------------------------------------------------------------------
0097 # Copy all scripts to the build directory, i.e. the directory in which we
0098 # build cellule. This is so that we can run the executable directly because it
0099 # relies on these scripts being in the current working directory.
0100 #
0101 set(cellule_SCRIPTS
0102 vis.mac run.mac plot.C
0103 )
0104
0105 foreach(_script ${cellule_SCRIPTS})
0106 configure_file(
0107 ${PROJECT_SOURCE_DIR}/${_script}
0108 ${PROJECT_BINARY_DIR}/${_script}
0109 COPYONLY
0110 )
0111 endforeach()
0112
0113 #----------------------------------------------------------------------------
0114 # Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
0115 #
0116 install(TARGETS cellularPhantom DESTINATION bin)