Fix issue #9764 - add TIMEOUT arg to ExternalProject_Add so that callers have explicit control over the amount of time they are willing to wait for a download step. Default to no timeout, which means just run download for however long it takes.

This commit is contained in:
David Cole 2009-12-11 15:04:55 -05:00
parent e28941b6d7
commit 490009c016
1 changed files with 12 additions and 5 deletions

View File

@ -17,6 +17,7 @@
# [SVN_REPOSITORY url] # URL of Subversion repo # [SVN_REPOSITORY url] # URL of Subversion repo
# [SVN_REVISION rev] # Revision to checkout from Subversion repo # [SVN_REVISION rev] # Revision to checkout from Subversion repo
# [URL /.../src.tgz] # Full path or URL of source # [URL /.../src.tgz] # Full path or URL of source
# [TIMEOUT seconds] # Time allowed for file download operations
# #--Update/Patch step---------- # #--Update/Patch step----------
# [UPDATE_COMMAND cmd...] # Source work-tree update command # [UPDATE_COMMAND cmd...] # Source work-tree update command
# [PATCH_COMMAND cmd...] # Command to patch downloaded source # [PATCH_COMMAND cmd...] # Command to patch downloaded source
@ -203,19 +204,24 @@ define_property(DIRECTORY PROPERTY "EP_PREFIX" INHERITED
function(_ep_write_downloadfile_script script_filename remote local timeout) function(_ep_write_downloadfile_script script_filename remote local timeout)
if(NOT timeout) if(timeout)
set(timeout 30) set(timeout_args TIMEOUT ${timeout})
set(timeout_msg "${timeout} seconds")
else()
set(timeout_args "# no TIMEOUT")
set(timeout_msg "none")
endif() endif()
file(WRITE ${script_filename} file(WRITE ${script_filename}
"message(STATUS \"downloading... "message(STATUS \"downloading...
src='${remote}' src='${remote}'
dst='${local}'\") dst='${local}'
timeout='${timeout_msg}'\")
file(DOWNLOAD file(DOWNLOAD
\"${remote}\" \"${remote}\"
\"${local}\" \"${local}\"
TIMEOUT ${timeout} ${timeout_args}
STATUS status STATUS status
LOG log) LOG log)
@ -694,7 +700,8 @@ function(_ep_add_download_command name)
message(FATAL_ERROR "Could not extract tarball filename from url:\n ${url}") message(FATAL_ERROR "Could not extract tarball filename from url:\n ${url}")
endif() endif()
set(file ${download_dir}/${fname}) set(file ${download_dir}/${fname})
_ep_write_downloadfile_script("${stamp_dir}/download-${name}.cmake" "${url}" "${file}" "") get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT)
_ep_write_downloadfile_script("${stamp_dir}/download-${name}.cmake" "${url}" "${file}" "${timeout}")
set(cmd ${CMAKE_COMMAND} -P ${stamp_dir}/download-${name}.cmake set(cmd ${CMAKE_COMMAND} -P ${stamp_dir}/download-${name}.cmake
COMMAND) COMMAND)
set(comment "Performing download step (download and extract) for '${name}'") set(comment "Performing download step (download and extract) for '${name}'")