Skip to content

Commit

Permalink
(#22079) prometheus-cpp: add new version 1.2.4, require C++11 only
Browse files Browse the repository at this point in the history
* prometheus: add version 1.2.0

* update 1.2.1

* update 1.2.3

* update 1.2.4

* check C++11 only instead of C++14

* require C++14 only on 1.1.0

* invert condition
  • Loading branch information
toge authored Sep 10, 2024
1 parent abaca04 commit 20d8ac3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
3 changes: 3 additions & 0 deletions recipes/prometheus-cpp/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"1.2.4":
url: "https://github.com/jupp0r/prometheus-cpp/archive/v1.2.4.tar.gz"
sha256: "48dbad454d314b836cc667ec4def93ec4a6e4255fc8387c20cacb3b8b6faee30"
"1.1.0":
url: "https://github.com/jupp0r/prometheus-cpp/archive/v1.1.0.tar.gz"
sha256: "397544fe91e183029120b4eebcfab24ed9ec833d15850aae78fd5db19062d13a"
Expand Down
31 changes: 15 additions & 16 deletions recipes/prometheus-cpp/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from conan.tools.build import check_min_cppstd, valid_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.scm import Version
from conan.tools.microsoft import is_msvc, check_min_vs

import os

Expand Down Expand Up @@ -36,15 +35,19 @@ class PrometheusCppConan(ConanFile):

@property
def _min_cppstd(self):
return 11 if Version(self.version) < "1.1.0" else 14
return "14" if Version(self.version) == "1.1.0" else "11"

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

def export_sources(self):
export_conandata_patches(self)
Expand Down Expand Up @@ -73,18 +76,14 @@ def requirements(self):
def validate(self):
if self.info.settings.compiler.cppstd:
check_min_cppstd(self, self._min_cppstd)
if Version(self.version) < "1.1.0":
return
check_min_vs(self, 191)
if not is_msvc(self):
minimum_version = self._compilers_minimum_version.get(str(self.info.settings.compiler), False)
if minimum_version and Version(self.info.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
)
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."
)

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

def generate(self):
tc = CMakeToolchain(self)
Expand Down
6 changes: 3 additions & 3 deletions recipes/prometheus-cpp/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ find_package(prometheus-cpp CONFIG REQUIRED)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE prometheus-cpp::push prometheus-cpp::pull)
if(${prometheus-cpp_VERSION} VERSION_LESS "1.1.0")
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
else()
if(${prometheus-cpp_VERSION} VERSION_EQUAL "1.1.0")
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)
else()
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
endif()
2 changes: 2 additions & 0 deletions recipes/prometheus-cpp/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"1.2.4":
folder: all
"1.1.0":
folder: all
"1.0.1":
Expand Down

0 comments on commit 20d8ac3

Please sign in to comment.