Merge topic 'improve-ExternalProject-file-name-recognition'

7f10b13 ExternalProject: Extract file names from more urls
This commit is contained in:
Brad King 2011-03-08 14:22:35 -05:00 committed by CMake Topic Stage
commit 831fef8167

View File

@ -403,11 +403,11 @@ endfunction(_ep_write_verifyfile_script)
function(_ep_write_extractfile_script script_filename name filename directory)
set(args "")
if(filename MATCHES "(\\.bz2|\\.tar\\.gz|\\.tgz|\\.zip)$")
if(filename MATCHES "(\\.|=)(bz2|tar\\.gz|tgz|zip)$")
set(args xfz)
endif()
if(filename MATCHES "\\.tar$")
if(filename MATCHES "(\\.|=)tar$")
set(args xf)
endif()
@ -1109,10 +1109,15 @@ function(_ep_add_download_command name)
else()
if("${url}" MATCHES "^[a-z]+://")
# TODO: Should download and extraction be different steps?
string(REGEX MATCH "[^/]*$" fname "${url}")
if(NOT "${fname}" MATCHES "\\.(bz2|tar|tgz|tar\\.gz|zip)$")
string(REGEX MATCH "[^/\\?]*$" fname "${url}")
if(NOT "${fname}" MATCHES "(\\.|=)(bz2|tar|tgz|tar\\.gz|zip)$")
string(REGEX MATCH "([^/\\?]+(\\.|=)(bz2|tar|tgz|tar\\.gz|zip))/.*$" match_result "${url}")
set(fname "${CMAKE_MATCH_1}")
endif()
if(NOT "${fname}" MATCHES "(\\.|=)(bz2|tar|tgz|tar\\.gz|zip)$")
message(FATAL_ERROR "Could not extract tarball filename from url:\n ${url}")
endif()
string(REPLACE ";" "-" fname "${fname}")
set(file ${download_dir}/${fname})
get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT)
_ep_write_downloadfile_script("${stamp_dir}/download-${name}.cmake" "${url}" "${file}" "${timeout}" "${md5}")