I am trying to use CMake's FetchContent to retrieve an external project.
(Also note that this is the first time that I am trying into a clean directory. I tell this because in some forums they were telling that this occurs when GIT SHA changes after first successful try.)
I have this:
FetchContent_Declare(
MyExternal
PREFIX prefix TMP_DIR tmp STAMP_DIR stamp LOG_DIR log DOWNLOAD_DIR download SOURCE_DIR source BINARY_DIR binary INSTALL_DIR install
GIT_REPOSITORY https://myexternal.com/myexternal.git
GIT_TAG c06d39b285754e62f421b5f36e123ca620a5482d
GIT_PROGRESS TRUE
GIT_CONFIG http.sslVerify=false
GIT_SHALLOW FALSE
)
FetchContent_MakeAvailable(MyExternal)
But what I get is this:
fatal: reference is not a tree: c06d39b285754e62f421b5f36e123ca620a5482d
I have checked manually and this commit hash do exists and I can checkout it.
How could I get this with FetchContent?
Edit:
Thanks to @tsyvarev, I have got what cmake exactly is doing. It calls just 2 commands:
git clone --no-checkout --progress --config advice.detachedHead=false --config http.sslVerify=false https://myexternal.com/myexternal.git source
and
git checkout c06d39b285754e62f421b5f36e123ca620a5482d --
I have tried exact commands manually and I have discovered that to make this work, between 1. and 2. commands, I have to make this:
git fetch --depth 1 origin c06d39b285754e62f421b5f36e123ca620a5482d
But I don't know why I have to do git fetch
especially for this commit. Maybe git experts would explain that.