From 7f10b137e1e75a57346b566a8818718b7f851625 Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 4 Mar 2011 16:51:46 -0500 Subject: [PATCH] ExternalProject: Extract file names from more urls Notably, downloads from sourceforge.net and gitweb snapshots. --- Modules/ExternalProject.cmake | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 3de6b7e68..390b8f923 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -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}")