summaryrefslogtreecommitdiff
path: root/Modules/FindGit.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-03-10 16:00:34 -0500
committerBrad King <brad.king@kitware.com>2017-03-10 16:09:31 -0500
commitc4d481e5b8558ac00e637b36312685762a82bb23 (patch)
tree718a1b01349bd5f8dad40448ec9062f32b560e49 /Modules/FindGit.cmake
parente1adec32b8325fb731da084e99acd6070f5e39bf (diff)
downloadcmake-c4d481e5b8558ac00e637b36312685762a82bb23.tar.gz
FindGit: Avoid finding VS 2017 non-general Git installation
At a VS 2017 command prompt the `PATH` contains a directory that happens to have a `Git/cmd/git.exe` inside it. However, this executable is not meant for general use. Revise our use of `Git/` path suffixes to be more specific to its original purpose of searching in the typical `c:/Program Files*/Git/` installation directories. Avoid using the suffixes on `PATH` entries. Fixes: #16706
Diffstat (limited to 'Modules/FindGit.cmake')
-rw-r--r--Modules/FindGit.cmake16
1 files changed, 15 insertions, 1 deletions
diff --git a/Modules/FindGit.cmake b/Modules/FindGit.cmake
index b830c080df..fae31eb835 100644
--- a/Modules/FindGit.cmake
+++ b/Modules/FindGit.cmake
@@ -43,12 +43,26 @@ if(CMAKE_HOST_WIN32)
endif()
endif()
+# First search the PATH and specific locations.
find_program(GIT_EXECUTABLE
NAMES ${git_names}
PATHS ${github_path} ${_git_sourcetree_path}
- PATH_SUFFIXES Git/cmd Git/bin
DOC "Git command line client"
)
+
+if(CMAKE_HOST_WIN32)
+ # Now look for installations in Git/ directories under typical installation
+ # prefixes on Windows. Exclude PATH from this search because VS 2017's
+ # command prompt happens to have a PATH entry with a Git/ subdirectory
+ # containing a minimal git not meant for general use.
+ find_program(GIT_EXECUTABLE
+ NAMES ${git_names}
+ PATH_SUFFIXES Git/cmd Git/bin
+ NO_SYSTEM_ENVIRONMENT_PATH
+ DOC "Git command line client"
+ )
+endif()
+
mark_as_advanced(GIT_EXECUTABLE)
unset(git_names)