FetchContent: Support relative remote URLs like git submodules
Git submodule URLs can be relative to the upstream repository, but when using FetchContent
, a relative path is assumed to be a path to a local directory.
FetchContent
should support relative GIT_REPOSITORY
URLs such that, for example with this repo, ../Community.git
would not resolve to a local repository, but to gitlab.kitware.com/cmake/Community.git
.
Git only falls back to assuming a relative path for a submodule is referring to a local repository if the containing repo does not have a default remote configured.
The main reason for allowing this is that the dependency repo will be cloned using the same mechanism as the parent project when using relative paths. This is particularly helpful for [Gitlab CI], for example:
https://docs.gitlab.com/ee/ci/git_submodules.html
[This] instructs Git to automatically deduce the URL to use when cloning sources... GitLab CI/CD uses HTTPS for cloning your sources, and you can continue to use SSH to clone locally.