diff options
author | Manuel Bentele | 2020-10-19 16:14:41 +0200 |
---|---|---|
committer | Manuel Bentele | 2020-10-19 16:16:58 +0200 |
commit | c6a843122ad60fff05e7daa2f7b30abc2ec101e9 (patch) | |
tree | aa60daa34b282165f1a70c4654d84530cbd53fa2 /cmake | |
parent | [BUILD] build Linux kernel module only on Linux systems (diff) | |
download | dnbd3-c6a843122ad60fff05e7daa2f7b30abc2ec101e9.tar.gz dnbd3-c6a843122ad60fff05e7daa2f7b30abc2ec101e9.tar.xz dnbd3-c6a843122ad60fff05e7daa2f7b30abc2ec101e9.zip |
[BUILD] set build type and stop Release build if repository is dirty
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/GenerateVersion.cmake | 22 | ||||
-rw-r--r-- | cmake/ProjectVersion.cmake | 1 |
2 files changed, 19 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}) diff --git a/cmake/ProjectVersion.cmake b/cmake/ProjectVersion.cmake index 108505d..8b7160c 100644 --- a/cmake/ProjectVersion.cmake +++ b/cmake/ProjectVersion.cmake @@ -14,6 +14,7 @@ macro(gen_project_version VERSION_INPUT_FILE VERSION_OUTPUT_FILE) add_custom_command(OUTPUT ${VERSION_OUTPUT_FILE} COMMAND ${CMAKE_COMMAND} -D VERSION_INPUT_FILE=${VERSION_INPUT_FILE} -D VERSION_OUTPUT_FILE=${VERSION_OUTPUT_FILE} + -D VERSION_BUILD_TYPE=${CMAKE_BUILD_TYPE} -P ${PROJECT_MODULES_DIR}/GenerateVersion.cmake COMMENT "Generating ${VERSION_OUTPUT_FILENAME}" DEPENDS regenerate-version-file) |