This repository has been archived by the owner on May 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
88411cc
commit c02b002
Showing
3 changed files
with
67 additions
and
0 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
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,37 @@ | ||
|
||
# this function returns the git hash of the current checkout, if the 'git' | ||
# command is available, it is a git checkout and it is not a tagged release. | ||
function(get_git_revision _hashvar) | ||
# got git? | ||
if(NOT GIT_FOUND) | ||
find_package(Git QUIET) | ||
endif() | ||
if(GIT_FOUND) | ||
# TODO: look for source directory (for out-of-source builds)? | ||
|
||
# check, if we have a tagged release | ||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --exact-match | ||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" | ||
RESULT_VARIABLE EXIT_CODE | ||
OUTPUT_QUIET | ||
ERROR_QUIET | ||
) | ||
# it failed => not a tagged revision | ||
if(NOT ${EXIT_CODE} EQUAL 0) | ||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short=10 HEAD | ||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" | ||
RESULT_VARIABLE EXIT_CODE | ||
OUTPUT_VARIABLE GIT_REV | ||
ERROR_QUIET | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
if(${EXIT_CODE} EQUAL 0) | ||
# all good, set hash | ||
set(${_hashvar} "${GIT_REV}" PARENT_SCOPE) | ||
return() | ||
endif() | ||
endif() | ||
endif() | ||
# no git available or any other error above, set to empty string | ||
set(${_hashvar} "" PARENT_SCOPE) | ||
endfunction() |
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,10 @@ | ||
#ifndef VERSION_HPP | ||
#define VERSION_HPP | ||
|
||
#define VERSION "@VERSION@" | ||
#define VERSION_MAJOR "@VERSION_MAJOR@" | ||
#define VERSION_MINOR "@VERSION_MINOR@" | ||
#define VERSION_PATCH "@VERSION_PATCH@" | ||
#define VERSION_GIT "@VERSION_GIT@" | ||
|
||
#endif |