Skip to content

Commit 7d36988

Browse files
authored
Support .tar.xz and .tar.zst in tarball URLs, fix #536 (#694)
* Support .tar.xz and .tar.zst in tarball URLs, fix #536 * cmake-format
1 parent 2132b4a commit 7d36988

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

cmake/CPM.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,9 @@ endfunction()
258258

259259
# Try to infer package name and version from a url
260260
function(cpm_package_name_and_ver_from_url url outName outVer)
261-
if(url MATCHES "[/\\?]([a-zA-Z0-9_\\.-]+)\\.(tar|tar\\.gz|tar\\.bz2|zip|ZIP)(\\?|/|$)")
261+
if(url MATCHES
262+
"[/\\?]([a-zA-Z0-9_\\.-]+)\\.(tar|tar\\.gz|tar\\.bz2|tar\\.xz|tar\\.zst|zip|ZIP)(\\?|/|$)"
263+
)
262264
# We matched an archive
263265
set(filename "${CMAKE_MATCH_1}")
264266

test/unit/package_name_and_ver_from_url.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ cpm_package_name_and_ver_from_url("https://example.com/foo" name ver)
5555
assert_not_defined(name)
5656
assert_not_defined(ver)
5757

58+
cpm_package_name_and_ver_from_url(
59+
"http://downloads.xiph.org/releases/ogg/libogg-1.3.5.tar.xz" name ver
60+
)
61+
assert_equal("libogg" ${name})
62+
assert_equal("1.3.5" ${ver})
63+
5864
cpm_package_name_and_ver_from_url("example.zip.com/foo" name ver)
5965
assert_not_defined(name)
6066
assert_not_defined(ver)

0 commit comments

Comments
 (0)