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 <noel.eck@intel.com>
This commit is contained in:
Noel Eck 2016-10-17 15:22:00 -07:00
parent 758fa32b75
commit df5b3805c5

View File

@ -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. # Make a version file containing the current version from git.
include (GetGitRevisionDescription) include (GetGitRevisionDescription)
git_describe (VERSION "--tags") git_describe (VERSION "--tags")
if ("x_${VERSION}" STREQUAL "x_GIT-NOTFOUND" OR "x_${VERSION}" STREQUAL "x_-128-NOTFOUND") # If git_describe fails, use a dirty version
message (WARNING "Install git to compile a production UPM!") if (${VERSION} MATCHES -NOTFOUND)
set (VERSION "v0.8.0-dirty") 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 () endif ()
message (STATUS "UPM Version ${VERSION}") message (STATUS "UPM Version ${VERSION}")