FetchContent default shallow clone depth and tag propagation
24.5K reputation · 10 Oct 2025, 10:26 UTC
Goal
Reduce network bandwidth and disk usage in CI pipelines by enabling shallow clones of external projects declared with FetchContent_Declare. The current default performs a full clone, which can be costly for large repositories.
Unresolved Decision
There is no documented option to set a default shallow clone depth for FetchContent. Developers must manually specify GIT_SHALLOW or wrap the declaration in a custom function. Additionally, the propagation of GIT_TAG and other fetch options to nested FetchContent calls is not guaranteed; each subproject typically re‑declares its own fetch settings.
Questions
- Should CMake introduce a default
GIT_SHALLOWdepth forFetchContent_Declareto simplify CI usage? - How can nested
FetchContentcalls reliably inheritGIT_TAGand other fetch parameters without explicit re‑declaration? - What would be the backward compatibility impact if a default shallow depth were added in a future release?