summaryrefslogtreecommitdiffstats
path: root/GitVersion.cmake
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-02-23 18:46:23 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-02-23 18:46:23 +0100
commit67b5d507010be0528c886133cae73fff0e3c7712 (patch)
tree6966c86e53c365c96c9391e0d0914337042e7f36 /GitVersion.cmake
parent2c0f4a5abbc5663417d1390f658b387378e28978 (diff)
downloadfastd-67b5d507010be0528c886133cae73fff0e3c7712.tar
fastd-67b5d507010be0528c886133cae73fff0e3c7712.zip
Use 'git describe' output as version string when available
Diffstat (limited to 'GitVersion.cmake')
-rw-r--r--GitVersion.cmake13
1 files changed, 13 insertions, 0 deletions
diff --git a/GitVersion.cmake b/GitVersion.cmake
new file mode 100644
index 0000000..8eed8c5
--- /dev/null
+++ b/GitVersion.cmake
@@ -0,0 +1,13 @@
+find_program(GIT_EXECUTABLE git DOC "path to the git executable")
+mark_as_advanced(GIT_EXECUTABLE)
+
+function(git_version RESULT_VAR DIR)
+ set(${RESULT_VAR} "" PARENT_SCOPE)
+ if(GIT_EXECUTABLE)
+ execute_process(COMMAND ${GIT_EXECUTABLE} describe WORKING_DIRECTORY ${DIR} OUTPUT_VARIABLE git_version_OUTPUT ERROR_VARIABLE git_version_ERROR RESULT_VARIABLE git_version_RESULT OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+ if(${git_version_RESULT} EQUAL 0)
+ set(${RESULT_VAR} "${git_version_OUTPUT}" PARENT_SCOPE)
+ endif()
+ endif()
+endfunction(git_version)