FetchContent_Declare not using GIT_SHALLOW as expected
Issue:
There are performance repercussions during configure due to some discrepancy in Git clone.
Discrepancy is in Git clone (depth=1) is 38.73 MiB while Cmake shallow is 160.10 MiB
This apparently appears as if GIT_SHALLOW
isn't being applied normally when FetchContent_Declare
with GIT_SHALLOW TRUE
Version:
- git version 2.26.2.windows.1
- Cmake both
3.18.4
and3.20.0-rc1
tested
Reproduction:
An example FetchContent_Declare which exhibits the issue:
cmake_minimum_required (VERSION 3.15) #FetchContent
project(CmakeBug)
include(FetchContent)
FetchContent_Declare(
arm-cmsis_5
GIT_REPOSITORY https://github.com/ARM-software/CMSIS_5
GIT_SHALLOW TRUE
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(arm-cmsis_5)
Expected Result:
A shallow clone git clone https://github.com/ARM-software/CMSIS_5 --depth 1
should should total 38.73 MiB:
Cloning into 'CMSIS_5'...
remote: Enumerating objects: 5916, done.
remote: Counting objects: 100% (5916/5916), done.
remote: Compressing objects: 100% (4283/4283), done.
remote: Total 5916 (delta 2144), reused 3907 (delta 1402), pack-reused 0
Receiving objects: 100% (5916/5916), 38.73 MiB | 3.02 MiB/s, done.
Resolving deltas: 100% (2144/2144), done.
Updating files: 100% (6016/6016), done.
Actual Result:
Running cmake .. -DFETCHCONTENT_QUIET=FALSE
on Cmake 3.18.4
and 3.20.0-rc1
results in a Git-Clone 160.10 MiB (~4 times higher than expected/desired):
C:\CMake_FtechBug\build>cmake .. -DFETCHCONTENT_QUIET=FALSE
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19042.
-- The C compiler identification is MSVC 19.28.29337.0
-- The CXX compiler identification is MSVC 19.28.29337.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Populating arm-cmsis_5
Cloning into 'arm-cmsis_5-src'...
remote: Enumerating objects: 34292, done.
remote: Counting objects: 100% (34292/34292), done.
remote: Compressing objects: 100% (14452/14452), done.
remote: Total 34292 (delta 24965), reused 26568 (delta 19011), pack-reused 0
Receiving objects: 100% (34292/34292), 160.10 MiB | 3.14 MiB/s, done.
Resolving deltas: 100% (24965/24965), done.
Branch 'master' set up to track remote branch 'master' from 'origin'.
Switched to a new branch 'master'
HEAD is now at 20285262 Updated CMSIS-Pack documentation
-- Configuring done
-- Generating done
-- Build files have been written to: C:/CMake_FtechBug/build
Diagnosis Info:
- Full clone is 239.79 MiB:
>git clone https://github.com/ARM-software/CMSIS_5
...
Receiving objects: 100% (74078/74078), 239.79 MiB | 3.11 MiB/s, done.3822
- Master branch clone is 41.18 MiB
git clone https://github.com/ARM-software/CMSIS_5 --depth 1 --branch master cmsis_master ... Receiving objects: 100% (8248/8248), 41.18 MiB | 2.94 MiB/s, done.
Conclusion:
It isn't clear what command Cmake is using to clone the Git repository but it is downloading ~4 times the amount of data than is desired/optimal.
Further diagnostics is necessary as