summaryrefslogtreecommitdiff
path: root/cmake/utils/GenVersionHeader.cmake
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2026-02-15 17:54:30 +0100
committerSander Vrijders <sander@ouroboros.rocks>2026-02-18 08:02:16 +0100
commit079035dbf4890e667c5e931295a1c24f28d9c0df (patch)
tree69bb016631636aea1541719e6634a6bebd588e4e /cmake/utils/GenVersionHeader.cmake
parente9ac4a01f3b1389f7d4d39e0faa6936f17e881ab (diff)
downloadouroboros-079035dbf4890e667c5e931295a1c24f28d9c0df.tar.gz
ouroboros-079035dbf4890e667c5e931295a1c24f28d9c0df.zip
build: Add git hash to version string
Embed git commit hash into version.h and irmd --version output using git describe. Regenerated at build time to stay current across commits. Ouroboros version MAJOR.MINOR.PATCH (TAG-COMMITS-GHASH-dirty) Example for dirty work tree (uncommitted changes): $ irmd --version Ouroboros version 0.22.0 (0.22.0-36-g86dba544-dirty) Example after commit: $ sudo irmd --version Ouroboros version 0.22.0-37-g55fa9445 Officical release (on tag): Ouroboros version 0.22.0 Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'cmake/utils/GenVersionHeader.cmake')
-rw-r--r--cmake/utils/GenVersionHeader.cmake11
1 files changed, 11 insertions, 0 deletions
diff --git a/cmake/utils/GenVersionHeader.cmake b/cmake/utils/GenVersionHeader.cmake
new file mode 100644
index 00000000..5f5821b9
--- /dev/null
+++ b/cmake/utils/GenVersionHeader.cmake
@@ -0,0 +1,11 @@
+include(${CMAKE_CURRENT_LIST_DIR}/GetGitHash.cmake)
+get_git_hash(${GIT_DIR} ${PACKAGE_VERSION_MAJOR} ${PACKAGE_VERSION_MINOR} ${PACKAGE_VERSION_PATCH} PACKAGE_VERSION_STRING)
+
+configure_file(${INPUT_FILE} ${OUTPUT_FILE}.tmp @ONLY)
+
+execute_process(
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ ${OUTPUT_FILE}.tmp ${OUTPUT_FILE}
+)
+
+file(REMOVE ${OUTPUT_FILE}.tmp)