From 6c545806abc5441be994a1f9315cfd75d4b89682 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Mon, 5 Jul 2021 10:12:01 +1000 Subject: [PATCH] [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. --- version.cmake | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/version.cmake b/version.cmake index 548a0a5c..e483eca2 100644 --- a/version.cmake +++ b/version.cmake @@ -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)