Skip to content

Commit ad126e7

Browse files
committed
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.
1 parent 2347727 commit ad126e7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,12 @@ include(GetGitRevisionDescription)
170170
git_get_exact_tag(TAG)
171171
if(NOT TAG MATCHES "NOTFOUND")
172172
if(TAG MATCHES "v[0-9].*")
173-
# For a version tag, remove the leading 'v'.
174-
string(SUBSTRING "${TAG}" 1 -1 LDC_VERSION)
173+
# For a version tag, remove the leading 'v'. CMake 2.8.0 (e.g. Ubuntu
174+
# 10.04 LTS) doesn't support -1 in string(SUBSTRING ...), so spell it
175+
# out.
176+
string(LENGTH "${TAG}" taglen)
177+
MATH(EXPR taglen "${taglen} - 1")
178+
string(SUBSTRING "${TAG}" 1 ${taglen} LDC_VERSION)
175179
else()
176180
set(LDC_VERSION "${TAG}")
177181
endif()

0 commit comments

Comments
 (0)