FetchContent: Git update step is always executed when GIT_TAG is specified
Update (see the discussion below for more information):
The reason behind the original issue is that starting from CMake 3.18, the Git update step is always executed even when a GIT_TAG (commit hash or tag) is specified.
Original issue:
When using FetchContent to checkout an external Git repository, CMake 3.18 and above fails to perform the patch step on the second run, because the repository is already patched. Whereas with CMake 3.17.3 and below, it always succeeds. No matter the compiler or the library being patched, the error is the same:
[0/7] Performing update step for 'splinter-populate'
[2/7] Performing patch step for 'splinter-populate'
FAILED: splinter-populate-prefix/src/splinter-populate-stamp/splinter-populate-patch
cmd.exe /C "cd /D C:\dev\project\build\_deps\splinter-src && git apply --ignore-space-change --ignore-whitespace C:/dev/project/patches/splinter.patch && "C:\Program Files\CMake\bin\cmake.exe" -E touch C:/dev/project/build/_deps/splinter-subbuild/splinter-populate-prefix/src/splinter-populate-stamp/splinter-populate-patch"
error: patch failed: src/bsplinebasis.cpp:119
error: src/bsplinebasis.cpp: patch does not apply
ninja: build stopped: subcommand failed.
My guess is that the regression comes from !4818 (merged).
Edited by Boris Basic