From 248dbfa4a2c8aaed4093b8bf02595972a9f289aa Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 10 Mar 2017 13:17:46 +0000 Subject: [PATCH] Allow external overriding of auto-fetched git hash identifier in cmake * This is useful if the build doesn't happen within a git checkout and you want to pass in the hash anyway, but it also allows adding suffixes like -official etc. --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bfcd19704..b6eb9c5cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,8 @@ if(CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR) message(FATAL_ERROR "In-source builds not allowed") endif() +set(BUILD_VERSION_HASH "" CACHE STRING "The current git commit hash, possibly with suffixes to indicate build type") + function(get_git_hash _git_hash) if(EXISTS "${CMAKE_SOURCE_DIR}/.git") execute_process( @@ -41,6 +43,9 @@ function(get_git_hash _git_hash) if(NOT GIT_HASH) set(GIT_HASH "NO_GIT_COMMIT_HASH_DEFINED") endif() + if(BUILD_VERSION_HASH) + set(GIT_HASH "${BUILD_VERSION_HASH}") + endif() set(${_git_hash} "${GIT_HASH}" PARENT_SCOPE) endfunction(get_git_hash)