Warning, /geant4/examples/extended/medical/dna/moleculardna/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(molecular)
0005
0006 #----------------------------------------------------------------------------
0007 # Find Geant4 package
0008 option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
0009 if (WITH_GEANT4_UIVIS)
0010 find_package(Geant4 REQUIRED ui_all vis_all)
0011 else ()
0012 find_package(Geant4 REQUIRED)
0013 endif ()
0014
0015 #----------------------------------------------------------------------------
0016 # Setup Geant4 include directories and compile definitions
0017 # Setup include directory for this project
0018 #
0019 include_directories(${PROJECT_SOURCE_DIR}/include)
0020 include(${Geant4_USE_FILE})
0021
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 "geometries.tar.gz")
0028 set(GEOMETRY_FOlDER_NAME "geometries")
0029 set(GEOMETRY_LOCAL_FILENAME "${PROJECT_BINARY_DIR}/${GEOMETRY_FILE_NAME}")
0030 set(GEOMETRY_DATASETS_URL
0031 "https://cern.ch/geant4-data/datasets/examples/extended/medical/dna/moleculardna/1/${GEOMETRY_FILE_NAME}")
0032 set(HASH_MD5 "1bca28e1260a2afeda86514c4d42a921")
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 "geometries-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 "geometries-data: download FAILED: ${DownloadReturnStatus},
0050 This example needs internet for the geometry data file,
0051 even configuring done and complied.
0052 Please, check your connection.
0053 ")
0054 else ()
0055 message(STATUS "geometries-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: geometries.tar.gz")
0066 execute_process(
0067 COMMAND ${CMAKE_COMMAND} -E tar xfz "${GEOMETRY_LOCAL_FILENAME}"
0068 OUTPUT_QUIET
0069 RESULT_VARIABLE __geometries_untar_result
0070 )
0071 if (__geometries_untar_result)
0072 message(FATAL_ERROR "geometries-data: failed to untar file : ${GEOMETRY_LOCAL_FILENAME}")
0073 else ()
0074 message(STATUS "geometries-data: untarred in '${PROJECT_BINARY_DIR}/geometries' 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 # Locate sources and headers for this project
0083 # NB: headers are included so they will show up in IDEs
0084 #
0085 file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
0086 file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
0087
0088 #----------------------------------------------------------------------------
0089 # Add the executable, and link it to the Geant4 libraries
0090 #
0091 add_executable(molecular molecular.cc ${sources} ${headers})
0092 target_link_libraries(molecular ${Geant4_LIBRARIES})
0093
0094 #----------------------------------------------------------------------------
0095 # Copy all scripts to the build directory, i.e. the directory in which we
0096 # build molecular_proj. This is so that we can run the executable directly because
0097 # it relies on these scripts being in the current working directory.
0098 #
0099 file(GLOB molecular_SCRIPTS
0100 ${PROJECT_SOURCE_DIR}/*.in
0101 ${PROJECT_SOURCE_DIR}/*.mac
0102 ${PROJECT_SOURCE_DIR}/*.C)
0103
0104 foreach (_script ${molecular_SCRIPTS})
0105 configure_file(
0106 ${_script}
0107 ${PROJECT_BINARY_DIR}/.
0108 COPYONLY
0109 )
0110 endforeach ()
0111
0112 #----------------------------------------------------------------------------
0113 # Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
0114 #
0115 install(TARGETS molecular DESTINATION bin)