From: Dylan Noblesmith Date: Mon, 12 Dec 2011 13:06:25 +0000 (+0000) Subject: cmake: work with CMake < 2.8.5 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=f931261b510b5762b686e4bcfa0e97f1f6a7c8c8;p=oota-llvm.git cmake: work with CMake < 2.8.5 CMake versions 2.8.4 and earlier were giving this error since r146323: "string end index: -1 is out of range 0 - 6" Passing -1 as the length of the desired substring was a new feature added in CMake 2.8.5: http://www.cmake.org/Bug/view.php?id=10740 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146372 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/cmake/modules/VersionFromVCS.cmake b/cmake/modules/VersionFromVCS.cmake index a55e9b837f3..d6a2ae5f45f 100644 --- a/cmake/modules/VersionFromVCS.cmake +++ b/cmake/modules/VersionFromVCS.cmake @@ -30,7 +30,9 @@ function(add_version_info_from_vcs VERS) OUTPUT_VARIABLE git_output) if( git_result EQUAL 0 ) string(REGEX MATCH r[0-9]+ git_svn_rev ${git_output}) - string(SUBSTRING "${git_svn_rev}" 1 -1 git_svn_rev_number) + string(LENGTH "${git_svn_rev}" rev_length) + math(EXPR rev_length "${rev_length}-1") + string(SUBSTRING "${git_svn_rev}" 1 ${rev_length} git_svn_rev_number) set(SVN_REVISION ${git_svn_rev_number} PARENT_SCOPE) set(git_svn_rev "-svn-${git_svn_rev}")