فهرست منبع

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 <[email protected]>
Brad King 9 سال پیش
والد
کامیت
57c337e2ef
1فایلهای تغییر یافته به همراه5 افزوده شده و 7 حذف شده
  1. 5 7
      Modules/ExternalProject.cmake

+ 5 - 7
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}")