generate git-revision.h at build time instead of configure time

Replace execute_process with add_custom_target so the git revision
check runs on every build, not just on cmake configure.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-29 19:35:20 +01:00
parent fb9d6e917c
commit 00c980af68
2 changed files with 21 additions and 3 deletions

View File

@@ -267,12 +267,16 @@ endif ()
#--- start create git-revision.h ----------------------------------------------
if (IS_GIT_REPO)
execute_process(COMMAND sh ${CMAKE_SOURCE_DIR}/src/git_revision.sh)
add_custom_target(git_revision ALL
COMMAND sh ${CMAKE_SOURCE_DIR}/src/git_revision.sh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Checking git revision"
)
set(HAVE_GIT_REV_H "-DHAVE_GIT_REV_H")
set(HAVE_GIT_REV_H "-DHAVE_GIT_REV_H")
set(GIT_REV_H "git-revision.h")
else (IS_GIT_REPO)
set(HAVE_GIT_REV_H "")
set(HAVE_GIT_REV_H "")
set(GIT_REV_H "")
endif (IS_GIT_REPO)