summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt16
1 files changed, 15 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 43d15df..d29c087 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -117,8 +117,22 @@ IF (LOG_VOLATILE_DATA)
ENDIF()
+OPTION(ADD_GIT_INFO "Add information about source code version from Git repository" TRUE)
# generate version.h
-exec_program("git" ${CMAKE_CURRENT_SOURCE_DIR} ARGS "describe --always" OUTPUT_VARIABLE PROJECT_VERSION_GIT)
+IF(ADD_GIT_INFO)
+execute_process(
+ COMMAND git describe --always --abbrev=4 HEAD
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ RESULT_VARIABLE PROJECT_VERSION_GIT_RETURN_CODE
+ OUTPUT_VARIABLE PROJECT_VERSION_GIT
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_QUIET
+)
+ENDIF()
+IF((NOT ${ADD_GIT_INFO}) OR (${PROJECT_VERSION_GIT_RETURN_CODE}))
+ SET(PROJECT_VERSION_GIT "unknown")
+ MESSAGE(STATUS "Setting Git library version to: " ${PROJECT_VERSION_GIT} )
+ENDIF()
configure_file("version.cc.in" "version.cc" @ONLY)