summaryrefslogtreecommitdiffstats
path: root/cmake/GenerateVersion.cmake
diff options
context:
space:
mode:
authorManuel Bentele2020-10-22 12:08:34 +0200
committerManuel Bentele2020-10-22 12:08:34 +0200
commitf9872723efc831827d179c3baf5b9f6c428512c4 (patch)
tree9662cc3071362570a1f4051f0850b41fbdfff246 /cmake/GenerateVersion.cmake
parent[BUILD] add option to build the dnbd3-server with afl-fuzz support (diff)
downloaddnbd3-f9872723efc831827d179c3baf5b9f6c428512c4.tar.gz
dnbd3-f9872723efc831827d179c3baf5b9f6c428512c4.tar.xz
dnbd3-f9872723efc831827d179c3baf5b9f6c428512c4.zip
[BUILD] add CMake targets to build binary and source packages with CPack
This patch adds the following CMake targets - package - source to build bundeled packages. Those packages contain either all built binary artifacts or all source files for source code distribution. Both CMake targets are available in Release build configuration.
Diffstat (limited to 'cmake/GenerateVersion.cmake')
-rw-r--r--cmake/GenerateVersion.cmake38
1 files changed, 12 insertions, 26 deletions
diff --git a/cmake/GenerateVersion.cmake b/cmake/GenerateVersion.cmake
index 4dfdaa8..8574ba7 100644
--- a/cmake/GenerateVersion.cmake
+++ b/cmake/GenerateVersion.cmake
@@ -3,32 +3,18 @@
# Copyright (C) 2020 Manuel Bentele <development@manuel-bentele.de>
#
-# get Git short hash and tag of latest repository commit
-execute_process(COMMAND git describe HEAD
- OUTPUT_VARIABLE DNBD3_BUILD_VERSION
- OUTPUT_STRIP_TRAILING_WHITESPACE)
-if(DNBD3_BUILD_VERSION STREQUAL "")
- set(DNBD3_BUILD_VERSION "unknown")
-endif(DNBD3_BUILD_VERSION STREQUAL "")
+# set CMake module path to include version macros
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
+ ${VERSION_MODULE_PATH})
-# get status of Git repository
-execute_process(COMMAND git status --porcelain
- OUTPUT_VARIABLE DNBD3_GIT_STATUS
- OUTPUT_STRIP_TRAILING_WHITESPACE)
+# include version macros
+include(Version)
-# check if Git repository is dirty
-if(NOT DNBD3_GIT_STATUS STREQUAL "")
- # the Git repository is dirty, thus extend the version information
- set(DNBD3_BUILD_VERSION "${DNBD3_BUILD_VERSION}-modified")
+# get Git version of Git repository
+get_repository_version(DNBD3_VERSION ${VERSION_INPUT_FILE} ${VERSION_BUILD_TYPE})
- # print a message in Release build configuration to warn about the dirty repository
- if(VERSION_BUILD_TYPE MATCHES "Release")
- message(WARNING "This dnbd3 Git repository is dirty! Please commit or revert all changes for a ${VERSION_BUILD_TYPE} build!")
- endif(VERSION_BUILD_TYPE MATCHES "Release")
-endif(NOT DNBD3_GIT_STATUS STREQUAL "")
-
-# set current build type of the project
-set(DNBD3_BUILD_TYPE ${VERSION_BUILD_TYPE})
-
-# write dnbd3 version into a new C source file based on the specified version template
-configure_file(${VERSION_INPUT_FILE} ${VERSION_OUTPUT_FILE})
+# generate version header if header does not exists
+if(NOT EXISTS ${VERSION_INPUT_FILE})
+ # write dnbd3 version into a new C source file based on the specified version template
+ configure_file(${VERSION_INPUT_FILE_TEMPLATE} ${VERSION_OUTPUT_FILE})
+endif(NOT EXISTS ${VERSION_INPUT_FILE})