comparison Resources/CMake/DownloadPackage.cmake @ 21:29bfa3095207

check return code in download
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 31 Jul 2012 17:56:27 +0200
parents 67a6978503b7
children 09718f2fc5cb
comparison
equal deleted inserted replaced
20:a56b6a8b89ba 21:29bfa3095207
32 if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux") 32 if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux")
33 if ("${TMP_EXTENSION}" STREQUAL "zip") 33 if ("${TMP_EXTENSION}" STREQUAL "zip")
34 execute_process( 34 execute_process(
35 COMMAND sh -c "unzip ${TMP_PATH} ${UncompressArguments}" 35 COMMAND sh -c "unzip ${TMP_PATH} ${UncompressArguments}"
36 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 36 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
37 ) 37 RESULT_VARIABLE Failure
38 )
38 elseif (("${TMP_EXTENSION}" STREQUAL "gz") OR ("${TMP_EXTENSION}" STREQUAL "tgz")) 39 elseif (("${TMP_EXTENSION}" STREQUAL "gz") OR ("${TMP_EXTENSION}" STREQUAL "tgz"))
39 #message("tar xvfz ${TMP_PATH} ${UncompressArguments}") 40 #message("tar xvfz ${TMP_PATH} ${UncompressArguments}")
40 execute_process( 41 execute_process(
41 COMMAND sh -c "tar xvfz ${TMP_PATH} ${UncompressArguments}" 42 COMMAND sh -c "tar xvfz ${TMP_PATH} ${UncompressArguments}"
42 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 43 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
44 RESULT_VARIABLE Failure
43 ) 45 )
44 elseif ("${TMP_EXTENSION}" STREQUAL "bz2") 46 elseif ("${TMP_EXTENSION}" STREQUAL "bz2")
45 execute_process( 47 execute_process(
46 COMMAND sh -c "tar xvfj ${TMP_PATH} ${UncompressArguments}" 48 COMMAND sh -c "tar xvfj ${TMP_PATH} ${UncompressArguments}"
47 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 49 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
50 RESULT_VARIABLE Failure
48 ) 51 )
49 else() 52 else()
50 message(FATAL_ERROR "Unknown package format.") 53 message(FATAL_ERROR "Unknown package format.")
51 endif() 54 endif()
52 55
55 58
56 if (("${TMP_EXTENSION}" STREQUAL "gz") OR ("${TMP_EXTENSION}" STREQUAL "tgz")) 59 if (("${TMP_EXTENSION}" STREQUAL "gz") OR ("${TMP_EXTENSION}" STREQUAL "tgz"))
57 execute_process( 60 execute_process(
58 COMMAND ${ZIP_EXECUTABLE} e ${TMP_PATH} 61 COMMAND ${ZIP_EXECUTABLE} e ${TMP_PATH}
59 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 62 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
63 RESULT_VARIABLE Failure
60 ) 64 )
65
66 if (Failure)
67 message(FATAL_ERROR "Error while running the uncompression tool")
68 endif()
69
61 set(ARGS ${UncompressArguments}) 70 set(ARGS ${UncompressArguments})
62 SEPARATE_ARGUMENTS(ARGS) 71 SEPARATE_ARGUMENTS(ARGS)
63 list(LENGTH ARGS TMP_LENGTH) 72 list(LENGTH ARGS TMP_LENGTH)
64 73
65 if ("${TMP_EXTENSION}" STREQUAL "tgz") 74 if ("${TMP_EXTENSION}" STREQUAL "tgz")
70 79
71 if (TMP_LENGTH EQUAL 0) 80 if (TMP_LENGTH EQUAL 0)
72 execute_process( 81 execute_process(
73 COMMAND ${ZIP_EXECUTABLE} x ${TMP_FILENAME2} 82 COMMAND ${ZIP_EXECUTABLE} x ${TMP_FILENAME2}
74 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 83 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
84 RESULT_VARIABLE Failure
75 ) 85 )
76 else() 86 else()
77 foreach(SUBDIR ${ARGS}) 87 foreach(SUBDIR ${ARGS})
78 execute_process( 88 execute_process(
79 COMMAND ${ZIP_EXECUTABLE} x "-i!${SUBDIR}" "${TMP_FILENAME2}" 89 COMMAND ${ZIP_EXECUTABLE} x "-i!${SUBDIR}" "${TMP_FILENAME2}"
80 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 90 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
91 RESULT_VARIABLE Failure
81 ) 92 )
93
94 if (Failure)
95 message(FATAL_ERROR "Error while running the uncompression tool")
96 endif()
82 endforeach() 97 endforeach()
83 endif() 98 endif()
84 elseif ("${TMP_EXTENSION}" STREQUAL "zip") 99 elseif ("${TMP_EXTENSION}" STREQUAL "zip")
85 execute_process( 100 execute_process(
86 COMMAND ${ZIP_EXECUTABLE} x ${TMP_PATH} 101 COMMAND ${ZIP_EXECUTABLE} x ${TMP_PATH}
87 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 102 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
103 RESULT_VARIABLE Failure
88 ) 104 )
89 else() 105 else()
90 message(FATAL_ERROR "Support your platform here") 106 message(FATAL_ERROR "Support your platform here")
91 endif() 107 endif()
92 else() 108 else()
93 message(FATAL_ERROR "Support your platform here") 109 message(FATAL_ERROR "Support your platform here")
110 endif()
111
112 if (Failure)
113 message(FATAL_ERROR "Error while running the uncompression tool")
94 endif() 114 endif()
95 115
96 if (NOT IS_DIRECTORY "${TargetDirectory}") 116 if (NOT IS_DIRECTORY "${TargetDirectory}")
97 message(FATAL_ERROR "The package was not uncompressed at the proper location. Check the CMake instructions.") 117 message(FATAL_ERROR "The package was not uncompressed at the proper location. Check the CMake instructions.")
98 endif() 118 endif()