better handling of non-git builds
This commit is contained in:
parent
0b2dfd80e2
commit
8b69f9fe03
|
@ -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")
|
||||
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)
|
||||
else()
|
||||
set (BARRIER_REVISION "0badc0de")
|
||||
endif()
|
||||
|
||||
if (DEFINED ENV{BUILD_NUMBER})
|
||||
set (BARRIER_BUILD_NUMBER $ENV{BUILD_NUMBER})
|
||||
|
|
Loading…
Reference in New Issue