diff options
| author | Dimitri Staessens <dimitri@ouroboros.rocks> | 2026-02-15 18:54:42 +0100 |
|---|---|---|
| committer | Sander Vrijders <sander@ouroboros.rocks> | 2026-02-18 08:02:26 +0100 |
| commit | b6b0b754d99dc2298930cb5db42950bf7c08cc08 (patch) | |
| tree | a0f9da590f7a40f4af8b818f26241fa973fa4e97 /cmake/version.cmake | |
| parent | 03b3f0c5345e4ddc4cdfad050e9b28e79ffa6721 (diff) | |
| download | ouroboros-b6b0b754d99dc2298930cb5db42950bf7c08cc08.tar.gz ouroboros-b6b0b754d99dc2298930cb5db42950bf7c08cc08.zip | |
build: Automatically parse version from tag
The build will now parse tags so the git tag is now the single source
of truth for a version. We do not need to manually maintain the
version header.
The VERSION file uses git's export-subst feature. When git archive
creates a snapshot (e.g. cgit), git substitutes the $Format:...$
placeholder with the output of git describe, embedding the version
string directly in the archive. This requires the export-subst
attribute to be set for the VERSION file in the repository's
.gitattributes.
The version is resolved in the following order:
- git describe (inside a git repository with tags)
- the VERSION file (archives/snapshots)
- 0.0.0 (fallback)
The build system will warn when it can't set a correct version, such
as in a git repo without tags, or an archive without VERSION.
Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'cmake/version.cmake')
| -rw-r--r-- | cmake/version.cmake | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/cmake/version.cmake b/cmake/version.cmake index 518fa5bf..75a4ac59 100644 --- a/cmake/version.cmake +++ b/cmake/version.cmake @@ -1,11 +1,15 @@ -set(PACKAGE_VERSION_MAJOR 0) -set(PACKAGE_VERSION_MINOR 22) -set(PACKAGE_VERSION_PATCH 0) +include(utils/ParseGitTag) + +# Parse version from git tag or use custom version if unavailable +parse_git_tag(${CMAKE_SOURCE_DIR} PACKAGE_VERSION_MAJOR PACKAGE_VERSION_MINOR + PACKAGE_VERSION_PATCH) + set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}") include(utils/GetGitHash) -get_git_hash(${CMAKE_SOURCE_DIR} ${PACKAGE_VERSION_MAJOR} ${PACKAGE_VERSION_MINOR} ${PACKAGE_VERSION_PATCH} PACKAGE_VERSION_STRING) +get_git_hash(${CMAKE_SOURCE_DIR} ${PACKAGE_VERSION_MAJOR} ${PACKAGE_VERSION_MINOR} + ${PACKAGE_VERSION_PATCH} PACKAGE_VERSION_STRING) configure_file("${CMAKE_SOURCE_DIR}/include/ouroboros/version.h.in" "${CMAKE_BINARY_DIR}/include/ouroboros/version.h" @ONLY) |
