-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] installed benchmark thinks it's version 0.0.0 #1046
Comments
Well, the question is how you'd prefer to handle it. Here's one suggestion (I can make a PR): If the --- benchmark/CMakeLists.txt 2020-09-22 10:36:09.000000000 -0400
+++ benchmark-1.5.2/CMakeLists.txt 2020-09-24 08:26:10.000000000 -0400
@@ -13,7 +13,7 @@
endif()
endforeach()
-project (benchmark CXX)
+project (benchmark VERSION 1.5.2 LANGUAGES CXX)
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)
@@ -77,12 +77,16 @@
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
-# Read the git tags to determine the project version
-include(GetGitVersion)
-get_git_version(GIT_VERSION)
-
+# If the version hasn't been set in the project() command, read the
+# git tags to determine the project version
+if (NOT benchmark_VERSION)
+ include(GetGitVersion)
+ get_git_version(GIT_VERSION)
+ string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION ${GIT_VERSION})
+else()
+ set(VERSION ${benchmark_VERSION})
+endif()
# Tell the user what versions we are using
-string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION ${GIT_VERSION})
message(STATUS "Version: ${VERSION}")
# The version of the libraries |
This means having the release in a separate branch or doing the release locally each time (to avoid accidentally setting the project). i wonder if the other way round is better: always set the project version to the latest release, and use it iff the git version returns nothing? |
I can do that, too. Though in the end, that will do just the same as not using the version info from git at all (which would be fine with me): At the release, the version will be set to, say, 1.5.3 and will be tagged correspondingly. So the two versions give the same answer. During follow-up development, the cmake release will remain at 1.5.3, and git will return 1.5.3-dirty, which gets simplified into 1.5.3 anyway. So easiest would be to just remove getting the git version in the first place. |
The only benefit will be when i forget to update the version in the depot
but remember the git tag and the development version at least is correct :D
Dominic Hamon | Google
*There are no bad ideas; only good ideas that go horribly wrong
<http://www.poorlydrawnlines.com/comic/ideas-2/>.*
…On Thu, Sep 24, 2020 at 4:19 PM Kai Germaschewski ***@***.***> wrote:
I can do that, too. Though in the end, that will do just the same as not
using the version info from git at all (which would be fine with me):
At the release, the version will be set to, say, 1.5.3 and will be tagged
correspondingly. So the two versions give the same answer. During follow-up
development, the cmake release will remain at 1.5.3, and git will return
1.5.3-dirty, which gets simplified into 1.5.3 anyway. So easiest would be
to just remove getting the git version in the first place.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1046 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAD4QMUUCNHMJPAILYBMESLSHNPR3ANCNFSM4RX2GNYQ>
.
|
Downstream packager specifically use the source release and not the git version. For example debian explicitly patches --- benchmark.orig/CMakeLists.txt
+++ benchmark/CMakeLists.txt
@@ -79,7 +79,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_C
# Read the git tags to determine the project version
include(GetGitVersion)
-get_git_version(GIT_VERSION)
+#get_git_version(GIT_VERSION)
# Tell the user what versions we are using
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" VERSION ${GIT_VERSION})
so that they can pass in the version explicitly #!/usr/bin/make -f
include /usr/share/dpkg/pkg-info.mk
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
%:
dh $@ --buildsystem=cmake
override_dh_auto_configure:
dh_auto_configure -- -DGIT_VERSION="$(DEB_VERSION_UPSTREAM)" \
-DGOOGLETEST_PATH=/usr/src/googletest \
-DCMAKE_BUILD_TYPE=Release -DBENCHMARK_ENABLE_LTO=true https://salsa.debian.org/science-team/benchmark/-/blob/master/debian/rules Another example is arch linux and the reason why I commented here: cmake \
-DCMAKE_BUILD_TYPE=None \
-DCMAKE_CXX_FLAGS="${CXXFLAGS} -DNDEBUG" \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=lib \
-DBUILD_SHARED_LIBS=ON \
-DBENCHMARK_ENABLE_LTO=ON \
-DBENCHMARK_ENABLE_GTEST_TESTS=OFF \
..
make DESTDIR="$pkgdir/" install https://github.com/archlinux/svntogit-community/blob/packages/benchmark/trunk/PKGBUILD They did not patch it and thus created a
If you use the source package (e.g. https://github.com/google/benchmark/archive/v1.5.2.tar.gz) to install benchmark, you aren't able to determine the version of benchmark. I guess for those packagers, they would like to be able to at least pass in a version. The optimum would be if the upstream package would provide the version. On a side note: a |
google/benchmark#1046 has been resolved. Closes #10771 from kou/cpp-conda-remove-workaround-for-benchmark Lead-authored-by: Sutou Kouhei <kou@clear-code.com> Co-authored-by: Antoine Pitrou <antoine@python.org> Signed-off-by: Antoine Pitrou <antoine@python.org>
When downloading a release (e.g., 1.5.2) and building/installing it via cmake, it ends up recording its version as
0.0.0
in its installed cmake config (lib/cmake/benchmark/benchmarkConfigVersion.cmake
):The consequence of this is that unfortunately something like
find_package(benchmark 1.5.2)
will fail, since0.0.0
is considered not compatible.This is caused by benchmark usually automatically getting its version from
git describe
, but that doesn't work when building a tarball.The text was updated successfully, but these errors were encountered: