diff --git a/README.md b/README.md index dc2d7b80..d86e0a9a 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ CPMAddPackage("uri#tag") CPMAddPackage("uri@version#tag") ``` -In the shorthand syntax if the URI is of the form `gh:user/name`, it is interpreted as GitHub URI and converted to `https://github.com/user/name.git`. If the URI is of the form `gl:user/name`, it is interpreted as a [GitLab](https://gitlab.com/explore/) URI and converted to `https://gitlab.com/user/name.git`. If the URI is of the form `bb:user/name`, it is interpreted as a [Bitbucket](https://bitbucket.org/) URI and converted to `https://bitbucket.org/user/name.git`. Otherwise the URI used verbatim as a git URL. All packages added using the shorthand syntax will be added using the [EXCLUDE_FROM_ALL](https://cmake.org/cmake/help/latest/prop_tgt/EXCLUDE_FROM_ALL.html) and [SYSTEM](https://cmake.org/cmake/help/latest/prop_tgt/SYSTEM.html#prop_tgt:SYSTEM) flag. +In the shorthand syntax if the URI is of the form `gh:user/name`, it is interpreted as GitHub URI and converted to `https://github.com/user/name.git`. If the URI is of the form `gl:user/name`, it is interpreted as a [GitLab](https://gitlab.com/explore/) URI and converted to `https://gitlab.com/user/name.git`. If the URI is of the form `bb:user/name`, it is interpreted as a [Bitbucket](https://bitbucket.org/) URI and converted to `https://bitbucket.org/user/name.git`. If the URI is of the form `cb:user/name`, it is interpreted as a [codeberg](https://codeberg.org/) URI and converted to `https://codeberg.org/user/name.git`. Otherwise the URI used verbatim as a git URL. All packages added using the shorthand syntax will be added using the [EXCLUDE_FROM_ALL](https://cmake.org/cmake/help/latest/prop_tgt/EXCLUDE_FROM_ALL.html) and [SYSTEM](https://cmake.org/cmake/help/latest/prop_tgt/SYSTEM.html#prop_tgt:SYSTEM) flag. The single-argument syntax also works for URLs: diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake index 854b9343..17e19ddd 100644 --- a/cmake/CPM.cmake +++ b/cmake/CPM.cmake @@ -353,6 +353,9 @@ function(cpm_parse_add_package_single_arg arg outArgs) elseif(scheme STREQUAL "bb") set(out "BITBUCKET_REPOSITORY;${uri}") set(packageType "git") + elseif(scheme STREQUAL "cb") + set(out "CODEBERG_REPOSITORY;${uri}") + set(packageType "git") # A CPM-specific scheme was not found. Looks like this is a generic URL so try to determine # type elseif(arg MATCHES ".git/?(@|#|$)") @@ -526,6 +529,7 @@ function(CPMAddPackage) GITHUB_REPOSITORY GITLAB_REPOSITORY BITBUCKET_REPOSITORY + CODEBERG_REPOSITORY GIT_REPOSITORY SOURCE_DIR FIND_PACKAGE_ARGUMENTS @@ -560,6 +564,8 @@ function(CPMAddPackage) set(CPM_ARGS_GIT_REPOSITORY "https://gitlab.com/${CPM_ARGS_GITLAB_REPOSITORY}.git") elseif(DEFINED CPM_ARGS_BITBUCKET_REPOSITORY) set(CPM_ARGS_GIT_REPOSITORY "https://bitbucket.org/${CPM_ARGS_BITBUCKET_REPOSITORY}.git") + elseif(DEFINED CPM_ARGS_BITBUCKET_REPOSITORY) + set(CPM_ARGS_GIT_REPOSITORY "https://codeberg.org/${CPM_ARGS_CODEBERG_REPOSITORY}.git") endif() if(DEFINED CPM_ARGS_GIT_REPOSITORY) @@ -1095,6 +1101,7 @@ function(cpm_prettify_package_arguments OUT_VAR IS_IN_COMMENT) DOWNLOAD_ONLY GITHUB_REPOSITORY GITLAB_REPOSITORY + CODEBERG_REPOSITORY GIT_REPOSITORY SOURCE_DIR FIND_PACKAGE_ARGUMENTS diff --git a/test/unit/parse_add_package_single_arg.cmake b/test/unit/parse_add_package_single_arg.cmake index d774d0fc..feb4cc5e 100644 --- a/test/unit/parse_add_package_single_arg.cmake +++ b/test/unit/parse_add_package_single_arg.cmake @@ -36,6 +36,12 @@ assert_equal("BITBUCKET_REPOSITORY;foo/bar" "${args}") cpm_parse_add_package_single_arg("bb:foo/Bar" args) assert_equal("BITBUCKET_REPOSITORY;foo/Bar" "${args}") +cpm_parse_add_package_single_arg("cb:foo/bar" args) +assert_equal("CODEBERG_REPOSITORY;foo/bar" "${args}") + +cpm_parse_add_package_single_arg("cb:foo/Bar" args) +assert_equal("CODEBERG_REPOSITORY;foo/Bar" "${args}") + cpm_parse_add_package_single_arg("https://github.com/cpm-cmake/CPM.cmake.git@0.30.5" args) assert_equal("GIT_REPOSITORY;https://github.com/cpm-cmake/CPM.cmake.git;VERSION;0.30.5" "${args}")