-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmake: get version from git, or git archive
- Loading branch information
Showing
4 changed files
with
37 additions
and
2 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 +1,2 @@ | ||
docs/rmg-commands.md linguist-generated=true | ||
cmake/RMGGitVersion.cmake export-subst |
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
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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# this is a special value replaced by git archive. | ||
set(RMG_GIT_VERSION "$Format:%(describe:tags=1)$") | ||
|
||
# try to get the tag ourselves from git describe, if we did not have it set above | ||
# (i.e. we are not in a git-created archive). | ||
if(RMG_GIT_VERSION MATCHES "Format:") | ||
set(RMG_GIT_VERSION "v0.0.0") | ||
find_package(Git) | ||
if(Git_FOUND) | ||
execute_process( | ||
COMMAND ${GIT_EXECUTABLE} describe --tags --match "v*" | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
OUTPUT_VARIABLE GIT_OUTPUT | ||
RESULT_VARIABLE GIT_STATUS | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
if(GIT_STATUS EQUAL 0) | ||
set(RMG_GIT_VERSION ${GIT_OUTPUT}) | ||
endif() | ||
endif() | ||
endif() | ||
|
||
# cleanup git describe output to match cmake's expectations. | ||
string(REGEX REPLACE "^v" "" RMG_GIT_VERSION ${RMG_GIT_VERSION}) | ||
string(REGEX REPLACE "-.*$" "" RMG_GIT_VERSION ${RMG_GIT_VERSION}) |