summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2026-02-15 18:29:10 +0100
committerSander Vrijders <sander@ouroboros.rocks>2026-02-18 08:02:21 +0100
commit03b3f0c5345e4ddc4cdfad050e9b28e79ffa6721 (patch)
treef3aff1cca2f3e67a220f85cdfef5693eb9ecdfdb /cmake
parent079035dbf4890e667c5e931295a1c24f28d9c0df (diff)
downloadouroboros-03b3f0c5345e4ddc4cdfad050e9b28e79ffa6721.tar.gz
ouroboros-03b3f0c5345e4ddc4cdfad050e9b28e79ffa6721.zip
build: Add a version target
This adds a make version target, that will print the version from the build directory without having to compile and run irmd --version. [100%] Updating git hash in version.h [100%] Built target version_header Ouroboros 0.22.0-37-ga3a5da14-dirty [100%] Built target version Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/utils/PrintVersion.cmake8
-rw-r--r--cmake/version.cmake7
2 files changed, 15 insertions, 0 deletions
diff --git a/cmake/utils/PrintVersion.cmake b/cmake/utils/PrintVersion.cmake
new file mode 100644
index 00000000..34148eb7
--- /dev/null
+++ b/cmake/utils/PrintVersion.cmake
@@ -0,0 +1,8 @@
+file(STRINGS "${VERSION_HEADER}" lines REGEX "OUROBOROS_VERSION_STRING")
+foreach(line ${lines})
+ if(line MATCHES "define OUROBOROS_VERSION_STRING \"(.*)\"")
+ set(version "${CMAKE_MATCH_1}")
+ message("Ouroboros ${version}")
+ break()
+ endif()
+endforeach()
diff --git a/cmake/version.cmake b/cmake/version.cmake
index 1998e874..518fa5bf 100644
--- a/cmake/version.cmake
+++ b/cmake/version.cmake
@@ -21,3 +21,10 @@ add_custom_target(version_header ALL
-P ${CMAKE_SOURCE_DIR}/cmake/utils/GenVersionHeader.cmake
COMMENT "Updating git hash in version.h"
)
+
+add_custom_target(version
+ COMMAND ${CMAKE_COMMAND}
+ -DVERSION_HEADER=${CMAKE_BINARY_DIR}/include/ouroboros/version.h
+ -P ${CMAKE_SOURCE_DIR}/cmake/utils/PrintVersion.cmake
+ DEPENDS version_header
+)