mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-15 23:22:53 +08:00
cmake: Unset GIT_WORK_TREE and GIT_DIR before FetchContent_Populate
GIT_WORK_TREE is an environment variable which tells git where the worktree is. It may be set by the user or by git itself, e.g. when running `git rebase -i --exec ...`. If it is set, it overrides the working directory, causing the `git checkout` from FetchContent_Populate to fail. Clear this variable. Do the same for GIT_DIR for the same reason. A way to reproduce the failure that this commit fixes is: git rebase -i HEAD^^^ --exec 'ninja -C /path/to/build/dir fish' prior to this commit, using the fetched PCRE2, this would fail in CMake.
This commit is contained in:
parent
39fbc27d8d
commit
deec78cdd3
@ -54,6 +54,12 @@ else()
|
||||
# so we end up installing all of PCRE2 including its headers, man pages, etc.
|
||||
FetchContent_GetProperties(pcre2)
|
||||
if (NOT pcre2_POPULATED)
|
||||
# If GIT_WORK_TREE is set (by user or by git itself with e.g. git rebase), it
|
||||
# will override the git directory which CMake tries to apply in FetchContent_Populate,
|
||||
# resulting in a failed checkout.
|
||||
# Ensure it is not set.
|
||||
unset(ENV{GIT_WORK_TREE})
|
||||
unset(ENV{GIT_DIR})
|
||||
FetchContent_Populate(pcre2)
|
||||
add_subdirectory(${pcre2_SOURCE_DIR} ${pcre2_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
Loading…
x
Reference in New Issue
Block a user