From: Jo-Philipp Wich Date: Fri, 17 Feb 2017 17:22:02 +0000 (+0100) Subject: build: infer VERSION from Git history X-Git-Url: https://git.librecmc.org/?p=oweals%2Fopkg-lede.git;a=commitdiff_plain;h=3b8b122de4b067f0181363e31d09eec03e2e1fb9 build: infer VERSION from Git history Pass short hash and commit date as VERSION string. Signed-off-by: Jo-Philipp Wich --- 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)