summaryrefslogtreecommitdiffstats
path: root/Modules/DownloadFile.cmake
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2008-12-04 18:27:48 (GMT)
committerDavid Cole <david.cole@kitware.com>2008-12-04 18:27:48 (GMT)
commit930827d48c39b34e8950cae1a417e53bdbdade0e (patch)
tree89732d31474a3050e88883b5efd9060524317471 /Modules/DownloadFile.cmake
parent7c2445212ebfeac4f4c6408a809c77024982f715 (diff)
downloadCMake-930827d48c39b34e8950cae1a417e53bdbdade0e.zip
CMake-930827d48c39b34e8950cae1a417e53bdbdade0e.tar.gz
CMake-930827d48c39b34e8950cae1a417e53bdbdade0e.tar.bz2
ENH: First draft of add_external_project functionality. Tweaks, dashboard fixing, more tests and documentation certain to follow as it gets used by others...
Diffstat (limited to 'Modules/DownloadFile.cmake')
-rw-r--r--Modules/DownloadFile.cmake31
1 files changed, 31 insertions, 0 deletions
diff --git a/Modules/DownloadFile.cmake b/Modules/DownloadFile.cmake
new file mode 100644
index 0000000..db45db9
--- /dev/null
+++ b/Modules/DownloadFile.cmake
@@ -0,0 +1,31 @@
+#
+# Use 'cmake -Dremote=${url} -Dlocal=${filename} -Dtimeout=${seconds}
+# -P DownloadFile.cmake' to call this script...
+#
+if(NOT DEFINED remote)
+ message(FATAL_ERROR "error: required variable 'remote' not defined...")
+endif()
+
+if(NOT DEFINED local)
+ message(FATAL_ERROR "error: required variable 'local' not defined...")
+endif()
+
+if(NOT DEFINED timeout)
+ set(timeout 30)
+endif(NOT DEFINED timeout)
+
+message(STATUS "info: downloading '${remote}'...")
+file(DOWNLOAD "${remote}" "${local}" TIMEOUT ${timeout} STATUS status LOG log)
+
+list(GET status 0 status_code)
+list(GET status 1 status_string)
+
+if(NOT status_code EQUAL 0)
+ message(FATAL_ERROR "error: download of '${remote}' failed
+status_code: ${status_code}
+status_string: ${status_string}
+log: ${log}
+")
+endif()
+
+message(STATUS "info: done downloading '${remote}'...")