CMake: fix get_git_head_revision.

This commit is contained in:
levlam 2022-08-14 16:36:21 +03:00
parent bcd89728c3
commit da9f8078b8

View File

@ -58,10 +58,12 @@ endfunction()
function(get_git_head_revision _refspecvar _hashvar) function(get_git_head_revision _refspecvar _hashvar)
_git_find_closest_git_dir("${CMAKE_CURRENT_SOURCE_DIR}" GIT_DIR) _git_find_closest_git_dir("${CMAKE_CURRENT_SOURCE_DIR}" GIT_DIR)
file(RELATIVE_PATH _relative_to_source_dir "${CMAKE_CURRENT_SOURCE_DIR}" "${GIT_DIR}") if (NOT GIT_DIR STREQUAL "")
if (_relative_to_source_dir MATCHES "^[.][.]") file(RELATIVE_PATH _relative_to_source_dir "${CMAKE_CURRENT_SOURCE_DIR}" "${GIT_DIR}")
# We've gone above the CMake root dir. if (_relative_to_source_dir MATCHES "^[.][.]")
set(GIT_DIR "") # We've gone above the CMake root dir.
set(GIT_DIR "")
endif()
endif() endif()
if (GIT_DIR STREQUAL "") if (GIT_DIR STREQUAL "")
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)