summaryrefslogtreecommitdiffstats
path: root/Modules/ExternalProject.cmake
diff options
context:
space:
mode:
authorRuslan Baratov <ruslan_baratov@yahoo.com>2016-05-19 13:35:01 (GMT)
committerBrad King <brad.king@kitware.com>2016-05-19 15:20:50 (GMT)
commit89113e125d95fc24eaaec59edaa00b6d428111f5 (patch)
treeacd7056658794f514a5d041fef18fb8d409721eb /Modules/ExternalProject.cmake
parente7d5e4b4bf864fa779e2fc90dfb352588bf82246 (diff)
downloadCMake-89113e125d95fc24eaaec59edaa00b6d428111f5.zip
CMake-89113e125d95fc24eaaec59edaa00b6d428111f5.tar.gz
CMake-89113e125d95fc24eaaec59edaa00b6d428111f5.tar.bz2
ExternalProject: Re-implement download logic as a dedicated script
Move the content to a `ExternalProject-download.cmake.in` file and use `configure_file` to generate the final script. Retry logic was not working before because similar script trigger FATAL_ERROR if 'file(DOWNLOAD ...)' exits with nonzero 'status_code'. FATAL_ERROR makes the whole chain of commands stop and '_ep_write_verifyfile_script' retry logic was not used in fact. Default retry number set to 5 with pauses 0, 5, 5, 15, 60 seconds. Some space left for future improvements if needed (90, 300, 1200=20min). Can be controlled by user.
Diffstat (limited to 'Modules/ExternalProject.cmake')
-rw-r--r--Modules/ExternalProject.cmake61
1 files changed, 19 insertions, 42 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 2249501..ad6de18 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -867,16 +867,11 @@ function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_p
endif()
if("${hash}" MATCHES "${_ep_hash_regex}")
- string(CONCAT hash_check
- "if(EXISTS \"${LOCAL}\")\n"
- " file(\"${CMAKE_MATCH_1}\" \"${LOCAL}\" hash_value)\n"
- " if(\"x\${hash_value}\" STREQUAL \"x${CMAKE_MATCH_2}\")\n"
- " return()\n"
- " endif()\n"
- "endif()\n"
- )
+ set(ALGO "${CMAKE_MATCH_1}")
+ set(EXPECT_VALUE "${CMAKE_MATCH_2}")
else()
- set(hash_check "")
+ set(ALGO "")
+ set(EXPECT_VALUE "")
endif()
set(TLS_VERIFY_CODE "")
@@ -904,41 +899,23 @@ function(_ep_write_downloadfile_script script_filename REMOTE LOCAL timeout no_p
set(TLS_CAINFO_CODE "set(CMAKE_TLS_CAINFO \"${tls_cainfo}\")")
endif()
- file(WRITE ${script_filename}
-"${hash_check}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(NOT status_code EQUAL 0)
- message(FATAL_ERROR \"error: downloading '${REMOTE}' failed
- status_code: \${status_code}
- status_string: \${status_string}
- log: \${log}
-\")
-endif()
-
-message(STATUS \"downloading... done\")
-"
-)
-
+ # Used variables:
+ # * TLS_VERIFY_CODE
+ # * TLS_CAINFO_CODE
+ # * ALGO
+ # * EXPECT_VALUE
+ # * REMOTE
+ # * LOCAL
+ # * SHOW_PROGRESS
+ # * TIMEOUT_ARGS
+ # * TIMEOUT_MSG
+ configure_file(
+ "${_ExternalProject_SELF_DIR}/ExternalProject-download.cmake.in"
+ "${script_filename}"
+ @ONLY
+ )
endfunction()
-
function(_ep_write_verifyfile_script script_filename LOCAL hash)
if("${hash}" MATCHES "${_ep_hash_regex}")
set(ALGO "${CMAKE_MATCH_1}")