summaryrefslogtreecommitdiffstats
path: root/Modules/ExternalProject.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-07-05 18:52:00 (GMT)
committerBrad King <brad.king@kitware.com>2016-07-05 18:57:13 (GMT)
commit57c337e2ef358c5eae2b2e364065e93bf58f0f64 (patch)
treee3af9c282082ec2b953dac5cd25414ca26a50811 /Modules/ExternalProject.cmake
parent909048e5342fa6369ae26470ee0ce82e2a62abfb (diff)
downloadCMake-57c337e2ef358c5eae2b2e364065e93bf58f0f64.zip
CMake-57c337e2ef358c5eae2b2e364065e93bf58f0f64.tar.gz
CMake-57c337e2ef358c5eae2b2e364065e93bf58f0f64.tar.bz2
ExternalProject: Match filenames in URLs with query strings and anchors
While at it, refactor logic to consolidate the filename extraction and verification into a single match. Inspired-by: Ruslan Baratov <ruslan_baratov@yahoo.com>
Diffstat (limited to 'Modules/ExternalProject.cmake')
-rw-r--r--Modules/ExternalProject.cmake12
1 files changed, 5 insertions, 7 deletions
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 2ff18fc..ee517f6 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -1871,15 +1871,13 @@ function(_ep_add_download_command name)
if("${url}" MATCHES "^[a-z]+://")
# TODO: Should download and extraction be different steps?
if("x${fname}" STREQUAL "x")
- string(REGEX MATCH "[^/\\?]*$" fname "${url}")
+ set(fname "${url}")
endif()
- if(NOT "${fname}" MATCHES "(\\.|=)(7z|tar|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip)$")
- string(REGEX MATCH "([^/\\?]+(\\.|=)(7z|tar|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip))/.*$" match_result "${url}")
+ if("${fname}" MATCHES [[([^/\?#]+(\.|=)(7z|tar|tar\.bz2|tar\.gz|tar\.xz|tbz2|tgz|txz|zip))([/?#].*)?$]])
set(fname "${CMAKE_MATCH_1}")
- endif()
- if (no_extract)
- get_filename_component(fname "${url}" NAME)
- elseif(NOT "${fname}" MATCHES "(\\.|=)(7z|tar|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip)$")
+ elseif(no_extract)
+ get_filename_component(fname "${fname}" NAME)
+ else()
message(FATAL_ERROR "Could not extract tarball filename from url:\n ${url}")
endif()
string(REPLACE ";" "-" fname "${fname}")