mirror of
https://github.com/google/benchmark.git
synced 2024-12-01 07:16:07 +00:00
17bc235ab3
* CMake: `get_git_version()`: just use `--dirty` flag of `git describe` * CMake: move version normalization out of `get_git_version()` Mainly, i want `get_git_version()` to return true version, not something sanitized. * JSON reporter: store library version and schema version in `context` * Tools: discard inputs with unexpected `json_schema_version` * Extract version string into `GetBenchmarkVersiom()` --------- Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
37 lines
859 B
CMake
37 lines
859 B
CMake
# - 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 --tags --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=8 --dirty
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
RESULT_VARIABLE status
|
|
OUTPUT_VARIABLE GIT_VERSION
|
|
ERROR_QUIET)
|
|
if(status)
|
|
set(GIT_VERSION "v0.0.0")
|
|
endif()
|
|
else()
|
|
set(GIT_VERSION "v0.0.0")
|
|
endif()
|
|
|
|
set(${var} ${GIT_VERSION} PARENT_SCOPE)
|
|
endfunction()
|