CMake prefers git.exe installed by VS2017
I just submitted issue report to Visual Studio 2017: https://developercommunity.visualstudio.com/content/problem/26539/vs2017-deployed-gitexe-not-usable.html I am, however, not clear where might be the problem, so I'm also letting the CMake Team know about the problem here. ------ ## Environment * Windows 10 * Visual Studio Professional 2017 (Version 15.0.26228.4) * Git 2.11.1.windows.1 (`C:\Program Files\Git\cmd\git.EXE` in `PATH`) ## Problem I have a project, https://github.com/lexicalunit/nanodbc/, with `CMakeLists.txt` which calls `git` to add external project: ``` find_package(Git REQUIRED) ExternalProject_Add( catch PREFIX ${CMAKE_BINARY_DIR}/catch GIT_REPOSITORY https://github.com/philsquared/Catch.git UPDATE_COMMAND ${GIT_EXECUTABLE} pull CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" LOG_DOWNLOAD ON) ``` In Visual Studio 2017 command prompt, I run CMake to configure the build and CMake generates custom build step file `catch-gitclone.cmake`. CMake seems to prefer `git.exe` from the VS2017 installation instead of the one available in `PATH` ``` execute_process( COMMAND "C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Microsoft/TeamFoundation/Team Explorer/Git/cmd/git.exe" ${git_options} checkout master -- WORKING_DIRECTORY "D:/dev/nanodbc/_build32/catch/src/catch" RESULT_VARIABLE error_code ) ``` The problem is, that `C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/CommonExtensions/Microsoft/TeamFoundation/Team Explorer/Git/cmd/git.exe` seems not directly usable (either a bug or by design, who knows) and the `git clone` terminates with System Error prompts about missing DLLs: libintl-8.dll, , libcurl-4.dll, libpcre-1.dll, libssp-0.dll ![cmake-3.8rc2-vs2017-run-git-dll-hell](/uploads/7175c29ae2180350fe32cd70bd289834/cmake-3.8rc2-vs2017-run-git-dll-hell.png) Perhaps it is something that could be corrected, so CMake prefers `C:\Program Files\Git\cmd\git.EXE` which is available in the `PATH`.
issue