aboutsummaryrefslogtreecommitdiff
path: root/cmake/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/Modules')
-rw-r--r--cmake/Modules/GenerateVersion.cmake26
1 files changed, 11 insertions, 15 deletions
diff --git a/cmake/Modules/GenerateVersion.cmake b/cmake/Modules/GenerateVersion.cmake
index 9b5304ad5..ad0e38263 100644
--- a/cmake/Modules/GenerateVersion.cmake
+++ b/cmake/Modules/GenerateVersion.cmake
@@ -1,28 +1,24 @@
# Always run during 'make'
-if(VERSION_EXTRA)
- set(VERSION_GITHASH "${VERSION_STRING}")
-else()
- execute_process(COMMAND git describe --tag --dirty
+if(DEVELOPMENT_BUILD)
+ execute_process(COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY "${GENERATE_VERSION_SOURCE_DIR}"
OUTPUT_VARIABLE VERSION_GITHASH OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
-
if(VERSION_GITHASH)
- message(STATUS "*** Detected Git version ${VERSION_GITHASH} ***")
- else()
- execute_process(COMMAND git describe --always --tag --dirty
+ set(VERSION_GITHASH "${VERSION_STRING}-${VERSION_GITHASH}")
+ execute_process(COMMAND git diff-index --quiet HEAD
WORKING_DIRECTORY "${GENERATE_VERSION_SOURCE_DIR}"
- OUTPUT_VARIABLE VERSION_GITHASH OUTPUT_STRIP_TRAILING_WHITESPACE
- ERROR_QUIET)
- if(VERSION_GITHASH)
- set(VERSION_GITHASH "${VERSION_STRING}-${VERSION_GITHASH}")
- message(STATUS "*** Detected shallow Git version ${VERSION_GITHASH} ***")
- else()
- set(VERSION_GITHASH "${VERSION_STRING}")
+ RESULT_VARIABLE IS_DIRTY)
+ if(IS_DIRTY)
+ set(VERSION_GITHASH "${VERSION_GITHASH}-dirty")
endif()
+ message(STATUS "*** Detected Git version ${VERSION_GITHASH} ***")
endif()
endif()
+if(NOT VERSION_GITHASH)
+ set(VERSION_GITHASH "${VERSION_STRING}")
+endif()
configure_file(
${GENERATE_VERSION_SOURCE_DIR}/cmake_config_githash.h.in