Skip to content

Commit

Permalink
benchmark: add version 1.9.1 (#26292)
Browse files Browse the repository at this point in the history
* benchmark: add version 1.9.1

* revert auto_shared_fpic

* benchmark: general maintenance

---------

Co-authored-by: Luis Caro Campos <3535649+jcar87@users.noreply.github.com>
  • Loading branch information
toge and jcar87 authored Jan 10, 2025
1 parent cd0b755 commit e23098f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 93 deletions.
34 changes: 4 additions & 30 deletions recipes/benchmark/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
sources:
"1.9.1":
url: "https://github.com/google/benchmark/archive/refs/tags/v1.9.1.tar.gz"
sha256: "32131c08ee31eeff2c8968d7e874f3cb648034377dfc32a4c377fa8796d84981"
# keep 1.9.0, the last release for c++14
"1.9.0":
url: "https://github.com/google/benchmark/archive/refs/tags/v1.9.0.tar.gz"
sha256: "35a77f46cc782b16fac8d3b107fbfbb37dcd645f7c28eee19f3b8e0758b48994"
Expand All @@ -9,33 +13,3 @@ sources:
"1.8.4":
url: "https://github.com/google/benchmark/archive/refs/tags/v1.8.4.tar.gz"
sha256: "3e7059b6b11fb1bbe28e33e02519398ca94c1818874ebed18e504dc6f709be45"
"1.8.3":
url: "https://github.com/google/benchmark/archive/refs/tags/v1.8.3.tar.gz"
sha256: "6bc180a57d23d4d9515519f92b0c83d61b05b5bab188961f36ac7b06b0d9e9ce"
"1.8.2":
url: "https://github.com/google/benchmark/archive/refs/tags/v1.8.2.tar.gz"
sha256: "2aab2980d0376137f969d92848fbb68216abb07633034534fc8c65cc4e7a0e93"
"1.8.1":
url: "https://github.com/google/benchmark/archive/refs/tags/v1.8.1.tar.gz"
sha256: "e9ff65cecfed4f60c893a1e8a1ba94221fad3b27075f2f80f47eb424b0f8c9bd"
"1.8.0":
url: "https://github.com/google/benchmark/archive/refs/tags/v1.8.0.tar.gz"
sha256: "ea2e94c24ddf6594d15c711c06ccd4486434d9cf3eca954e2af8a20c88f9f172"
"1.7.1":
url: "https://github.com/google/benchmark/archive/refs/tags/v1.7.1.tar.gz"
sha256: "6430e4092653380d9dc4ccb45a1e2dc9259d581f4866dc0759713126056bc1d7"
"1.7.0":
url: "https://github.com/google/benchmark/archive/refs/tags/v1.7.0.tar.gz"
sha256: "3aff99169fa8bdee356eaa1f691e835a6e57b1efeadb8a0f9f228531158246ac"
"1.6.2":
url: "https://github.com/google/benchmark/archive/v1.6.2.tar.gz"
sha256: "a9f77e6188c1cd4ebedfa7538bf5176d6acc72ead6f456919e5f464ef2f06158"
"1.6.1":
url: "https://github.com/google/benchmark/archive/v1.6.1.tar.gz"
sha256: "6132883bc8c9b0df5375b16ab520fac1a85dc9e4cf5be59480448ece74b278d4"
"1.6.0":
url: "https://github.com/google/benchmark/archive/v1.6.0.tar.gz"
sha256: "1f71c72ce08d2c1310011ea6436b31e39ccab8c2db94186d26657d41747c85d6"
"1.5.6":
url: "https://github.com/google/benchmark/archive/v1.5.6.tar.gz"
sha256: "789f85b4810d13ff803834ea75999e41b326405d83d6a538baf01499eda96102"
61 changes: 18 additions & 43 deletions recipes/benchmark/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import cross_building, check_min_cppstd
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, rmdir, replace_in_file
from conan.tools.microsoft import is_msvc, check_min_vs
from conan.tools.scm import Version
import os

required_conan_version = ">=1.53.0"
required_conan_version = ">=2.0.0"


class BenchmarkConan(ConanFile):
name = "benchmark"
description = "A microbenchmark support library."
license = "Apache-2.0"
url = "https://github.com/conan-io/conan-center-index/"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/google/benchmark"
topics = ("google", "microbenchmark")

Expand All @@ -37,28 +36,18 @@ class BenchmarkConan(ConanFile):

@property
def _min_cppstd(self):
if Version(self.version) >= "1.9.1":
return 17
if Version(self.version) >= "1.8.5":
return 14
if is_msvc(self):
return 14
return 11

@property
def _compilers_minimum_version(self):
return {
"14": {
"apple-clang": "10",
"clang": "7",
"gcc": "7",
"msvc": "191",
"Visual Studio": "15",
}
}.get(self._min_cppstd, {})

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if self.settings.os != "Linux" or Version(self.version) < "1.5.4":
if self.settings.os != "Linux":
del self.options.enable_libpfm

def configure(self):
Expand All @@ -69,28 +58,26 @@ def layout(self):
cmake_layout(self, src_folder="src")

def validate(self):
if self.settings.compiler.cppstd:
check_min_cppstd(self, self._min_cppstd)
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
)

