diff --git a/CMakeLists.txt b/CMakeLists.txt index b46ca827d..f8a47f6c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,9 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/icinga-version.h.force) else() if(NOT ICINGA2_GIT_VERSION_INFO OR GIT_VERSION MATCHES "-NOTFOUND$") file(STRINGS icinga2.spec SPEC_VERSION REGEX "^Version:") - string(SUBSTRING ${SPEC_VERSION} 9 -1 SPEC_VERSION) + string(LENGTH "${SPEC_VERSION}" SPEC_LENGTH) + math(EXPR SPEC_LENGTH "${SPEC_LENGTH} - 9") + string(SUBSTRING ${SPEC_VERSION} 9 ${SPEC_LENGTH} SPEC_VERSION) set(GIT_VERSION "r${SPEC_VERSION}") endif() configure_file(icinga-version.h.cmake icinga-version.h)