diff options
author | Szczepan Zalega <szczepan@nitrokey.com> | 2018-07-18 10:43:48 +0200 |
---|---|---|
committer | Szczepan Zalega <szczepan@nitrokey.com> | 2018-07-18 10:43:48 +0200 |
commit | f6d08b36552ee2aae412086123a571b9929c0ae3 (patch) | |
tree | c579692982ef772d20e33fa788aa20dd2f2bedf5 /CMakeLists.txt | |
parent | 430e4b4116ec00c4875170642f8ae04bc3497d88 (diff) | |
download | libnitrokey-f6d08b36552ee2aae412086123a571b9929c0ae3.tar.gz libnitrokey-f6d08b36552ee2aae412086123a571b9929c0ae3.tar.bz2 |
Handle build without Git repository info
Sets version to "unknown"
Fixes #126
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 16 |
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) |