From df5b3805c5f4e12173cd7e9c9cbb0b9e29fc5657 Mon Sep 17 00:00:00 2001 From: Noel Eck Date: Mon, 17 Oct 2016 15:22:00 -0700 Subject: [PATCH] cmake: If git-describe failes with *-NOTFOUND, tag version dirty There is a case where git_describe was returning 'HEAD-HASH-NOTFOUND' which missed the STREQUAL check and VERSION was set incorrectly. Changed the STREQUAL to a MATCH on -NOTFOUND. In this way, any of the -NOTFOUND returns change the version to dirty. Signed-off-by: Noel Eck --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c553e2d9..f0df76f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,9 +94,11 @@ set (LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Installation path for # Make a version file containing the current version from git. include (GetGitRevisionDescription) git_describe (VERSION "--tags") -if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_-128-NOTFOUND") - message (WARNING "Install git to compile a production UPM!") +# If git_describe fails, use a dirty version +if (${VERSION} MATCHES -NOTFOUND) set (VERSION "v0.8.0-dirty") + message (WARNING "Failed to retrieve UPM version with 'git describe' (using " + "${VERSION}). Check that git is installed and this is a valid git repo.") endif () message (STATUS "UPM Version ${VERSION}")