summaryrefslogtreecommitdiffstats
path: root/cmake/cmake.d
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-03-25 14:38:40 +0200
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2018-03-29 18:39:15 +0000
commita3c312ece0a77310a9d8ecde1dd0f1267646f4ff (patch)
tree651a0aefce68c8e23617dc590d76bddae0d51670 /cmake/cmake.d
parent6c0e9e48f57ed2f5cf5adf2f51f51cbf130abcf6 (diff)
Adds commit hash to the version.
Added the short hash coming from git lastest git commit to the version number. In addition of the dirty flag it make possible to know from where modifications divergences begin. Change-Id: Id25256f896c8179009d8588f79e7801cc2c90821 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'cmake/cmake.d')
-rw-r--r--cmake/cmake.d/02-variables.cmake11
1 files changed, 10 insertions, 1 deletions
diff --git a/cmake/cmake.d/02-variables.cmake b/cmake/cmake.d/02-variables.cmake
index b4940f2..dc1c313 100644
--- a/cmake/cmake.d/02-variables.cmake
+++ b/cmake/cmake.d/02-variables.cmake
@@ -67,6 +67,13 @@ execute_process(COMMAND git describe --abbrev=0
OUTPUT_STRIP_TRAILING_WHITESPACE
)
+# Get the git commit hash to append to the version
+execute_process(COMMAND git rev-parse --short HEAD
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ OUTPUT_VARIABLE COMMIT_HASH
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
# Detect unstaged or untracked changes
execute_process(COMMAND git status --short
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
@@ -84,7 +91,9 @@ endif()
# attributes then add the dirty flag if git repo not sync'ed
project(${PROJECT_NAME} VERSION ${PROJECT_VERSION} LANGUAGES ${PROJECT_LANGUAGES})
if(NOT ${DIRTY_FLAG})
-set(PROJECT_VERSION "${PROJECT_VERSION}-dirty")
+ set(PROJECT_VERSION "${PROJECT_VERSION}-${COMMIT_HASH}-dirty")
+else()
+ set(PROJECT_VERSION "${PROJECT_VERSION}-${COMMIT_HASH}")
endif()
set(AFB_TOKEN "" CACHE PATH "Default AFB_TOKEN")