Hi,

Recently I had to build a project on windows whose build required git.  And
even though I had installed git from here [1] in the default location, I
had to tell CMake where to find it every time I did a build in a clean
build tree.  So here is a patch that tells CMake to look in the default
install location for Git for Windows [2] when asked for git.  I have tested
it on my windows machine and it works there.

Shawn

[1]: https://git-for-windows.github.io/
[2]: C:\Program Files\Git\bin\git.exe ('Program Files (x86)' for older
versions or 32 bit systems)
From 9cb6cda92245779f9c3868d6bcc88edb4f02db6b Mon Sep 17 00:00:00 2001
From: Shawn Waldon <[email protected]>
Date: Thu, 14 Jan 2016 18:18:41 -0500
Subject: [PATCH] git: add search paths for default git for windows install

---
 Modules/FindGit.cmake | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Modules/FindGit.cmake b/Modules/FindGit.cmake
index 2c3e5fd..6f6e41e 100644
--- a/Modules/FindGit.cmake
+++ b/Modules/FindGit.cmake
@@ -50,12 +50,14 @@ if(WIN32)
     file(GLOB github_path "${github_path}")
     # SourceTree search path for Windows
     set(_git_sourcetree_path "$ENV{LOCALAPPDATA}/Atlassian/SourceTree/git_local/bin")
+    # Git for Windows (git-for-windows.github.io) paths
+    set(_git_for_windows_paths "C:/Program Files/Git/bin;C:/Program Files (x86)/Git/bin")
   endif()
 endif()
 
 find_program(GIT_EXECUTABLE
   NAMES ${git_names}
-  PATHS ${github_path} ${_git_sourcetree_path}
+  PATHS ${github_path} ${_git_sourcetree_path} ${_git_for_windows_paths}
   PATH_SUFFIXES Git/cmd Git/bin
   DOC "git command line client"
   )
-- 
2.5.0

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to