FetchContent_Declare GIT_CONFIG options cannot contains spaces on Linux
I'm writing a pipeline for Azure DevOps, where we have to provide credentials for git operations. This is typically done with setting git --config http.extraheader="AUTHORIZATION: bearer $ENV{System_AccessToken}"
. I tried the following snippet, which works on Windows.
if(DEFINED ENV{System_AccessToken})
set(GIT_CONFIG_EXTRA_HEADER "AUTHORIZATION: bearer $ENV{System_AccessToken}" CACHE STRING "")
endif()
include(FetchContent)
FetchContent_Declare(fmtlib
GIT_REPOSITORY https://internal-url/fmtlib
GIT_CONFIG http.extraheader=${GIT_CONFIG_EXTRA_HEADER}
)
The resulting git clone
command in _deps/fmtlib-subbuild/fmtlib-populate-prefix/tmp/fmtlib-populate-gitclone.cmake
is:
COMMAND "/usr/bin/git" clone --no-checkout --config http.extraheader=AUTHORIZATION: bearer <token> "https://internal-url/fmtlib" "fmtlib-src"
It seems the value in the GIT_CONFIG
key/value pair cannot contain spaces.