]> granicus.if.org Git - icinga2/blobdiff - CMakeLists.txt
Fix null ptr exception in Zone::GetLocalZone()
[icinga2] / CMakeLists.txt
index b46ca827dcbdbe5219c48f4ef5af2e1489c97e51..89e1c3a27467208cb6e9fbef92c5d028f8073db9 100644 (file)
@@ -48,8 +48,16 @@ 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)
-    set(GIT_VERSION "r${SPEC_VERSION}")
+    string(LENGTH "${SPEC_VERSION}" SPEC_VERSION_LENGTH)
+    math(EXPR SPEC_VERSION_LENGTH "${SPEC_VERSION_LENGTH} - 9")
+    string(SUBSTRING ${SPEC_VERSION} 9 ${SPEC_VERSION_LENGTH} SPEC_VERSION)
+
+    file(STRINGS icinga2.spec SPEC_REVISION REGEX "^%define revision ")
+    string(LENGTH "${SPEC_REVISION}" SPEC_REVISION_LENGTH)
+    math(EXPR SPEC_REVISION_LENGTH "${SPEC_REVISION_LENGTH} - 17")
+    string(SUBSTRING ${SPEC_REVISION} 17 ${SPEC_REVISION_LENGTH} SPEC_REVISION)
+
+    set(GIT_VERSION "r${SPEC_VERSION}-${SPEC_REVISION}")
   endif()
   configure_file(icinga-version.h.cmake icinga-version.h)
 endif()