diff --git a/llvm/cmake/modules/VersionFromVCS.cmake b/llvm/cmake/modules/VersionFromVCS.cmake index a55e9b837f38..d6a2ae5f45f5 100644 --- a/llvm/cmake/modules/VersionFromVCS.cmake +++ b/llvm/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}")