[all] cmake: check for VERSION file before using git describe

In order to make it easier for package maintainers that manage LG inside
their own git repository we should use the version file if it exists
over calling git describe.
This commit is contained in:
Geoffrey McRae 2021-07-05 10:12:01 +10:00
parent 7c1e8a85cd
commit 6c545806ab

View File

@ -1,15 +1,16 @@
execute_process(
COMMAND git describe --always --abbrev=10 --dirty=+ --tags
WORKING_DIRECTORY "${PROJECT_TOP}"
OUTPUT_VARIABLE GIT_REV
ERROR_QUIET)
if (EXISTS ${PROJECT_TOP}/VERSION)
file(READ ${PROJECT_TOP}/VERSION GIT_REV)
else()
execute_process(
COMMAND git describe --always --abbrev=10 --dirty=+ --tags
WORKING_DIRECTORY "${PROJECT_TOP}"
OUTPUT_VARIABLE GIT_REV
ERROR_QUIET)
endif()
if ("${GIT_REV}" STREQUAL "")
if (EXISTS ${PROJECT_TOP}/VERSION)
file(READ ${PROJECT_TOP}/VERSION GIT_REV)
else()
set(GIT_REV "UNKNOWN")
endif()
set(GIT_REV "UNKNOWN")
endif()
string(STRIP "${GIT_REV}" GIT_VERSION)