[all] set the working directory for git versioning commands

This commit is contained in:
Geoffrey McRae 2020-10-09 02:54:36 +11:00
parent a94d3734c2
commit 4d8a116849

View File

@ -1,17 +1,14 @@
execute_process(COMMAND git describe --always --long --abbrev=10 --tags
OUTPUT_VARIABLE GIT_REV
ERROR_QUIET)
execute_process(
COMMAND git describe --always --long --abbrev=10 --tags
WORKING_DIRECTORY "${PROJECT_TOP}"
OUTPUT_VARIABLE GIT_REV
ERROR_QUIET)
if (NOT "${GIT_REV}" STREQUAL "")
execute_process(
COMMAND bash -c "git diff --quiet --exit-code || echo +"
WORKING_DIRECTORY "${PROJECT_TOP}"
OUTPUT_VARIABLE GIT_DIFF)
execute_process(
COMMAND git describe --exact-match --tags
OUTPUT_VARIABLE GIT_TAG ERROR_QUIET)
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE GIT_BRANCH)
string(STRIP "${GIT_REV}" GIT_REV)
endif()