Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: properly search for git application before using it #353

Merged
merged 1 commit into from
Oct 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions external/git/cmake/GetGitRevisionDescription.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ function(_git_find_closest_git_dir _start_dir _git_dir_var)
endfunction()

function(get_git_head_revision _refspecvar _hashvar)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
if(NOT GIT_FOUND)
set(${_refspecvar}
"GIT-NOTFOUND"
PARENT_SCOPE)
set(${_hashvar}
"GIT-NOTFOUND"
PARENT_SCOPE)
endif()

_git_find_closest_git_dir("${CMAKE_CURRENT_SOURCE_DIR}" GIT_DIR)

if(${ARGC} GREATER 2})
Expand Down Expand Up @@ -178,13 +190,14 @@ function(git_describe _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var}
"GIT-NOTFOUND"
PARENT_SCOPE)
return()
endif()

get_git_head_revision(refspec hash)
if(NOT hash)
set(${_var}
"HEAD-HASH-NOTFOUND"
Expand Down Expand Up @@ -221,13 +234,14 @@ function(git_describe_working_tree _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var}
"GIT-NOTFOUND"
PARENT_SCOPE)
return()
endif()

get_git_head_revision(refspec hash)
if(NOT hash)
set(${_var}
"HEAD-HASH-NOTFOUND"
Expand Down Expand Up @@ -261,13 +275,14 @@ function(git_local_changes _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var}
"GIT-NOTFOUND"
PARENT_SCOPE)
return()
endif()

get_git_head_revision(refspec hash)
if(NOT hash)
set(${_var}
"HEAD-HASH-NOTFOUND"
Expand Down Expand Up @@ -296,13 +311,14 @@ function(git_get_branch _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var}
"GIT-NOTFOUND"
PARENT_SCOPE)
return()
endif()

get_git_head_revision(refspec hash)
if(NOT hash)
set(${_var}
"HEAD-HASH-NOTFOUND"
Expand All @@ -329,13 +345,14 @@ function(git_get_short_hash _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var}
"GIT-NOTFOUND"
PARENT_SCOPE)
return()
endif()

get_git_head_revision(refspec hash)
if(NOT hash)
set(${_var}
"HEAD-HASH-NOTFOUND"
Expand Down