summaryrefslogtreecommitdiff
path: root/cmake_common.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake_common.cmake')
-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!")