summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-02-25 07:01:28 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-02-25 07:01:28 +0100
commitf19b8c4d82380ae0defb6c6041270d815164b0d2 (patch)
tree2155a87f86d48f520e77d4fb2fbb6884128da960
parentda761883608d20798c66a2e9243240bb6142b024 (diff)
downloadfastd-f19b8c4d82380ae0defb6c6041270d815164b0d2.tar
fastd-f19b8c4d82380ae0defb6c6041270d815164b0d2.zip
Rewrite 'git describe' version support to update the version whenever needed
-rw-r--r--CMakeLists.txt8
-rw-r--r--GitVersion.cmake13
-rw-r--r--config.h.in2
-rw-r--r--src/CMakeLists.txt13
-rw-r--r--src/types.h1
5 files changed, 15 insertions, 22 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8bc5c84..c87786c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,13 +2,7 @@ cmake_minimum_required(VERSION 2.8.3)
project(FASTD C)
set(CMAKE_MODULE_PATH ${FASTD_SOURCE_DIR})
-
-include(GitVersion)
-
-git_version(FASTD_VERSION ${FASTD_SOURCE_DIR})
-if(NOT FASTD_VERSION)
- set(FASTD_VERSION "v7+")
-endif(NOT FASTD_VERSION)
+set(FASTD_VERSION "v7+")
find_package(BISON 2.5 REQUIRED)
find_package(FLEX REQUIRED)
diff --git a/GitVersion.cmake b/GitVersion.cmake
deleted file mode 100644
index 527332d..0000000
--- a/GitVersion.cmake
+++ /dev/null
@@ -1,13 +0,0 @@
-find_program(GIT_EXECUTABLE git DOC "path to the git executable")
-mark_as_advanced(GIT_EXECUTABLE)
-
-function(git_version RESULT_VAR DIR)
- set(${RESULT_VAR} "" PARENT_SCOPE)
- if(GIT_EXECUTABLE)
- execute_process(COMMAND ${GIT_EXECUTABLE} describe --dirty WORKING_DIRECTORY ${DIR} OUTPUT_VARIABLE git_version_OUTPUT ERROR_VARIABLE git_version_ERROR RESULT_VARIABLE git_version_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE)
-
- if(${git_version_RESULT} EQUAL 0)
- set(${RESULT_VAR} "${git_version_OUTPUT}" PARENT_SCOPE)
- endif()
- endif()
-endfunction(git_version)
diff --git a/config.h.in b/config.h.in
index 5aa1f6a..0ad647c 100644
--- a/config.h.in
+++ b/config.h.in
@@ -27,8 +27,6 @@
#ifndef _FASTD_CONFIG_H_
#define _FASTD_CONFIG_H_
-#define FASTD_VERSION "@FASTD_VERSION@"
-
#cmakedefine WITH_CAPABILITIES
#cmakedefine USE_CRYPTO_AES128CTR
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 916a726..0b45153 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -36,4 +36,17 @@ add_executable(fastd
set_target_properties(fastd PROPERTIES COMPILE_FLAGS -pthread ${UECC_CFLAGS_OTHER} LINK_FLAGS -pthread ${UECC_LDFLAGS_OTHER})
target_link_libraries(fastd rt ${CAP_LIBRARY} ${UECC_LIBRARIES} ${NACL_LIBRARY})
+add_custom_target(
+ version
+ COMMAND echo "#ifndef _FASTD_VERSION_H_" > ${CMAKE_CURRENT_BINARY_DIR}/version.h.new
+ COMMAND echo "#define _FASTD_VERSION_H_" >> ${CMAKE_CURRENT_BINARY_DIR}/version.h.new
+ COMMAND sh -c "echo \"#define FASTD_VERSION \\\"\$(git describe --dirty || echo ${FASTD_VERSION})\\\"\"" >> ${CMAKE_CURRENT_BINARY_DIR}/version.h.new
+ COMMAND echo "#endif /* _FASTD_VERSION_H_ */" >> ${CMAKE_CURRENT_BINARY_DIR}/version.h.new
+ COMMAND cmp -s ${CMAKE_CURRENT_BINARY_DIR}/version.h.new ${CMAKE_CURRENT_BINARY_DIR}/version.h && rm ${CMAKE_CURRENT_BINARY_DIR}/version.h.new || mv ${CMAKE_CURRENT_BINARY_DIR}/version.h.new ${CMAKE_CURRENT_BINARY_DIR}/version.h
+ WORKING_DIRECTORY "${FASTD_SOURCE_DIR}"
+ VERBATIM
+)
+
+add_dependencies(fastd version)
+
install(TARGETS fastd RUNTIME DESTINATION bin)
diff --git a/src/types.h b/src/types.h
index 4cd48e6..1a0b791 100644
--- a/src/types.h
+++ b/src/types.h
@@ -34,6 +34,7 @@
#define _FASTD_TYPES_H_
#include <config.h>
+#include <version.h>
typedef enum fastd_mode {