Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the codeberg repository to the single argument compact syntax. #509

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
7 changes: 7 additions & 0 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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/?(@|#|$)")
Expand Down Expand Up @@ -526,6 +529,7 @@ function(CPMAddPackage)
GITHUB_REPOSITORY
GITLAB_REPOSITORY
BITBUCKET_REPOSITORY
CODEBERG_REPOSITORY
GIT_REPOSITORY
SOURCE_DIR
FIND_PACKAGE_ARGUMENTS
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test/unit/parse_add_package_single_arg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]" args)
assert_equal("GIT_REPOSITORY;https://github.com/cpm-cmake/CPM.cmake.git;VERSION;0.30.5" "${args}")

Expand Down