diff options
-rw-r--r-- | CMakeLists.txt | 8 | ||||
-rw-r--r-- | GitVersion.cmake | 13 | ||||
-rw-r--r-- | config.h.in | 2 |
3 files changed, 21 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5de8ccd..8bc5c84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,15 @@ cmake_minimum_required(VERSION 2.8.3) project(FASTD C) -set(PROJECT_VERSION "7+") 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) + find_package(BISON 2.5 REQUIRED) find_package(FLEX REQUIRED) diff --git a/GitVersion.cmake b/GitVersion.cmake new file mode 100644 index 0000000..8eed8c5 --- /dev/null +++ b/GitVersion.cmake @@ -0,0 +1,13 @@ +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 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 8fdba1b..5aa1f6a 100644 --- a/config.h.in +++ b/config.h.in @@ -27,7 +27,7 @@ #ifndef _FASTD_CONFIG_H_ #define _FASTD_CONFIG_H_ -#define FASTD_VERSION "@PROJECT_VERSION@" +#define FASTD_VERSION "@FASTD_VERSION@" #cmakedefine WITH_CAPABILITIES |