summaryrefslogtreecommitdiffstats
path: root/cmake/GenerateVersion.cmake
diff options
context:
space:
mode:
authorManuel Bentele2020-10-16 17:15:49 +0200
committerManuel Bentele2020-10-16 17:15:49 +0200
commit969496f15e1e0359e26c2c6e995ad4ef82720f86 (patch)
tree358466216630eb10e8ee91b9ede490424f6db848 /cmake/GenerateVersion.cmake
parent[FUSE] turn on compiler optimization to fix warning (diff)
downloaddnbd3-969496f15e1e0359e26c2c6e995ad4ef82720f86.tar.gz
dnbd3-969496f15e1e0359e26c2c6e995ad4ef82720f86.tar.xz
dnbd3-969496f15e1e0359e26c2c6e995ad4ef82720f86.zip
[BUILD] rewrite CMake build system to track changes of source files
This change restructures the source code directories, separates shared form non-shared application code and adds CMake dependencies. These dependencies allow the tracking of changes and trigger a rebuild of those build targets where changed files are involved. WARNING: Note that the support of the DNBD3_SERVER_AFL build option is not supported yet. Thus, the option should be never turned on.
Diffstat (limited to 'cmake/GenerateVersion.cmake')
-rw-r--r--cmake/GenerateVersion.cmake15
1 files changed, 15 insertions, 0 deletions
diff --git a/cmake/GenerateVersion.cmake b/cmake/GenerateVersion.cmake
new file mode 100644
index 0000000..e336489
--- /dev/null
+++ b/cmake/GenerateVersion.cmake
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# 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_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+if(DNBD3_VERSION STREQUAL "")
+ set(DNBD3_VERSION "unknown")
+endif(DNBD3_VERSION STREQUAL "")
+
+# write dnbd3 version into a new C source file based on the specified version template
+configure_file(${VERSION_INPUT_FILE} ${VERSION_OUTPUT_FILE})