[Cmake-commits] CMake branch, next, updated. v3.6.0-821-g3068a61

Brad King brad.king at kitware.com
Wed Jul 13 09:53:23 EDT 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  3068a61110162f6972a0392c2821aa3c5c91a69b (commit)
       via  2eec433f98f472eb902892ed11b68fae41376ce6 (commit)
      from  33aaf5180f12918392bd158c1c7278f4c83bc922 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3068a61110162f6972a0392c2821aa3c5c91a69b
commit 3068a61110162f6972a0392c2821aa3c5c91a69b
Merge: 33aaf51 2eec433
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Wed Jul 13 09:53:22 2016 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Jul 13 09:53:22 2016 -0400

    Merge topic 'ExternalProject-alt-urls' into next
    
    2eec433f ExternalProject: Add support for multiple alternative URLs


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2eec433f98f472eb902892ed11b68fae41376ce6
commit 2eec433f98f472eb902892ed11b68fae41376ce6
Author:     Lars Schmertmann <Lars.Schmertmann at governikus.de>
AuthorDate: Tue Jul 12 16:53:36 2016 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Wed Jul 13 09:44:34 2016 -0400

    ExternalProject: Add support for multiple alternative URLs
    
    Now it is possible to pass multiple URLs as a list that will be tried in
    and foreach(). So it will try next URL if the previous failed.
    
    Fixes #15749.

diff --git a/Modules/ExternalProject-download.cmake.in b/Modules/ExternalProject-download.cmake.in
index 5b73cd8..91d74e0 100644
--- a/Modules/ExternalProject-download.cmake.in
+++ b/Modules/ExternalProject-download.cmake.in
@@ -114,48 +114,56 @@ endif()
 
 set(retry_number 5)
 
+message(STATUS "Downloading...
+   dst='@LOCAL@'
+   timeout='@TIMEOUT_MSG@'"
+)
+
 foreach(i RANGE ${retry_number})
   sleep_before_download(${i})
 
-  message(STATUS "downloading...
-       src='@REMOTE@'
-       dst='@LOCAL@'
-       timeout='@TIMEOUT_MSG@'")
-
-  @TLS_VERIFY_CODE@
-  @TLS_CAINFO_CODE@
-
-  file(
-      DOWNLOAD
-      "@REMOTE@" "@LOCAL@"
-      @SHOW_PROGRESS@
-      @TIMEOUT_ARGS@
-      STATUS status
-      LOG log
-  )
-
-  list(GET status 0 status_code)
-  list(GET status 1 status_string)
-
-  if(status_code EQUAL 0)
-    check_file_hash(has_hash hash_is_good)
-    if(has_hash AND NOT hash_is_good)
-      message(STATUS "Hash mismatch, removing...")
-      file(REMOVE "@LOCAL@")
+  foreach(url @REMOTE@)
+    message(STATUS "Using src='${url}'")
+
+    @TLS_VERIFY_CODE@
+    @TLS_CAINFO_CODE@
+
+    file(
+        DOWNLOAD
+        "${url}" "@LOCAL@"
+        @SHOW_PROGRESS@
+        @TIMEOUT_ARGS@
+        STATUS status
+        LOG log
+    )
+
+    list(GET status 0 status_code)
+    list(GET status 1 status_string)
+
+    if(status_code EQUAL 0)
+      check_file_hash(has_hash hash_is_good)
+      if(has_hash AND NOT hash_is_good)
+        message(STATUS "Hash mismatch, removing...")
+        file(REMOVE "@LOCAL@")
+      else()
+        message(STATUS "Downloading... done")
+        return()
+      endif()
     else()
-      message(STATUS "Downloading... done")
-      return()
+      string(APPEND logFailedURLs "error: downloading '${url}' failed
+       status_code: ${status_code}
+       status_string: ${status_string}
+       log:
+       --- LOG BEGIN ---
+       ${log}
+       --- LOG END ---
+       "
+      )
     endif()
-  else()
-    message("error: downloading '@REMOTE@' failed
-  status_code: ${status_code}
-  status_string: ${status_string}
-  log:
-  --- LOG BEGIN ---
-  ${log}
-  --- LOG END ---"
-    )
-  endif()
+  endforeach()
 endforeach()
 
-message(FATAL_ERROR "Downloading failed")
+message(FATAL_ERROR "Each download failed!
+  ${logFailedURLs}
+  "
+)
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 3686fb6..7e179aa 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -69,8 +69,8 @@ Create custom targets to build projects in external trees
     URL of mercurial repo
   ``HG_TAG <tag>``
     Mercurial branch name, commit id or tag
-  ``URL /.../src.tgz``
-    Full path or URL of source
+  ``URL /.../src.tgz [/.../src.tgz]...``
+    Full path or URL(s) of source.  Multiple URLs are allowed as mirrors.
   ``URL_HASH ALGO=value``
     Hash of file at URL
   ``URL_MD5 md5``
@@ -1667,7 +1667,7 @@ function(_ep_add_download_command name)
   get_property(fname TARGET ${name} PROPERTY _EP_DOWNLOAD_NAME)
 
   # TODO: Perhaps file:// should be copied to download dir before extraction.
-  string(REGEX REPLACE "^file://" "" url "${url}")
+  string(REGEX REPLACE "file://" "" url "${url}")
 
   set(depends)
   set(comment)
@@ -1861,6 +1861,19 @@ function(_ep_add_download_command name)
       @ONLY
       )
     list(APPEND depends ${stamp_dir}/${name}-urlinfo.txt)
+
+    list(LENGTH url url_list_length)
+    if(NOT "${url_list_length}" STREQUAL "1")
+      foreach(entry ${url})
+        if(NOT "${entry}" MATCHES "^[a-z]+://")
+          message(FATAL_ERROR "At least one entry of URL is a path (invalid in a list)")
+        endif()
+      endforeach()
+      if("x${fname}" STREQUAL "x")
+        list(GET url 0 fname)
+      endif()
+    endif()
+
     if(IS_DIRECTORY "${url}")
       get_filename_component(abs_dir "${url}" ABSOLUTE)
       set(comment "Performing download step (DIR copy) for '${name}'")

-----------------------------------------------------------------------

Summary of changes:
 Modules/ExternalProject-download.cmake.in |   84 ++++++++++++++++-------------
 Modules/ExternalProject.cmake             |   19 +++++--
 2 files changed, 62 insertions(+), 41 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list