summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-07-13 10:55:08 -0400
committerBrad King <brad.king@kitware.com>2017-07-13 10:58:08 -0400
commit938c86ba1fc0121387038e65b511491a9336f7a3 (patch)
treec6aef04a7e7aa73f71058cdf1ec5555e7a5c34f3
parent11006a894ef27738942c08abc300f15906c0e5c9 (diff)
downloadcmake-938c86ba1fc0121387038e65b511491a9336f7a3.tar.gz
cmake_common: 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.
-rw-r--r--cmake_common.cmake20
1 files changed, 16 insertions, 4 deletions
diff --git a/cmake_common.cmake b/cmake_common.cmake
index 075920db68..b063829417 100644
--- a/cmake_common.cmake
+++ b/cmake_common.cmake
@@ -162,10 +162,22 @@ endif()
# Look for a GIT command-line client.
if(NOT DEFINED CTEST_GIT_COMMAND)
- find_program(CTEST_GIT_COMMAND
- NAMES git git.cmd
- PATH_SUFFIXES Git/cmd Git/bin
- )
+ set(git_names git git.cmd)
+
+ # First search the PATH.
+ find_program(CTEST_GIT_COMMAND NAMES ${git_names})
+
+ 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(CTEST_GIT_COMMAND
+ NAMES ${git_names}
+ PATH_SUFFIXES Git/cmd Git/bin
+ NO_SYSTEM_ENVIRONMENT_PATH
+ )
+ endif()
endif()
if(NOT CTEST_GIT_COMMAND)
message(FATAL_ERROR "CTEST_GIT_COMMAND not available!")