浏览代码

ExternalProject: Remove explicit list of supported archive types

- Do not try to guess the flags to pass to "cmake -E tar" ("z" or not) based
  on the extension. It is not necessary, as the archive type is autodetected
  since we switched to libarchive.
- Add new tests for .tar.zst archives, which would fail without the change.

Fixes: #25062
Javier Martín 7 月之前
父节点
当前提交
1cc85064ff

+ 6 - 0
Help/release/dev/externalproject-archive-types.rst

@@ -0,0 +1,6 @@
+externalproject-archive-types
+-----------------------------
+
+* The :module:`ExternalProject` module no longer checks the ``URL`` archive
+  file extension.  Any archive type that :option:`cmake -E tar <cmake-E tar>`
+  can extract is now allowed.

+ 4 - 0
Modules/ExternalProject.cmake

@@ -301,6 +301,10 @@ URL
 .. versionadded:: 3.1
   Added support for `tbz2`, `.tar.xz`, `.txz`, and `.7z` extensions.
 
+.. versionadded:: 4.1
+  All archive types that :option:`cmake -E tar <cmake-E tar>` can extract
+  are supported regardless of file extension.
+
 Git
 ~~~
 

+ 2 - 17
Modules/ExternalProject/shared_internal_commands.cmake

@@ -701,23 +701,8 @@ function(_ep_write_extractfile_script
   directory
   options
 )
-  set(args "")
-
-  if(filename MATCHES
-    "(\\.|=)(7z|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip)$")
-    set(args xfz)
-  endif()
-
-  if(filename MATCHES "(\\.|=)tar$")
-    set(args xf)
-  endif()
-
-  if(args STREQUAL "")
-    message(FATAL_ERROR
-      "Do not know how to extract '${filename}' -- known types are: "
-      ".7z, .tar, .tar.bz2, .tar.gz, .tar.xz, .tbz2, .tgz, .txz and .zip"
-    )
-  endif()
+  # cmake -E tar auto detects the type of archive being extracted
+  set(args "xf")
 
   configure_file(
     "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/extractfile.cmake.in"

+ 1 - 1
Tests/ExternalProjectLocal/CMakeLists.txt

@@ -142,7 +142,7 @@ set_property(TARGET ${proj} PROPERTY FOLDER "Local/TGZ")
 #  this more complete, we should add a diff between this and the TGZ tree since
 #  that one does build.
 #
-set(extra_cmp_exts tar.bz2 tar.xz zip)
+set(extra_cmp_exts tar.bz2 tar.xz tar.zst zip)
 foreach(ext IN LISTS extra_cmp_exts)
   string(TOUPPER "${ext}" name)
 

二进制
Tests/ExternalProjectLocal/Step1.tar.zst


二进制
Tests/ExternalProjectLocal/Step1NoDir.tar.zst