Shallow downloads of git repos via FetchContent

I am using CPM to download dependency of my project. The dependencies is a large repo and a tag has been made which removes a lot of unneeded parts of the repo. This was done so that when the project is being configured, it takes 30 secs instead of minutes to fetch what it needs.

I used GIT_SHALLOW when adding the package and have confirmed that --depth 1 gets through to the git clone command (as well as --no-single-branch which I think might be a mistake for this purpose?).
The --branch option isn’t present however which is causing the whole repo to be downloaded. CMake seems to download the whole repo then switch to the branch you request even with GIT_SHALLOW defined.

Is there any work around for this? Am I missing something?
Cheers,
Larry

This topic has a fairly long history, which you can find in the CMake issue tracker here: https://gitlab.kitware.com/cmake/cmake/-/issues/17770

2 Likes