Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Unified Diff: third_party/google_benchmark/cmake/GetGitVersion.cmake

Issue 2865663003: Adding Google benchmarking library. (Closed)
Patch Set: Sketch. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/google_benchmark/cmake/GetGitVersion.cmake
diff --git a/third_party/google_benchmark/cmake/GetGitVersion.cmake b/third_party/google_benchmark/cmake/GetGitVersion.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..8dd948004597acda5a70464ac01bf810747f55ff
--- /dev/null
+++ b/third_party/google_benchmark/cmake/GetGitVersion.cmake
@@ -0,0 +1,51 @@
+# - Returns a version string from Git tags
+#
+# This function inspects the annotated git tags for the project and returns a string
+# into a CMake variable
+#
+# get_git_version(<var>)
+#
+# - Example
+#
+# include(GetGitVersion)
+# get_git_version(GIT_VERSION)
+#
+# Requires CMake 2.8.11+
+find_package(Git)
+
+if(__get_git_version)
+ return()
+endif()
+set(__get_git_version INCLUDED)
+
+function(get_git_version var)
+ if(GIT_EXECUTABLE)
+ execute_process(COMMAND ${GIT_EXECUTABLE} describe --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=8
+ RESULT_VARIABLE status
+ OUTPUT_VARIABLE GIT_VERSION
+ ERROR_QUIET)
+ if(${status})
+ set(GIT_VERSION "v0.0.0")
+ else()
+ string(STRIP ${GIT_VERSION} GIT_VERSION)
+ string(REGEX REPLACE "-[0-9]+-g" "-" GIT_VERSION ${GIT_VERSION})
+ endif()
+
+ # Work out if the repository is dirty
+ execute_process(COMMAND ${GIT_EXECUTABLE} update-index -q --refresh
+ OUTPUT_QUIET
+ ERROR_QUIET)
+ execute_process(COMMAND ${GIT_EXECUTABLE} diff-index --name-only HEAD --
+ OUTPUT_VARIABLE GIT_DIFF_INDEX
+ ERROR_QUIET)
+ string(COMPARE NOTEQUAL "${GIT_DIFF_INDEX}" "" GIT_DIRTY)
+ if (${GIT_DIRTY})
+ set(GIT_VERSION "${GIT_VERSION}-dirty")
+ endif()
+ else()
+ set(GIT_VERSION "v0.0.0")
+ endif()
+
+ message("-- git Version: ${GIT_VERSION}")
+ set(${var} ${GIT_VERSION} PARENT_SCOPE)
+endfunction()
« no previous file with comments | « third_party/google_benchmark/cmake/Config.cmake.in ('k') | third_party/google_benchmark/cmake/gnu_posix_regex.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698