Fix Git tag -> version string conversion on CMake 2.8.0.

This version is notably shipped with Ubuntu 10.04 LTS, used
for building the Linux release binaries.
This commit is contained in:
David Nadlinger
2013-10-15 23:23:14 +02:00
parent 234772767a
commit ad126e7155

View File

@@ -170,8 +170,12 @@ include(GetGitRevisionDescription)
git_get_exact_tag(TAG)
if(NOT TAG MATCHES "NOTFOUND")
if(TAG MATCHES "v[0-9].*")
# For a version tag, remove the leading 'v'.
string(SUBSTRING "${TAG}" 1 -1 LDC_VERSION)
# For a version tag, remove the leading 'v'. CMake 2.8.0 (e.g. Ubuntu
# 10.04 LTS) doesn't support -1 in string(SUBSTRING ...), so spell it
# out.
string(LENGTH "${TAG}" taglen)
MATH(EXPR taglen "${taglen} - 1")
string(SUBSTRING "${TAG}" 1 ${taglen} LDC_VERSION)
else()
set(LDC_VERSION "${TAG}")
endif()