Ask cmake to find git executable

Related work item: Github #28
This commit is contained in:
Minmin Gong 2019-01-30 09:34:16 -08:00
Родитель 47cfbc2532
Коммит 4fe50bd32d
2 изменённых файлов: 10 добавлений и 5 удалений

13
External/CMakeLists.txt поставляемый
Просмотреть файл

@ -1,6 +1,11 @@
# Copyright (c) Microsoft Corporation. All rights reserved. # Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. # 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(cxxopts_REV "3f2d70530219e09fe7e563f86126b0d3b228a60d")
set(googletest_REV "440527a61e1c91188195f7de212c63c77e8f0a45") set(googletest_REV "440527a61e1c91188195f7de212c63c77e8f0a45")
set(SPIRV_Headers_REV "bbf63435c37aafac5d1cdfc287401d87cd3ca364") set(SPIRV_Headers_REV "bbf63435c37aafac5d1cdfc287401d87cd3ca364")
@ -14,8 +19,8 @@ function(UpdateExternalLib name url rev)
set(external_lib_folder "${external_folder}/${name}") set(external_lib_folder "${external_folder}/${name}")
if(EXISTS ${external_lib_folder}) if(EXISTS ${external_lib_folder})
message(STATUS "Updating ${name} to revision ${rev}...") message(STATUS "Updating ${name} to revision ${rev}...")
execute_process(COMMAND "git" "fetch" "origin" WORKING_DIRECTORY "${external_lib_folder}") execute_process(COMMAND "${git_executable}" "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}" "rev-parse" "HEAD" WORKING_DIRECTORY "${external_lib_folder}" OUTPUT_VARIABLE head_rev)
string(STRIP ${head_rev} head_rev) string(STRIP ${head_rev} head_rev)
if (${head_rev} STREQUAL ${rev}) if (${head_rev} STREQUAL ${rev})
set(need_checkout FALSE) set(need_checkout FALSE)
@ -24,12 +29,12 @@ function(UpdateExternalLib name url rev)
endif() endif()
else() else()
message(STATUS "Cloning ${name} revision...") 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) set(need_checkout TRUE)
endif() endif()
if(need_checkout) if(need_checkout)
message(STATUS "Checking out to revision ${rev}...") 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() endif()
endfunction() endfunction()

Просмотреть файл

@ -26,7 +26,7 @@ ShaderConductor is not a real compiler. Instead, it glues existing open source c
## Prerequisites ## 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++. * [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. * [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. * [Python](https://www.python.org/downloads/). Version 2.7 or up. You need not change your PATH variable during installation.