diff --git a/cmake/Version.cmake b/cmake/Version.cmake index 4fe8e14b..403a02f7 100644 --- a/cmake/Version.cmake +++ b/cmake/Version.cmake @@ -45,10 +45,7 @@ if (NOT DEFINED BARRIER_REVISION) string (SUBSTRING $ENV{GIT_COMMIT} 0 8 BARRIER_REVISION) else() find_program (GIT_BINARY git) - if (GIT_BINARY STREQUAL "GIT_BINARY-NOTFOUND") - set (BARRIER_REVISION "00000000") - message (WARNING "git not found. revision hash set to ${BARRIER_REVISION}") - else() + if (NOT GIT_BINARY STREQUAL "GIT_BINARY-NOTFOUND") execute_process ( COMMAND git rev-parse --short=8 HEAD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} @@ -59,15 +56,12 @@ if (NOT DEFINED BARRIER_REVISION) endif() endif() -if (DEFINED BARRIER_REVISION) - string(LENGTH ${BARRIER_REVISION} BARRIER_REVISION_LENGTH) - if (NOT ((BARRIER_REVISION MATCHES "^[a-f0-9]+") AND (BARRIER_REVISION_LENGTH EQUAL "8"))) - message (FATAL_ERROR "BARRIER_REVISION ('${BARRIER_REVISION}') should be a short commit hash") - endif() - unset (BARRIER_REVISION_LENGTH) -else() - set (BARRIER_REVISION "0badc0de") +string(LENGTH "${BARRIER_REVISION}" BARRIER_REVISION_LENGTH) +if (NOT BARRIER_REVISION_LENGTH EQUAL 8 OR NOT BARRIER_REVISION MATCHES "^[a-f0-9]+") + set (BARRIER_REVISION "00000000") + message (WARNING "revision not found. setting to ${BARRIER_REVISION}") endif() +unset (BARRIER_REVISION_LENGTH) if (DEFINED ENV{BUILD_NUMBER}) set (BARRIER_BUILD_NUMBER $ENV{BUILD_NUMBER})