ExternalProject: Extract file names from more urls

Notably, downloads from sourceforge.net and gitweb snapshots.
This commit is contained in:
David Cole 2011-03-04 16:51:46 -05:00
parent ed1cd2daf6
commit 7f10b137e1
1 changed files with 9 additions and 4 deletions

View File

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