Back to home page

EIC code displayed by LXR

 
 

    


Warning, /geant4/examples/extended/medical/DICOM/cmake/DownloadDICOMData.cmake is written in an unsupported language. File is not indexed.

0001 # Script to download DICOM_HEAD data for DICOM example
0002 # called from the DICOM example CMakeLists.txt
0003 #
0004 # The script will download the G4DICOM.1.0.tar.gz from the Geant4 Download site
0005 # and unpack it in the example build directory.
0006 # An error is issued if the download or unpack operation fails.
0007 #
0008 # Inspired by test65/DownloadLENDData.cmake
0009 
0010 set(DICOMDATA_FILENAME "G4DICOM.1.1.tar.gz")
0011 set(DICOMDATA_WORKING_DIR "${CMAKE_CURRENT_BINARY_DIR}")
0012 set(DICOMDATA_LOCAL_FILENAME "${DICOMDATA_WORKING_DIR}/${DICOMDATA_FILENAME}")
0013 set(DICOMDATA_LOCAL_ROOTDIR "${DICOMDATA_WORKING_DIR}/DICOM1.1")
0014 set(DICOMDATA_INSTALL_DIR "${Geant4_DATASET_G4ENSDFSTATE_PATH}")
0015 get_filename_component(DICOMDATA_INSTALL_DIR "${DICOMDATA_INSTALL_DIR}" PATH)
0016 
0017 # The Geant4 Download site
0018 set(DICOM_DATA_URL "http://cern.ch/geant4/support/source/${DICOMDATA_FILENAME}")
0019 message(STATUS "DICOM_DATA_URL ${DICOM_DATA_URL}")
0020 
0021 # Return if data directory is already present
0022 set(DICOMDATA_NEEDS_DOWNLOAD TRUE)
0023 if (EXISTS "${DICOMDATA_LOCAL_ROOTDIR}")
0024   message(STATUS "DICOM example: DICOM_HEAD data found, skipping download")
0025   message(STATUS "Installing '${DICOMDATA_LOCAL_ROOTDIR}' to '${DICOMDATA_INSTALL_DIR}'...")
0026 
0027   install(DIRECTORY ${DICOMDATA_LOCAL_ROOTDIR}
0028       DESTINATION ${DICOMDATA_INSTALL_DIR})
0029   return()
0030 endif()
0031 
0032 # Download tar file
0033 message(STATUS "DICOM example: DICOM_HEAD data not found, going to download")
0034 file(DOWNLOAD "${DICOM_DATA_URL}" "${DICOMDATA_LOCAL_FILENAME}"
0035   SHOW_PROGRESS
0036   INACTIVITY_TIMEOUT 1200
0037   TIMEOUT 3000
0038   STATUS DownloadStatus
0039 )
0040 if(DownloadReturnStatus)
0041   message(ERROR  "DICOM example: download data FAILED: ${DownloadReturnStatus}, ${DownloadStringReturnStatus}")
0042   return()
0043 else()
0044   message(STATUS "DICOM example: download data OK")
0045 endif()
0046 
0047 # Unpack downloaded tarball
0048 message(STATUS "Going to unpack: ${DICOMDATA_LOCAL_FILENAME}")
0049 execute_process(
0050   COMMAND ${CMAKE_COMMAND} -E tar xfz "${DICOMDATA_LOCAL_FILENAME}"
0051   WORKING_DIRECTORY ${DICOMDATA_WORKING_DIR}
0052   OUTPUT_QUIET
0053   RESULT_VARIABLE __dicomdata_untar_result
0054 )
0055 
0056 if(__dicomdata_untar_result)
0057   message(ERROR  "DICOM example: failed to untar file: ${DICOMDATA_LOCAL_FILENAME}")
0058 else()
0059   message(STATUS "DICOM example: untarred '${DICOMDATA_LOCAL_FILENAME}' OK")
0060 endif()
0061 
0062 message(STATUS "Installing '${DICOMDATA_LOCAL_ROOTDIR}' to '${DICOMDATA_INSTALL_DIR}'...")
0063 
0064 install(DIRECTORY ${DICOMDATA_LOCAL_ROOTDIR}
0065     DESTINATION ${DICOMDATA_INSTALL_DIR})