changeset 21:29bfa3095207

check return code in download
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 31 Jul 2012 17:56:27 +0200
parents a56b6a8b89ba
children 1bc6327d1de3
files Resources/CMake/DownloadPackage.cmake
diffstat 1 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Resources/CMake/DownloadPackage.cmake	Tue Jul 24 10:44:19 2012 +0200
+++ b/Resources/CMake/DownloadPackage.cmake	Tue Jul 31 17:56:27 2012 +0200
@@ -34,17 +34,20 @@
         execute_process(
           COMMAND sh -c "unzip ${TMP_PATH} ${UncompressArguments}"
           WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
-          )
+          RESULT_VARIABLE Failure
+        )
       elseif (("${TMP_EXTENSION}" STREQUAL "gz") OR ("${TMP_EXTENSION}" STREQUAL "tgz"))
         #message("tar xvfz ${TMP_PATH} ${UncompressArguments}")
         execute_process(
           COMMAND sh -c "tar xvfz ${TMP_PATH} ${UncompressArguments}"
           WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+          RESULT_VARIABLE Failure
           )
       elseif ("${TMP_EXTENSION}" STREQUAL "bz2")
         execute_process(
           COMMAND sh -c "tar xvfj ${TMP_PATH} ${UncompressArguments}"
           WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+          RESULT_VARIABLE Failure
           )
       else()
         message(FATAL_ERROR "Unknown package format.")
@@ -57,7 +60,13 @@
         execute_process(
           COMMAND ${ZIP_EXECUTABLE} e ${TMP_PATH}
           WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+          RESULT_VARIABLE Failure
           )
+
+        if (Failure)
+          message(FATAL_ERROR "Error while running the uncompression tool")
+        endif()
+
         set(ARGS ${UncompressArguments})
         SEPARATE_ARGUMENTS(ARGS)
         list(LENGTH ARGS TMP_LENGTH)
@@ -72,19 +81,26 @@
           execute_process(
             COMMAND ${ZIP_EXECUTABLE} x ${TMP_FILENAME2}
             WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+            RESULT_VARIABLE Failure
             )
         else()
           foreach(SUBDIR ${ARGS})
             execute_process(
               COMMAND ${ZIP_EXECUTABLE} x "-i!${SUBDIR}" "${TMP_FILENAME2}"
               WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+              RESULT_VARIABLE Failure
               )
+
+            if (Failure)
+              message(FATAL_ERROR "Error while running the uncompression tool")
+            endif()
           endforeach()
         endif()
       elseif ("${TMP_EXTENSION}" STREQUAL "zip")
         execute_process(
           COMMAND ${ZIP_EXECUTABLE} x ${TMP_PATH}
           WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+          RESULT_VARIABLE Failure
           )
       else()
         message(FATAL_ERROR "Support your platform here")
@@ -92,6 +108,10 @@
     else()
       message(FATAL_ERROR "Support your platform here")
     endif()
+   
+    if (Failure)
+      message(FATAL_ERROR "Error while running the uncompression tool")
+    endif()
 
     if (NOT IS_DIRECTORY "${TargetDirectory}")
       message(FATAL_ERROR "The package was not uncompressed at the proper location. Check the CMake instructions.")