-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update version string setting proceedure
Package maintainers can override the git repo detection by providing their own release version string using cmake -DRELEASE_STRING="you_version" For all other users we check for a git repo and default to the last release version string if none is found
- Loading branch information
Showing
2 changed files
with
34 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,35 @@ | ||
set(LATEST_RELEASE "2017-03-R2") | ||
# This script controls the version string that is passed at compile time. | ||
# To override the version, use cmake -DRELEASE_STRING="you_version" | ||
# If RELEASE_STRING is not explicitly set we attempt to use the latest git | ||
# commit. If cmake isn't being run from within a git repository we use the | ||
# LATEST_RELEASE variable, which developers should set before a release is | ||
# tagged | ||
|
||
if(NOT DEFINED RELEASE_STRING) | ||
set(LATEST_RELEASE "2017-03-R2") | ||
|
||
execute_process( | ||
COMMAND git log -n 1 --format=%h | ||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | ||
RESULT_VARIABLE GIT_EXIT_ERROR | ||
ERROR_QUIET | ||
OUTPUT_VARIABLE GIT_VERSION | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
if (GIT_EXIT_ERROR) | ||
# We're probably not in a git repo | ||
set(RELEASE ${LATEST_RELEASE}) | ||
else (GIT_EXIT_ERROR) | ||
# We're in a git repo | ||
execute_process( | ||
COMMAND git status -s --untracked-files=no | ||
OUTPUT_VARIABLE DIRTY | ||
COMMAND git log -n 1 --format=%h | ||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | ||
RESULT_VARIABLE GIT_EXIT_ERROR | ||
ERROR_QUIET | ||
OUTPUT_VARIABLE GIT_VERSION | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
if ( NOT "${DIRTY}" STREQUAL "" ) | ||
set(DIRTY_FLAG "*") | ||
else() | ||
set(DIRTY_FLAG "") | ||
endif() | ||
set(RELEASE "git-${GIT_VERSION}${DIRTY_FLAG}") | ||
endif (GIT_EXIT_ERROR) | ||
if (GIT_EXIT_ERROR) | ||
# We're probably not in a git repo | ||
set(RELEASE_STRING ${LATEST_RELEASE}) | ||
else (GIT_EXIT_ERROR) | ||
# We're in a git repo | ||
execute_process( | ||
COMMAND git status -s --untracked-files=no | ||
OUTPUT_VARIABLE DIRTY | ||
) | ||
if ( NOT "${DIRTY}" STREQUAL "" ) | ||
set(DIRTY_FLAG "*") | ||
else() | ||
set(DIRTY_FLAG "") | ||
endif() | ||
set(RELEASE_STRING "git-${GIT_VERSION}${DIRTY_FLAG}") | ||
endif (GIT_EXIT_ERROR) | ||
endif(NOT DEFINED RELEASE_STRING) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters