summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-06-17 20:56:32 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-06-20 10:45:38 +0200
commitaaf71774131198de2095c07e560fb420833c544d (patch)
tree6f5974344d4fcb041822ada6381bdacc1667c3ad
parent2117838cf9fb083f6f74386abbb56e3b28d4db46 (diff)
downloadbiboumi-aaf71774131198de2095c07e560fb420833c544d.tar.gz
biboumi-aaf71774131198de2095c07e560fb420833c544d.tar.bz2
biboumi-aaf71774131198de2095c07e560fb420833c544d.tar.xz
biboumi-aaf71774131198de2095c07e560fb420833c544d.zip
Write the software version, including the git hash, in config.h using cmake
-rw-r--r--CMakeLists.txt25
-rw-r--r--src/config.h.cmake3
2 files changed, 25 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8a565ff..3d634b1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,8 +2,9 @@ cmake_minimum_required(VERSION 2.6)
project(biboumi)
-set(${PROJECT_NAME}_VERSION_MAJOR 0)
-set(${PROJECT_NAME}_VERSION_MINOR 1)
+set(${PROJECT_NAME}_VERSION_MAJOR 1)
+set(${PROJECT_NAME}_VERSION_MINOR 0)
+set(${PROJECT_NAME}_VERSION_SUFFIX "~dev")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -pedantic -Wall -Wextra")
@@ -23,6 +24,26 @@ find_package(Libidn)
find_package(SystemdDaemon)
find_package(Botan)
+#
+## Get the software version
+#
+if(${PROJECT_NAME}_VERSION_SUFFIX MATCHES "~dev")
+ # If we are on a dev version, append the hash of the current git HEAD to
+ # the version
+ include(FindGit)
+ if(GIT_FOUND)
+ execute_process(COMMAND git --git-dir=${CMAKE_SOURCE_DIR}/.git rev-parse --short HEAD
+ OUTPUT_VARIABLE GIT_REVISION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(GIT_REVISION)
+ set(${PROJECT_NAME}_VERSION_SUFFIX "${${PROJECT_NAME}_VERSION_SUFFIX} (${GIT_REVISION})")
+ endif()
+ endif()
+endif()
+
+set(BIBOUMI_VERSION
+ ${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}${${PROJECT_NAME}_VERSION_SUFFIX})
+
# To be able to include the config.h file generated by cmake
include_directories("${CMAKE_CURRENT_BINARY_DIR}/src/")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/")
diff --git a/src/config.h.cmake b/src/config.h.cmake
index 66ea967..bb4a5b8 100644
--- a/src/config.h.cmake
+++ b/src/config.h.cmake
@@ -2,4 +2,5 @@
#cmakedefine LIBIDN_FOUND
#cmakedefine SYSTEMDDAEMON_FOUND
#cmakedefine POLLER ${POLLER}
-#cmakedefine BOTAN_FOUND \ No newline at end of file
+#cmakedefine BOTAN_FOUND
+#cmakedefine BIBOUMI_VERSION "${BIBOUMI_VERSION}" \ No newline at end of file