Permalink
Browse files

Add git branch to C4Version.h

The branch information is necessary for upcoming automatically-updating
snapshots. For Travis, cmake will also pick up the branch name from the
C4REVISION_BRANCH environment variable.
  • Loading branch information...
lluchs committed Oct 3, 2018
1 parent 7616fa8 commit 55c34ecbd7cfe4ee76a4105b3715d24b9eb18dfe
Showing with 17 additions and 0 deletions.
  1. +1 −0 .travis.yml
  2. +15 −0 cmake/GitGetChangesetID.cmake
  3. +1 −0 src/C4Version.h.in
View
@@ -56,6 +56,7 @@ install:
before_script:
- export CXX="$CXXCOMPILER" CC="$CCOMPILER"
- export C4REVISION_BRANCH="$TRAVIS_BRANCH"
- >
cmake
-G"${BSYS/\#*/}"
@@ -42,6 +42,19 @@ function(git_get_changeset_id VAR)
OUTPUT_VARIABLE GIT_TIMESTAMP
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(DEFINED ENV{C4REVISION_BRANCH})
set(GIT_BRANCH "$ENV{C4REVISION_BRANCH}")
else()
execute_process(WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND "${GIT_EXECUTABLE}" "symbolic-ref" "--short" "HEAD"
RESULT_VARIABLE GIT_RESULT
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT GIT_RESULT EQUAL 0)
set(GIT_BRANCH "unknown")
endif()
endif()
endif()
endif()
if (NOT C4REVISION)
@@ -64,11 +77,13 @@ function(git_get_changeset_id VAR)
REGEX "date: .+"
)
string(SUBSTRING "${C4REVISION_TS}" 6 -1 GIT_TIMESTAMP)
set(GIT_BRANCH "unknown")
endif()
if(WORKDIR_DIRTY)
set(WORKDIR_DIRTY 1)
endif()
set(${VAR} "${C4REVISION}" PARENT_SCOPE)
set(${VAR}_DIRTY ${WORKDIR_DIRTY} PARENT_SCOPE)
set(${VAR}_TS "${GIT_TIMESTAMP}" PARENT_SCOPE)
set(${VAR}_BRANCH "${GIT_BRANCH}" PARENT_SCOPE)
endfunction()
View
@@ -40,6 +40,7 @@
#define C4REVISION "@C4REVISION@"
#define C4REVISION_TS "@C4REVISION_TS@"
#endif
#define C4REVISION_BRANCH "@C4REVISION_BRANCH@"
// Build Options
#ifdef _DEBUG

0 comments on commit 55c34ec

Please sign in to comment.