changeset 2852:d4f44a8028a1

allow passing FALSE as expeted MD5 in DownloadPackage when we don't wan't to check the MD5
author am@osimis.io
date Tue, 02 Oct 2018 15:54:36 +0200
parents 859e880ac9a8
children ebb3f2aa5f23
files Resources/CMake/DownloadPackage.cmake
diffstat 1 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/Resources/CMake/DownloadPackage.cmake	Mon Oct 01 14:19:45 2018 +0200
+++ b/Resources/CMake/DownloadPackage.cmake	Tue Oct 02 15:54:36 2018 +0200
@@ -73,18 +73,23 @@
       # user know."
       # https://code.google.com/p/orthanc/issues/detail?id=6
       if (NOT STATIC_BUILD AND NOT ALLOW_DOWNLOADS)
-	message(FATAL_ERROR "CMake is not allowed to download from Internet. Please set the ALLOW_DOWNLOADS option to ON")
+	      message(FATAL_ERROR "CMake is not allowed to download from Internet. Please set the ALLOW_DOWNLOADS option to ON")
       endif()
 
-      file(DOWNLOAD "${Url}" "${TMP_PATH}" 
-        SHOW_PROGRESS EXPECTED_MD5 "${MD5}"
-        TIMEOUT 60 INACTIVITY_TIMEOUT 60)
+      if (MD5)
+        file(DOWNLOAD "${Url}" "${TMP_PATH}" SHOW_PROGRESS TIMEOUT 60 INACTIVITY_TIMEOUT 60 EXPECTED_MD5 "${MD5}")
+      else()
+        file(DOWNLOAD "${Url}" "${TMP_PATH}" SHOW_PROGRESS TIMEOUT 60 INACTIVITY_TIMEOUT 60)
+      endif()
+
     else()
       message("Using local copy of ${Url}")
 
-      file(MD5 ${TMP_PATH} ActualMD5)
-      if (NOT "${ActualMD5}" STREQUAL "${MD5}")
-        message(FATAL_ERROR "The MD5 hash of a previously download file is invalid: ${TMP_PATH}")
+      if (MD5)
+        file(MD5 ${TMP_PATH} ActualMD5)
+        if (NOT "${ActualMD5}" STREQUAL "${MD5}")
+          message(FATAL_ERROR "The MD5 hash of a previously download file is invalid: ${TMP_PATH}")
+        endif()
       endif()
     endif()