diff --git a/recipes/re2/all/conandata.yml b/recipes/re2/all/conandata.yml index ae373a08facb0..bc9a3a910cce5 100644 --- a/recipes/re2/all/conandata.yml +++ b/recipes/re2/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "20230602": + url: "https://github.com/google/re2/releases/download/2023-06-02/re2-2023-06-02.tar.gz" + sha256: "4ccdd5aafaa1bcc24181e6dd3581c3eee0354734bb9f3cb4306273ffa434b94f" "20230301": url: "https://github.com/google/re2/archive/refs/tags/2023-03-01.tar.gz" sha256: "7a9a4824958586980926a300b4717202485c4b4115ac031822e29aa4ef207e48" diff --git a/recipes/re2/all/conanfile.py b/recipes/re2/all/conanfile.py index c8ad0901b061a..ca615ecb2c5f0 100644 --- a/recipes/re2/all/conanfile.py +++ b/recipes/re2/all/conanfile.py @@ -1,12 +1,13 @@ from conan import ConanFile +from conan.errors import ConanInvalidConfiguration from conan.tools.build import check_min_cppstd -from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout from conan.tools.files import copy, get, rmdir +from conan.tools.scm import Version import os required_conan_version = ">=1.54.0" - class Re2Conan(ConanFile): name = "re2" description = "Fast, safe, thread-friendly regular expression library" @@ -20,15 +21,35 @@ class Re2Conan(ConanFile): options = { "shared": [True, False], "fPIC": [True, False], + "with_icu": [True, False], } default_options = { "shared": False, "fPIC": True, + "with_icu": False, } + @property + def _min_cppstd(self): + return 14 if Version(self.version) >= "20230601" else 11 + + @property + def _compilers_minimum_version(self): + return { + "14": { + "gcc": "6", + "clang": "5", + "apple-clang": "10", + "Visual Studio": "15", + "msvc": "191", + }, + }.get(self._min_cppstd, {}) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if Version(self.version) < "20230201": + del self.options.with_icu def configure(self): if self.options.shared: @@ -37,9 +58,21 @@ def configure(self): def layout(self): cmake_layout(self, src_folder="src") + def requirements(self): + if self.options.get_safe("with_icu"): + self.requires("icu/73.1") + if Version(self.version) >= "20230601": + self.requires("abseil/20230125.3", transitive_headers=True) + def validate(self): if self.settings.compiler.get_safe("cppstd"): - check_min_cppstd(self, 11) + 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." + ) def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) @@ -49,6 +82,9 @@ def generate(self): tc.variables["RE2_BUILD_TESTING"] = False tc.generate() + deps = CMakeDeps(self) + deps.generate() + def build(self): cmake = CMake(self) cmake.configure() diff --git a/recipes/re2/all/test_package/CMakeLists.txt b/recipes/re2/all/test_package/CMakeLists.txt index dee70b6be9bd8..f2cb6370aee9f 100644 --- a/recipes/re2/all/test_package/CMakeLists.txt +++ b/recipes/re2/all/test_package/CMakeLists.txt @@ -5,4 +5,8 @@ find_package(re2 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} PRIVATE re2::re2) -target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) +if (re2_VERSION VERSION_GREATER_EQUAL "20230602") + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) +else() + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) +endif() diff --git a/recipes/re2/config.yml b/recipes/re2/config.yml index ff0398cb71456..6ecf995b443ac 100644 --- a/recipes/re2/config.yml +++ b/recipes/re2/config.yml @@ -1,4 +1,6 @@ versions: + "20230602": + folder: all "20230301": folder: all "20230201":