Skip to content

Commit

Permalink
better handling of non-git builds
Browse files Browse the repository at this point in the history
  • Loading branch information
walker0643 committed May 14, 2018
1 parent 0b2dfd8 commit 8b69f9f
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions cmake/Version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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})
Expand Down

0 comments on commit 8b69f9f

Please sign in to comment.