Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback message if unable to get git revision #141

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions cmake/modules/GetGitRevision.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,23 @@ function(get_git_revision)
set(GIT_REVISION "Failed to get git revision." PARENT_SCOPE)
endif(NOT GIT)

exec_program(${GIT} ${CMAKE_CURRENT_SOURCE_DIR}
exec_program(${GIT} -C "${CMAKE_CURRENT_SOURCE_DIR}"
ARGS "rev-parse HEAD"
OUTPUT_VARIABLE REVISION
RETURN_VALUE rev_parse_ret
)
exec_program(${GIT} ${CMAKE_CURRENT_SOURCE_DIR}
exec_program(${GIT} -C "${CMAKE_CURRENT_SOURCE_DIR}"
ARGS "rev-parse --short HEAD"
OUTPUT_VARIABLE REVISION_SHORT
RETURN_VALUE rev_parse_short_ret
)

# Might not be building from a git repo
if((NOT ${rev_parse_ret} EQUAL "0") OR (NOT ${rev_parse_short_ret} EQUAL "0"))
set(GIT_REVISION_SHORT "Snapshot")
set(GIT_REVISION "Failed to get git revision.")
endif()

set(GIT_REVISION_SHORT ${REVISION_SHORT} PARENT_SCOPE)
set(GIT_REVISION ${REVISION} PARENT_SCOPE)

Expand Down