check_min_cppstd(self, self._min_cppstd)
check_min_vs(self, "190")
if Version(self.version) < "1.7.0" and is_msvc(self) and self.options.shared:
raise ConanInvalidConfiguration(f"{self.ref} doesn't support msvc shared builds")

def requirements(self):
if self.options.get_safe("enable_libpfm"):
self.requires("libpfm4/4.13.0")

def build_requirements(self):
if Version(self.version) >= "1.7.1":
self.tool_requires("cmake/[>=3.16.3 <4]")
self.tool_requires("cmake/[>=3.16.3 <4]")

def _patch_sources(self):
replace_in_file(self,
os.path.join(self.source_folder, "CMakeLists.txt"),
"set(CMAKE_CXX_STANDARD",
"#"
)

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
self._patch_sources()

def generate(self):
tc = CMakeToolchain(self)
Expand All @@ -99,11 +86,8 @@ def generate(self):
tc.variables["BENCHMARK_ENABLE_LTO"] = self.options.enable_lto
tc.variables["BENCHMARK_ENABLE_EXCEPTIONS"] = self.options.enable_exceptions
tc.variables["BENCHMARK_ENABLE_LIBPFM"] = self.options.get_safe("enable_libpfm", False)
if not self.settings.compiler.cppstd:
tc.cache_variables["CMAKE_CXX_STANDARD"] = self._min_cppstd
if Version(self.version) >= "1.6.1":
tc.variables["BENCHMARK_ENABLE_WERROR"] = False
tc.variables["BENCHMARK_FORCE_WERROR"] = False
tc.variables["BENCHMARK_ENABLE_WERROR"] = False
tc.variables["BENCHMARK_FORCE_WERROR"] = False
if self.settings.os != "Windows":
if cross_building(self):
tc.variables["HAVE_STD_REGEX"] = False
Expand All @@ -113,17 +97,8 @@ def generate(self):
else:
tc.variables["BENCHMARK_USE_LIBCXX"] = False
tc.generate()

def _patch_sources(self):
if Version(self.version) > "1.7.0":
replace_in_file(self,
os.path.join(self.source_folder, "CMakeLists.txt"),
"set(CMAKE_CXX_STANDARD",
"#"
)

def build(self):
self._patch_sources()
cmake = CMake(self)
cmake.configure()
cmake.build()
Expand All @@ -142,7 +117,7 @@ def package_info(self):

self.cpp_info.components["_benchmark"].set_property("cmake_target_name", "benchmark::benchmark")
self.cpp_info.components["_benchmark"].libs = ["benchmark"]
if Version(self.version) >= "1.7.0" and not self.options.shared:
if not self.options.shared:
self.cpp_info.components["_benchmark"].defines.append("BENCHMARK_STATIC_DEFINE")
if self.settings.os in ("FreeBSD", "Linux"):
self.cpp_info.components["_benchmark"].system_libs.extend(["pthread", "rt", "m"])
Expand Down
22 changes: 2 additions & 20 deletions recipes/benchmark/config.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,9 @@
versions:
"1.9.1":
folder: all
"1.9.0":
folder: all
"1.8.5":
folder: all
"1.8.4":
folder: all
"1.8.3":
folder: all
"1.8.2":
folder: all
"1.8.1":
folder: all
"1.8.0":
folder: all
"1.7.1":
folder: all
"1.7.0":
folder: all
"1.6.2":
folder: all
"1.6.1":
folder: all
"1.6.0":
folder: all
"1.5.6":
folder: all

0 comments on commit e23098f

Please sign in to comment.