From ad126e71555143bc8e83a887abd4df2fa23fba01 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Tue, 15 Oct 2013 23:23:14 +0200 Subject: [PATCH] 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. --- CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e77ec831..ad9ab7a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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()