From 1cc85064ff847db50df29b3445082e05677228fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Mart=C3=ADn?= Date: Fri, 25 Apr 2025 11:48:02 +0200 Subject: [PATCH] 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 --- .../dev/externalproject-archive-types.rst | 6 ++++++ Modules/ExternalProject.cmake | 4 ++++ .../shared_internal_commands.cmake | 19 ++---------------- Tests/ExternalProjectLocal/CMakeLists.txt | 2 +- Tests/ExternalProjectLocal/Step1.tar.zst | Bin 0 -> 823 bytes Tests/ExternalProjectLocal/Step1NoDir.tar.zst | Bin 0 -> 790 bytes 6 files changed, 13 insertions(+), 18 deletions(-) create mode 100644 Help/release/dev/externalproject-archive-types.rst create mode 100644 Tests/ExternalProjectLocal/Step1.tar.zst create mode 100644 Tests/ExternalProjectLocal/Step1NoDir.tar.zst diff --git a/Help/release/dev/externalproject-archive-types.rst b/Help/release/dev/externalproject-archive-types.rst new file mode 100644 index 0000000000..a748a38236 --- /dev/null +++ b/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 ` + can extract is now allowed. diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 37bd39cae3..61e2ea5656 100644 --- a/Modules/ExternalProject.cmake +++ b/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 ` can extract + are supported regardless of file extension. + Git ~~~ diff --git a/Modules/ExternalProject/shared_internal_commands.cmake b/Modules/ExternalProject/shared_internal_commands.cmake index ac5d2bddc3..cb7b772225 100644 --- a/Modules/ExternalProject/shared_internal_commands.cmake +++ b/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" diff --git a/Tests/ExternalProjectLocal/CMakeLists.txt b/Tests/ExternalProjectLocal/CMakeLists.txt index c956fe4d01..8f753bcd50 100644 --- a/Tests/ExternalProjectLocal/CMakeLists.txt +++ b/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) diff --git a/Tests/ExternalProjectLocal/Step1.tar.zst b/Tests/ExternalProjectLocal/Step1.tar.zst new file mode 100644 index 0000000000000000000000000000000000000000..3731108d23593ae8df715f51c15206873a47fa05 GIT binary patch literal 823 zcmV-71IYX+wJ-eySXCJShHHc<(2}YS)HUo(a6Iq-MMLl(6tl?)kgDo-`i5x)YgQ=P zFQe3hgF!(7d;oR;cK{Fz5>?gsMYlU!S6?l~w>{n&=acs;nxxm}jsrbgy%_@(prJ1vz?<`*|lN8|tVU!3Y$pR~lI3v#h3Sg9D zdW^z>^6kL6vk|&%mPdGZnzYCrSLs{pbawu4B);A*_r;VKG$wJyGpKAd8H@%LkkpJx zi6+J3m?9C#ot+s&SFZGOm&pIWisc8luq&YlXQ(kDQivc!6o|}>BuSwIZ~~Djs+k88 zz+gch1}Tg}5Ges6LL?x8NGKIQL?q7vrA3R~V!H)sFhJG23CqRoBzx$TWE3%DB{{q% zXHurN%(&UZfV38!2SyBfK41gJ(#SY>Wq`Ws%7CdSib!rX6%*F4?Q*07)W6onZ8X5E z%aLs1R?VqA}WO@9V)9`eAk z0v&t6zJAM5_YVi0%dZZBz(|6jnjH<~OcW|mT*b;d&&O$4ip=siY#|6rL@iCkiUkMx z>x&|nCoo(*qORD-1X-Awz+x#8D;Q{tfS*QL2GD@^+8}{YMuC)bw(g@NhX-z?^$ewf Bg~$K^ literal 0 HcmV?d00001 diff --git a/Tests/ExternalProjectLocal/Step1NoDir.tar.zst b/Tests/ExternalProjectLocal/Step1NoDir.tar.zst new file mode 100644 index 0000000000000000000000000000000000000000..f453b750ea92114fca8e333abdc7450cd4e58458 GIT binary patch literal 790 zcmV+x1L^!IwJ-eySWOrJM(Thl(6U$u)V1zRBejaKFT_Q=L#^`QMDN}INCrXHL*`i! zeZUtFfk(Fic>r<%bpY?44rfDw_jDc>A}Fe_tJwZ%nV!~pZF{^iic6fMWO3SxGlg_q z^+vUuqrgk$a!zM6;c>8#F5AxB(U#J(HtE!;=7?GaeJ(mVpx;J(GxQF@M__>udKpUw zlfl5u1fl8j;KO9#dk>l>g7@BoFbJ+(d?!S6#0X6v#}UJ?_Y!wo=B%Rgwpzz<+>TW? zcDKb3v60S?l<{}bg=c}YVTkCgU=_{4h-cG4IcPi;oe7FU#NCTdjQhShVua?6;al~s)%$zn_KM%xv~F9*#vb1`U(=$s3OH(?nI&MAIwigb z5*KgP<67<8#@uml&m{^6;u`?2}@Nw2`X z1fRj*kTqTdv9SYb%LH|(N=}?wLXCx?1=e%87i$lt7>Nq`