From caf38725ae2802bdc71ea45c40c34635c5090dca Mon Sep 17 00:00:00 2001 From: Andrew Udvare Date: Mon, 20 Dec 2021 19:13:07 -0500 Subject: Allow overriding SCM version info If the build is from a non-repository, these functions will return empty. This patch allows using defines to CMake to set version info such as -DGIT_BRANCH=master. --- CMakeModules/GenerateSCMRev.cmake | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'CMakeModules') diff --git a/CMakeModules/GenerateSCMRev.cmake b/CMakeModules/GenerateSCMRev.cmake index 43ca730ec..c7da2b91d 100644 --- a/CMakeModules/GenerateSCMRev.cmake +++ b/CMakeModules/GenerateSCMRev.cmake @@ -11,9 +11,15 @@ find_package(Git QUIET PATHS "${GIT_EXECUTABLE}") # generate git/build information include(GetGitRevisionDescription) -get_git_head_revision(GIT_REF_SPEC GIT_REV) -git_describe(GIT_DESC --always --long --dirty) -git_branch_name(GIT_BRANCH) +if(NOT GIT_REF_SPEC) + get_git_head_revision(GIT_REF_SPEC GIT_REV) +endif() +if(NOT GIT_DESC) + git_describe(GIT_DESC --always --long --dirty) +endif() +if (NOT GIT_BRANCH) + git_branch_name(GIT_BRANCH) +endif() get_timestamp(BUILD_DATE) # Generate cpp with Git revision from template -- cgit v1.2.3