diff options
author | Jens Lorenz <jlorenz@de.adit-jv.com> | 2018-02-12 17:45:56 +0100 |
---|---|---|
committer | Jens Lorenz <jlorenz@de.adit-jv.com> | 2018-02-13 11:05:45 +0100 |
commit | 5b8411277e44e92eea3b8e9469af003415c02a6f (patch) | |
tree | 1ef22847112e596d79de199ce5de1c500c86f8cd /cmake/MacroVersionFromGit.cmake | |
parent | a4e8cdcef0ebf57b23ea6676a54c39e256e906eb (diff) | |
download | audiomanager-5b8411277e44e92eea3b8e9469af003415c02a6f.tar.gz |
CMake: Implement VCS agnostic versioning
Versioning should not strictly depend on Version Control System (e.g. git).
Best approach is to have a dedicated VERSION file exposing with format
<Major>.<Minor>.<Revision>. Target is that maintainer will manually release
the version once patches/fixes are merged e.g. to a stabilization branch.
In order to have an OEM specific meta information exposed with the version
information EXTRAVERSIONINFO can be specified by CMAKE flag.
Signed-off-by: Guerra Mattia <mguerra@de.adit-jv.com>
Diffstat (limited to 'cmake/MacroVersionFromGit.cmake')
-rw-r--r-- | cmake/MacroVersionFromGit.cmake | 55 |
1 files changed, 8 insertions, 47 deletions
diff --git a/cmake/MacroVersionFromGit.cmake b/cmake/MacroVersionFromGit.cmake index 94931c6..fca7bdc 100644 --- a/cmake/MacroVersionFromGit.cmake +++ b/cmake/MacroVersionFromGit.cmake @@ -1,50 +1,11 @@ -# get the current git version -execute_process(COMMAND git tag - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_VARIABLE TAG_LIST - OUTPUT_STRIP_TRAILING_WHITESPACE) - -IF (TAG_LIST AND NOT VERSION) - STRING (REPLACE "\n" ";" TAG_LIST ${TAG_LIST}) - - set (VERSION_LIST) - - foreach (element ${TAG_LIST}) - STRING (REGEX MATCH "^[0-9]+\\.." SINGLE_VERSION ${element}) - LIST (APPEND VERSION_LIST ${SINGLE_VERSION}) - endforeach (element) - - LIST (REVERSE VERSION_LIST) - - LIST (GET VERSION_LIST 0 VERSION_MISSING_MINOR) - - execute_process(COMMAND git --no-pager log --pretty=oneline HEAD...${VERSION_MISSING_MINOR} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - OUTPUT_VARIABLE COMMIT_LIST - OUTPUT_STRIP_TRAILING_WHITESPACE) - - IF (COMMIT_LIST) - STRING (REPLACE "\n" ";" COMMIT_LIST ${COMMIT_LIST}) - - LIST (LENGTH COMMIT_LIST MINOR_VERSION) - - SET (DAEMONVERSION "${VERSION_MISSING_MINOR}.${MINOR_VERSION}") - ENDIF (COMMIT_LIST) -ENDIF (TAGLIST AND NOT VERSION) - -if (NOT DAEMONVERSION) - #Can be changed via passing -DVERSION="XXX" to cmake - if(NOT DEFINED VERSION) - set( DAEMONVERSION "homebrew-${CMAKE_SOURCE_DIR}" ) - else (NOT DEFINED VERSION) - set( DAEMONVERSION "${VERSION}" ) - endif(NOT DEFINED VERSION) -else (NOT DAEMONVERSION) - STRING(REGEX REPLACE "(-)[^-]+$" "" DAEMONVERSION ${DAEMONVERSION}) - STRING(REGEX REPLACE "-" "." DAEMONVERSION ${DAEMONVERSION}) -endif(NOT DAEMONVERSION) - -message(STATUS "Build Version ${DAEMONVERSION}") +#Can be changed via passing -DVERSION="XXX" to cmake +if (NOT DEFINED VERSION) + FILE(READ "VERSION" DAEMONVERSION) +else (NOT DEFINED VERSION) + set (DAEMONVERSION "${VERSION}") +endif (NOT DEFINED VERSION) + +message(STATUS "Build Version ${DAEMONVERSION}${EXTRAVERSIONINFO}") execute_process(COMMAND git log --pretty=short WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG) |