summaryrefslogtreecommitdiffstats
path: root/cmake/GenerateVersion.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/GenerateVersion.cmake')
-rw-r--r--cmake/GenerateVersion.cmake22
1 files changed, 18 insertions, 4 deletions
diff --git a/cmake/GenerateVersion.cmake b/cmake/GenerateVersion.cmake
index e336489..152ab11 100644
--- a/cmake/GenerateVersion.cmake
+++ b/cmake/GenerateVersion.cmake
@@ -5,11 +5,25 @@
# get Git short hash and tag of latest repository commit
execute_process(COMMAND git describe HEAD
- OUTPUT_VARIABLE DNBD3_VERSION
+ OUTPUT_VARIABLE DNBD3_BUILD_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
-if(DNBD3_VERSION STREQUAL "")
- set(DNBD3_VERSION "unknown")
-endif(DNBD3_VERSION STREQUAL "")
+if(DNBD3_BUILD_VERSION STREQUAL "")
+ set(DNBD3_BUILD_VERSION "unknown")
+endif(DNBD3_BUILD_VERSION STREQUAL "")
+
+# get status of Git repository
+execute_process(COMMAND git status --porcelain
+ OUTPUT_VARIABLE DNBD3_GIT_STATUS
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+if(VERSION_BUILD_TYPE MATCHES "Release" AND NOT DNBD3_GIT_STATUS STREQUAL "")
+ message(FATAL_ERROR "This dnbd3 Git repository is dirty! Please commit or revert all changes for the ${VERSION_BUILD_TYPE} build!")
+else(VERSION_BUILD_TYPE MATCHES "Release" AND NOT DNBD3_GIT_STATUS STREQUAL "")
+ set(DNBD3_BUILD_VERSION "${DNBD3_BUILD_VERSION}-modified")
+endif(VERSION_BUILD_TYPE MATCHES "Release" AND 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})