summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 08:14:45 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 08:14:56 +0000
commit62010aafd4014c19d4d0cf36f01d3c53b43c5e7b (patch)
tree6f1fd3cfe312292e359bb7befa4b44a5fe986182 /cmake
parentReleasing debian version 1.7.3-2. (diff)
downloadttyd-62010aafd4014c19d4d0cf36f01d3c53b43c5e7b.tar.xz
ttyd-62010aafd4014c19d4d0cf36f01d3c53b43c5e7b.zip
Merging upstream version 1.7.7.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/GetGitVersion.cmake47
1 files changed, 47 insertions, 0 deletions
diff --git a/cmake/GetGitVersion.cmake b/cmake/GetGitVersion.cmake
new file mode 100644
index 0000000..6c8f6c8
--- /dev/null
+++ b/cmake/GetGitVersion.cmake
@@ -0,0 +1,47 @@
+find_package(Git)
+
+function(get_git_version var1 var2)
+ if(GIT_EXECUTABLE)
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} describe --tags --match "[0-9]*.[0-9]*.[0-9]*" --abbrev=8
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ RESULT_VARIABLE status
+ OUTPUT_VARIABLE GIT_VERSION
+ )
+ if (${status})
+ set(GIT_VERSION "0.0.0")
+ else()
+ string(STRIP ${GIT_VERSION} GIT_VERSION)
+ string(REGEX REPLACE "-[0-9]+-g" "-" GIT_VERSION ${GIT_VERSION})
+ endif()
+ else()
+ set(GIT_VERSION "0.0.0")
+ endif()
+
+ string(REGEX MATCH "^[0-9]+.[0-9]+.[0-9]+" SEM_VER "${GIT_VERSION}")
+
+ message("-- Git Tag: ${GIT_VERSION}, Sem Ver: ${SEM_VER}")
+
+ set(${var1} ${GIT_VERSION} PARENT_SCOPE)
+ set(${var2} ${SEM_VER} PARENT_SCOPE)
+endfunction()
+
+function(get_git_head var1)
+ if(GIT_EXECUTABLE)
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} --git-dir ${CMAKE_CURRENT_SOURCE_DIR}/.git rev-parse --short HEAD
+ RESULT_VARIABLE status
+ OUTPUT_VARIABLE GIT_COMMIT
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_QUIET
+ )
+
+ if(${status})
+ set(GIT_COMMIT "unknown")
+ endif()
+
+ message("-- Git Commit: ${GIT_COMMIT}")
+
+ set(${var1} ${GIT_COMMIT} PARENT_SCOPE)
+ endif()
+endfunction()