summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/modules/GitRevParse.cmake14
1 files changed, 14 insertions, 0 deletions
diff --git a/cmake/modules/GitRevParse.cmake b/cmake/modules/GitRevParse.cmake
new file mode 100644
index 0000000..9005d65
--- /dev/null
+++ b/cmake/modules/GitRevParse.cmake
@@ -0,0 +1,14 @@
+function(git_rev_parse VAR)
+ execute_process(
+ COMMAND git rev-parse --short HEAD
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ RESULT_VARIABLE PARSE_RESULT
+ OUTPUT_VARIABLE PARSE_OUTPUT
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ if(NOT PARSE_RESULT)
+ set(${VAR} ${PARSE_OUTPUT} PARENT_SCOPE)
+ else()
+ set(${VAR} "Unknown" PARENT_SCOPE)
+ endif()
+endfunction()