mirror of https://github.com/google/benchmark.git
fix version recorded in releases (#1047)
* cmake: fix handling the case where `git describe` fails * cmake: fix version recorded in releases If downloaded as a tarball release, there will be no info from git to determine the release, so it ends up v0.0.0. If that's the case, we'll now use the release specified in the project() command, which needs to be updated for each new release. * cmake: add `--tags` to `git describe` That way, lightweight tags will also be taken into account, which should never hurt, but it'll help in cases where, for some mysterious reason or other, annotated tags don't make it into a clone. * update releasing.md
This commit is contained in:
parent
a6a738c1cc
commit
a4bcd937b2
|
@ -13,7 +13,7 @@ foreach(p
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
project (benchmark CXX)
|
project (benchmark VERSION 1.5.3 LANGUAGES CXX)
|
||||||
|
|
||||||
option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." ON)
|
option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." ON)
|
||||||
option(BENCHMARK_ENABLE_EXCEPTIONS "Enable the use of exceptions in the benchmark library." ON)
|
option(BENCHMARK_ENABLE_EXCEPTIONS "Enable the use of exceptions in the benchmark library." ON)
|
||||||
|
@ -94,8 +94,14 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||||
include(GetGitVersion)
|
include(GetGitVersion)
|
||||||
get_git_version(GIT_VERSION)
|
get_git_version(GIT_VERSION)
|
||||||
|
|
||||||
|
# If no git version can be determined, use the version
|
||||||
|
# from the project() command
|
||||||
|
if ("${GIT_VERSION}" STREQUAL "0.0.0")
|
||||||
|
set(VERSION "${benchmark_VERSION}")
|
||||||
|
else()
|
||||||
|
set(VERSION "${GIT_VERSION}")
|
||||||
|
endif()
|
||||||
# Tell the user what versions we are using
|
# Tell the user what versions we are using
|
||||||
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION ${GIT_VERSION})
|
|
||||||
message(STATUS "Version: ${VERSION}")
|
message(STATUS "Version: ${VERSION}")
|
||||||
|
|
||||||
# The version of the libraries
|
# The version of the libraries
|
||||||
|
|
|
@ -20,16 +20,20 @@ set(__get_git_version INCLUDED)
|
||||||
|
|
||||||
function(get_git_version var)
|
function(get_git_version var)
|
||||||
if(GIT_EXECUTABLE)
|
if(GIT_EXECUTABLE)
|
||||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=8
|
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=8
|
||||||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
||||||
RESULT_VARIABLE status
|
RESULT_VARIABLE status
|
||||||
OUTPUT_VARIABLE GIT_VERSION
|
OUTPUT_VARIABLE GIT_DESCRIBE_VERSION
|
||||||
ERROR_QUIET)
|
ERROR_QUIET)
|
||||||
if(${status})
|
if(status)
|
||||||
set(GIT_VERSION "v0.0.0")
|
set(GIT_DESCRIBE_VERSION "v0.0.0")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
string(STRIP ${GIT_DESCRIBE_VERSION} GIT_DESCRIBE_VERSION)
|
||||||
|
if(GIT_DESCRIBE_VERSION MATCHES v[^-]*-)
|
||||||
|
string(REGEX REPLACE "v([^-]*)-([0-9]+)-.*" "\\1.\\2" GIT_VERSION ${GIT_DESCRIBE_VERSION})
|
||||||
else()
|
else()
|
||||||
string(STRIP ${GIT_VERSION} GIT_VERSION)
|
string(REGEX REPLACE "v(.*)" "\\1" GIT_VERSION ${GIT_DESCRIBE_VERSION})
|
||||||
string(REGEX REPLACE "-[0-9]+-g" "-" GIT_VERSION ${GIT_VERSION})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Work out if the repository is dirty
|
# Work out if the repository is dirty
|
||||||
|
@ -43,12 +47,12 @@ function(get_git_version var)
|
||||||
ERROR_QUIET)
|
ERROR_QUIET)
|
||||||
string(COMPARE NOTEQUAL "${GIT_DIFF_INDEX}" "" GIT_DIRTY)
|
string(COMPARE NOTEQUAL "${GIT_DIFF_INDEX}" "" GIT_DIRTY)
|
||||||
if (${GIT_DIRTY})
|
if (${GIT_DIRTY})
|
||||||
set(GIT_VERSION "${GIT_VERSION}-dirty")
|
set(GIT_DESCRIBE_VERSION "${GIT_DESCRIBE_VERSION}-dirty")
|
||||||
endif()
|
endif()
|
||||||
|
message(STATUS "git version: ${GIT_DESCRIBE_VERSION} normalized to ${GIT_VERSION}")
|
||||||
else()
|
else()
|
||||||
set(GIT_VERSION "v0.0.0")
|
set(GIT_VERSION "0.0.0")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(STATUS "git Version: ${GIT_VERSION}")
|
|
||||||
set(${var} ${GIT_VERSION} PARENT_SCOPE)
|
set(${var} ${GIT_VERSION} PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
|
@ -8,6 +8,12 @@
|
||||||
* `git log $(git describe --abbrev=0 --tags)..HEAD` gives you the list of
|
* `git log $(git describe --abbrev=0 --tags)..HEAD` gives you the list of
|
||||||
commits between the last annotated tag and HEAD
|
commits between the last annotated tag and HEAD
|
||||||
* Pick the most interesting.
|
* Pick the most interesting.
|
||||||
|
* Create one last commit that updates the version saved in `CMakeLists.txt` to the release version you're creating. (This version will be used if benchmark is installed from the archive you'll be creating in the next step.)
|
||||||
|
|
||||||
|
```
|
||||||
|
project (benchmark VERSION 1.5.3 LANGUAGES CXX)
|
||||||
|
```
|
||||||
|
|
||||||
* Create a release through github's interface
|
* Create a release through github's interface
|
||||||
* Note this will create a lightweight tag.
|
* Note this will create a lightweight tag.
|
||||||
* Update this to an annotated tag:
|
* Update this to an annotated tag:
|
||||||
|
|
Loading…
Reference in New Issue