From 4fe50bd32d1d1acd31350d7868ca88e6c06911f7 Mon Sep 17 00:00:00 2001 From: Minmin Gong Date: Wed, 30 Jan 2019 09:34:16 -0800 Subject: [PATCH] Ask cmake to find git executable Related work item: Github #28 --- External/CMakeLists.txt | 13 +++++++++---- README.md | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/External/CMakeLists.txt b/External/CMakeLists.txt index 9c5db15..0bd2630 100644 --- a/External/CMakeLists.txt +++ b/External/CMakeLists.txt @@ -1,6 +1,11 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +find_program(git_executable NAMES git git.exe git.cmd) +if(NOT git_executable) + message(FATAL_ERROR "Failed to find git.") +endif() + set(cxxopts_REV "3f2d70530219e09fe7e563f86126b0d3b228a60d") set(googletest_REV "440527a61e1c91188195f7de212c63c77e8f0a45") set(SPIRV_Headers_REV "bbf63435c37aafac5d1cdfc287401d87cd3ca364") @@ -14,8 +19,8 @@ function(UpdateExternalLib name url rev) set(external_lib_folder "${external_folder}/${name}") if(EXISTS ${external_lib_folder}) message(STATUS "Updating ${name} to revision ${rev}...") - execute_process(COMMAND "git" "fetch" "origin" WORKING_DIRECTORY "${external_lib_folder}") - execute_process(COMMAND "git" "rev-parse" "HEAD" WORKING_DIRECTORY "${external_lib_folder}" OUTPUT_VARIABLE head_rev) + execute_process(COMMAND "${git_executable}" "fetch" "origin" WORKING_DIRECTORY "${external_lib_folder}") + execute_process(COMMAND "${git_executable}" "rev-parse" "HEAD" WORKING_DIRECTORY "${external_lib_folder}" OUTPUT_VARIABLE head_rev) string(STRIP ${head_rev} head_rev) if (${head_rev} STREQUAL ${rev}) set(need_checkout FALSE) @@ -24,12 +29,12 @@ function(UpdateExternalLib name url rev) endif() else() message(STATUS "Cloning ${name} revision...") - execute_process(COMMAND "git" "clone" ${url} "-n" WORKING_DIRECTORY "${external_folder}") + execute_process(COMMAND "${git_executable}" "clone" ${url} "-n" WORKING_DIRECTORY "${external_folder}") set(need_checkout TRUE) endif() if(need_checkout) message(STATUS "Checking out to revision ${rev}...") - execute_process(COMMAND "git" "checkout" "-q" ${rev} WORKING_DIRECTORY "${external_lib_folder}") + execute_process(COMMAND "${git_executable}" "checkout" "-q" ${rev} WORKING_DIRECTORY "${external_lib_folder}") endif() endfunction() diff --git a/README.md b/README.md index 3d9ab13..6a13ae0 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ ShaderConductor is not a real compiler. Instead, it glues existing open source c ## Prerequisites -* [Git](http://git-scm.com/downloads). +* [Git](http://git-scm.com/downloads). Put git into the PATH is recommended. * [Visual Studio 2017](https://www.visualstudio.com/downloads). Select the following workloads: Universal Windows Platform Development and Desktop Development with C++. * [CMake](https://www.cmake.org/download/). Version 3.9 or up. It's highly recommended to choose "Add CMake to the system PATH for all users" during installation. * [Python](https://www.python.org/downloads/). Version 2.7 or up. You need not change your PATH variable during installation.