CMake 3.27.0-rc3 FetchContent regression in handling of invalid `<contentOptions>` for FetchContent_Declare
Consider the code:
include(FetchContent)
set(options "UPDATE_DISCONNECTED ON")
FetchContent_Declare(
googletest
${options}
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG 703bd9caab50b139428cea1aaff9974ebee5742e # release-1.10.0
)
FetchContent_Populate(googletest)
With CMake 3.26.4 we sucessfully generate a project and ignore the invalid option "UPDATE_DISCONNECTED ON"
( needed to be two values instead of one ).
With CMake 3.27.0-RC3 we now error out with:
[1/9] Creating directories for 'googletest-populate'
[1/9] Performing download step (git clone) for 'googletest-populate'
-- Avoiding repeated git clone, stamp file is up to date: '/home/rmaynard/Work/cmake/test/build/_deps/googletest-subbuild/googletest-populate-prefix/src/googletest-populate-stamp/googletest-populate-gitinfo.txt'
[2/9] Performing update step for 'googletest-populate'
CMake Error at /home/rmaynard/Work/cmake/test/build/_deps/googletest-subbuild/googletest-populate-prefix/tmp/googletest-populate-gitupdate.cmake:34 (message):
Failed to get the hash for HEAD:
fatal: not a git repository: '.git'
This is due to the handling around unparsed arguments and the git repository. When we trace the logic down to ExternalProject
we see the
git_repository
value in _ep_add_download_command
being https://github.com/google/googletest.git;UPDATE_DISCONNECTED ON
which when
parsed by _ep_write_gitclone_script
causes UPDATE_DISCONNECTED ON
to be come the git tag we try to clone.
At a minimum we need better error handling so that we don't fail so far down the stack from the source of the error.