浏览代码

ENH: Check tarball filename in ep_add

This teaches the ExternalProject module to check the download URL file
name.  If it is not a tarball (.tar, .tgz, .tar.gz) it is an error
because UntarFile does not yet understand other archive formats.
Brad King 16 年之前
父节点
当前提交
a03bb5a28f
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      Modules/ExternalProject.cmake

+ 5 - 2
Modules/ExternalProject.cmake

@@ -512,8 +512,11 @@ 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 "\\.(tar|tgz|tar\\.gz)" ext "${url}")
-        set(file ${download_dir}/${name}${ext})
+        string(REGEX MATCH "[^/]*$" fname "${url}")
+        if(NOT "${fname}" MATCHES "\\.(tar|tgz|tar\\.gz)$")
+          message(FATAL_ERROR "Could not extract tarball filename from url:\n  ${url}")
+        endif()
+        set(file ${download_dir}/${fname})
         set(cmd ${CMAKE_COMMAND} -Dremote=${url} -Dlocal=${file} -P ${CMAKE_ROOT}/Modules/DownloadFile.cmake
         set(cmd ${CMAKE_COMMAND} -Dremote=${url} -Dlocal=${file} -P ${CMAKE_ROOT}/Modules/DownloadFile.cmake
           COMMAND)
           COMMAND)
         set(comment "Performing download step (download and extract) for '${name}'")
         set(comment "Performing download step (download and extract) for '${name}'")