Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Modules / DownloadFile.cmake
blobdb45db9f9a4784bf01907356b43afb89c2a351a8
2 # Use 'cmake -Dremote=${url} -Dlocal=${filename} -Dtimeout=${seconds}
3 #   -P DownloadFile.cmake' to call this script...
5 if(NOT DEFINED remote)
6   message(FATAL_ERROR "error: required variable 'remote' not defined...")
7 endif()
9 if(NOT DEFINED local)
10   message(FATAL_ERROR "error: required variable 'local' not defined...")
11 endif()
13 if(NOT DEFINED timeout)
14   set(timeout 30)
15 endif(NOT DEFINED timeout)
17 message(STATUS "info: downloading '${remote}'...")
18 file(DOWNLOAD "${remote}" "${local}" TIMEOUT ${timeout} STATUS status LOG log)
20 list(GET status 0 status_code)
21 list(GET status 1 status_string)
23 if(NOT status_code EQUAL 0)
24   message(FATAL_ERROR "error: download of '${remote}' failed
25 status_code: ${status_code}
26 status_string: ${status_string}
27 log: ${log}
29 endif()
31 message(STATUS "info: done downloading '${remote}'...")