From 3b8b122de4b067f0181363e31d09eec03e2e1fb9 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 17 Feb 2017 18:22:02 +0100 Subject: [PATCH] build: infer VERSION from Git history Pass short hash and commit date as VERSION string. Signed-off-by: Jo-Philipp Wich --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d7730c6..34a0a6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,15 @@ IF(NOT BUILD_CPU) SET(BUILD_CPU "${CMAKE_SYSTEM_PROCESSOR}") ENDIF() +EXECUTE_PROCESS(COMMAND git log -1 "--format=%h (%ci)" + OUTPUT_VARIABLE GIT_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +IF(NOT GIT_VERSION) + SET(GIT_VERSION "unknown") +ENDIF() + ADD_DEFINITIONS(-Os -Wall --std=gnu99 -g3 -Wmissing-declarations -DDATADIR="/usr/share" -DOPKGETCDIR="/etc" @@ -23,6 +32,7 @@ ADD_DEFINITIONS(-Os -Wall --std=gnu99 -g3 -Wmissing-declarations -DOPKGLIBDIR="/usr/lib" -DHOST_CPU_STR="${HOST_CPU}" -DBUILD_CPU=${BUILD_CPU} + -DVERSION="${GIT_VERSION}" ) ADD_SUBDIRECTORY(libbb) -- 2.25.1