From 356b87e221befdd0ebc616a018e4ec764cb00c37 Mon Sep 17 00:00:00 2001 From: toge Date: Fri, 17 Feb 2023 23:22:10 +0900 Subject: [PATCH 01/32] protobuf: add version 4.23.1 --- recipes/protobuf/all/conandata.yml | 3 ++ recipes/protobuf/all/conanfile.py | 72 ++++++++++++++++++++++++++---- recipes/protobuf/config.yml | 2 + 3 files changed, 68 insertions(+), 9 deletions(-) diff --git a/recipes/protobuf/all/conandata.yml b/recipes/protobuf/all/conandata.yml index 0417c4d805f42..c054da1b9504c 100644 --- a/recipes/protobuf/all/conandata.yml +++ b/recipes/protobuf/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "4.23.1": + url: "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v4.23.1.tar.gz" + sha256: "12ba4ad04e6de473d4c216da9964c7d65f41660d57185017dcf551e1be8b6180" "3.21.12": url: "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.21.12.tar.gz" sha256: "930c2c3b5ecc6c9c12615cf5ad93f1cd6e12d0aba862b572e076259970ac3a53" diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index f696a27880684..fd3792db0595d 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -2,6 +2,7 @@ from conan.errors import ConanInvalidConfiguration from conan.tools.apple import is_apple_os from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.build import check_min_cppstd from conan.tools.files import copy, rename, get, apply_conandata_patches, export_conandata_patches, replace_in_file, rmdir, rm from conan.tools.microsoft import check_min_vs, msvc_runtime_flag, is_msvc, is_msvc_static_runtime from conan.tools.scm import Version @@ -48,6 +49,26 @@ def _is_clang_cl(self): def _is_clang_x86(self): return self.settings.compiler == "clang" and self.settings.arch == "x86" + @property + def _can_disable_rtti(self): + return Version(self.version) >= "3.15.4" + + @property + def _min_cppstd(self): + return 11 if Version(self.version) < "4.22.0" else 14 + + @property + def _compilers_minimum_version(self): + return { + "14": { + "gcc": "8", + "clang": "5", + "apple-clang": "10", + "Visual Studio": "15", + "msvc": "191", + }, + }.get(self._min_cppstd, {}) + def export_sources(self): export_conandata_patches(self) @@ -65,16 +86,26 @@ def layout(self): def requirements(self): if self.options.with_zlib: self.requires("zlib/[>=1.2.11 <2]") + if Version(self.version) >= "4.22.0": + self.requires("abseil/20230125.3", transitive_headers=True) 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." + ) + if self.options.shared and is_msvc_static_runtime(self): raise ConanInvalidConfiguration("Protobuf can't be built with shared + MT(d) runtimes") - check_min_vs(self, "190") - - if self.settings.compiler == "clang": - if Version(self.settings.compiler.version) < "4": - raise ConanInvalidConfiguration(f"{self.ref} doesn't support clang < 4") + if Version(self.version) < "4.22.0": + check_min_vs(self, "190") + if self.settings.compiler == "clang": + if Version(self.settings.compiler.version) < "4": + raise ConanInvalidConfiguration(f"{self.ref} doesn't support clang < 4") def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) @@ -101,6 +132,9 @@ def generate(self): if is_apple_os(self) and self.options.shared: # Workaround against SIP on macOS for consumers while invoking protoc when protobuf lib is shared tc.variables["CMAKE_INSTALL_RPATH"] = "@loader_path/../lib" + if Version(self.version) >= "4.22.0": + tc.variables["protobuf_ABSL_PROVIDER"] = "package" + tc.variables["CMAKE_CXX_STANDARD"] = 14 tc.generate() deps = CMakeDeps(self) @@ -191,15 +225,23 @@ def package(self): cmake.install() rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-config-version.cmake")) - os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-targets.cmake")) - os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-targets-{}.cmake".format(str(self.settings.build_type).lower()))) - rename(self, os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-config.cmake"), - os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-generate.cmake")) + if Version(self.version) < "4.22.0": + os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-targets.cmake")) + os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-targets-{}.cmake".format(str(self.settings.build_type).lower()))) + rename(self, os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-config.cmake"), + os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-generate.cmake")) + else: + # TODO: diary hack, need to fix + rename(self, os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-config.cmake"), + os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-protoc.cmake")) if not self.options.lite: rm(self, "libprotobuf-lite*", os.path.join(self.package_folder, "lib")) rm(self, "libprotobuf-lite*", os.path.join(self.package_folder, "bin")) + if Version(self.version) >= "4.22.0": + rmdir(self, os.path.join(self.package_folder, "lib", "cmake", "utf8_range")) + def package_info(self): self.cpp_info.set_property("cmake_find_mode", "both") self.cpp_info.set_property("cmake_module_file_name", "Protobuf") @@ -211,11 +253,21 @@ def package_info(self): os.path.join(self._cmake_install_base_path, "protobuf-module.cmake"), os.path.join(self._cmake_install_base_path, "protobuf-options.cmake"), ] + if Version(self.version) >= "4.22.0": + build_modules.append(os.path.join(self._cmake_install_base_path, "protobuf-protoc.cmake")) self.cpp_info.set_property("cmake_build_modules", build_modules) lib_prefix = "lib" if (is_msvc(self) or self._is_clang_cl) else "" lib_suffix = "d" if self.settings.build_type == "Debug" and self.options.debug_suffix else "" + if Version(self.version) >= "4.22.0": + # utf8_range + self.cpp_info.components["utf8_range"].set_property("cmake_target_name", "protobuf::utf8_range") + self.cpp_info.components["utf8_range"].libs = [lib_prefix + "utf8_range"] + # utf8_validity + self.cpp_info.components["utf8_validity"].set_property("cmake_target_name", "protobuf::utf8_validity") + self.cpp_info.components["utf8_validity"].libs = [lib_prefix + "utf8_validity"] + # libprotobuf self.cpp_info.components["libprotobuf"].set_property("cmake_target_name", "protobuf::libprotobuf") self.cpp_info.components["libprotobuf"].set_property("pkg_config_name", "protobuf") @@ -223,6 +275,8 @@ def package_info(self): self.cpp_info.components["libprotobuf"].libs = [lib_prefix + "protobuf" + lib_suffix] if self.options.with_zlib: self.cpp_info.components["libprotobuf"].requires = ["zlib::zlib"] + if Version(self.version) >= "4.22.0": + self.cpp_info.components["libprotobuf"].requires.extend(["abseil::abseil", "utf8_range", "utf8_validity"]) if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["libprotobuf"].system_libs.extend(["m", "pthread"]) if self._is_clang_x86 or "arm" in str(self.settings.arch): diff --git a/recipes/protobuf/config.yml b/recipes/protobuf/config.yml index 89750d93410cc..aaa56d0c8fa85 100644 --- a/recipes/protobuf/config.yml +++ b/recipes/protobuf/config.yml @@ -1,4 +1,6 @@ versions: + "4.23.1": + folder: all "3.21.12": folder: all "3.21.9": From fa4981b381e20a6412724b897185da131f065ccd Mon Sep 17 00:00:00 2001 From: toge Date: Tue, 23 May 2023 14:42:11 +0900 Subject: [PATCH 02/32] cast string --- recipes/protobuf/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index fd3792db0595d..aad9e5d8b2ed7 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -67,7 +67,7 @@ def _compilers_minimum_version(self): "Visual Studio": "15", "msvc": "191", }, - }.get(self._min_cppstd, {}) + }.get(str(self._min_cppstd), {}) def export_sources(self): export_conandata_patches(self) From 4df762ca45cc1c10785df88b03b0665d460b263b Mon Sep 17 00:00:00 2001 From: toge Date: Tue, 23 May 2023 18:42:20 +0900 Subject: [PATCH 03/32] enable C++14 on protobuf>=4.20.0 --- recipes/protobuf/all/test_package/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/recipes/protobuf/all/test_package/CMakeLists.txt b/recipes/protobuf/all/test_package/CMakeLists.txt index a5240f3215abb..b67320a18c7d2 100644 --- a/recipes/protobuf/all/test_package/CMakeLists.txt +++ b/recipes/protobuf/all/test_package/CMakeLists.txt @@ -5,7 +5,13 @@ project(test_package LANGUAGES CXX) find_package(protobuf CONFIG REQUIRED) add_executable(${PROJECT_NAME} test_package.cpp addressbook.proto) -target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) + +if (protobuf_VERSION VERSION_LESS "4.20.0") + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) +else() + target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) +endif() + target_include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") if (protobuf_LITE) target_link_libraries(${PROJECT_NAME} PRIVATE protobuf::libprotobuf-lite) From 06af570f0d744112f346a966c96fd956feb80355 Mon Sep 17 00:00:00 2001 From: toge Date: Wed, 24 May 2023 09:38:58 +0900 Subject: [PATCH 04/32] make abseil shared when protobuf is shared --- recipes/protobuf/all/conanfile.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index aad9e5d8b2ed7..2718089299d4e 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -79,6 +79,9 @@ def config_options(self): def configure(self): if self.options.shared: self.options.rm_safe("fPIC") + # shared build protobuf requires Abseil as shared libraries to avoid ODR violations. + if Version(self.version) >= "4.22.0": + self.options["abseil"].shared = True def layout(self): cmake_layout(self, src_folder="src") From 3a259e0a0d2f1cf86d860e1680c2af1865783dbb Mon Sep 17 00:00:00 2001 From: toge Date: Wed, 24 May 2023 18:33:41 +0900 Subject: [PATCH 05/32] build abseil shared only on msvc --- recipes/protobuf/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 2718089299d4e..f299218c0b7a0 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -80,7 +80,7 @@ def configure(self): if self.options.shared: self.options.rm_safe("fPIC") # shared build protobuf requires Abseil as shared libraries to avoid ODR violations. - if Version(self.version) >= "4.22.0": + if Version(self.version) >= "4.22.0" and is_msvc(self): self.options["abseil"].shared = True def layout(self): From 04e73d7f869329f82f7559a01352e89b5f68fe79 Mon Sep 17 00:00:00 2001 From: toge Date: Thu, 25 May 2023 03:12:00 +0900 Subject: [PATCH 06/32] add utf8_lib_prefix --- recipes/protobuf/all/conanfile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index f299218c0b7a0..593f96d60f709 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -264,12 +264,13 @@ def package_info(self): lib_suffix = "d" if self.settings.build_type == "Debug" and self.options.debug_suffix else "" if Version(self.version) >= "4.22.0": + utf8_lib_prefix = "lib" if self._is_clang_cl else "" # utf8_range self.cpp_info.components["utf8_range"].set_property("cmake_target_name", "protobuf::utf8_range") - self.cpp_info.components["utf8_range"].libs = [lib_prefix + "utf8_range"] + self.cpp_info.components["utf8_range"].libs = [utf8_lib_prefix + "utf8_range"] # utf8_validity self.cpp_info.components["utf8_validity"].set_property("cmake_target_name", "protobuf::utf8_validity") - self.cpp_info.components["utf8_validity"].libs = [lib_prefix + "utf8_validity"] + self.cpp_info.components["utf8_validity"].libs = [utf8_lib_prefix + "utf8_validity"] # libprotobuf self.cpp_info.components["libprotobuf"].set_property("cmake_target_name", "protobuf::libprotobuf") From 430c798e283c32a0eaf05d07d93e280bc07dca69 Mon Sep 17 00:00:00 2001 From: toge Date: Thu, 25 May 2023 19:21:31 +0900 Subject: [PATCH 07/32] apply miklelappo's comment --- recipes/protobuf/all/conanfile.py | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 593f96d60f709..f132d8efdf9eb 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -61,7 +61,7 @@ def _min_cppstd(self): def _compilers_minimum_version(self): return { "14": { - "gcc": "8", + "gcc": "7.3", "clang": "5", "apple-clang": "10", "Visual Studio": "15", @@ -95,14 +95,20 @@ def requirements(self): def validate(self): if self.settings.compiler.cppstd: check_min_cppstd(self, self._min_cppstd) + def loose_lt_semver(v1, v2): + lv1 = [int(v) for v in v1.split(".")] + lv2 = [int(v) for v in v2.split(".")] + min_length = min(len(lv1), len(lv2)) + return lv1[:min_length] < lv2[:min_length] + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) - if minimum_version and Version(self.settings.compiler.version) < minimum_version: + if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version): raise ConanInvalidConfiguration( - f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support.", ) if self.options.shared and is_msvc_static_runtime(self): - raise ConanInvalidConfiguration("Protobuf can't be built with shared + MT(d) runtimes") + raise ConanInvalidConfiguration(f"{self.ref} can't be built with shared + MT(d) runtimes") if Version(self.version) < "4.22.0": check_min_vs(self, "190") @@ -137,7 +143,7 @@ def generate(self): tc.variables["CMAKE_INSTALL_RPATH"] = "@loader_path/../lib" if Version(self.version) >= "4.22.0": tc.variables["protobuf_ABSL_PROVIDER"] = "package" - tc.variables["CMAKE_CXX_STANDARD"] = 14 + tc.variables["CMAKE_CXX_STANDARD"] = self._min_cppstd tc.generate() deps = CMakeDeps(self) @@ -228,15 +234,8 @@ def package(self): cmake.install() rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-config-version.cmake")) - if Version(self.version) < "4.22.0": - os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-targets.cmake")) - os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-targets-{}.cmake".format(str(self.settings.build_type).lower()))) - rename(self, os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-config.cmake"), - os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-generate.cmake")) - else: - # TODO: diary hack, need to fix - rename(self, os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-config.cmake"), - os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-protoc.cmake")) + os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-targets.cmake")) + os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, f"protobuf-targets-{str(self.settings.build_type).lower()}.cmake")) if not self.options.lite: rm(self, "libprotobuf-lite*", os.path.join(self.package_folder, "lib")) @@ -252,12 +251,10 @@ def package_info(self): self.cpp_info.set_property("pkg_config_name", "protobuf_full_package") # unofficial, but required to avoid side effects (libprotobuf component "steals" the default global pkg_config name) build_modules = [ - os.path.join(self._cmake_install_base_path, "protobuf-generate.cmake"), os.path.join(self._cmake_install_base_path, "protobuf-module.cmake"), os.path.join(self._cmake_install_base_path, "protobuf-options.cmake"), + os.path.join(self._cmake_install_base_path, "protobuf-config.cmake"), ] - if Version(self.version) >= "4.22.0": - build_modules.append(os.path.join(self._cmake_install_base_path, "protobuf-protoc.cmake")) self.cpp_info.set_property("cmake_build_modules", build_modules) lib_prefix = "lib" if (is_msvc(self) or self._is_clang_cl) else "" From 471d84e8be2a5655202d7a8767957e00b30d16b7 Mon Sep 17 00:00:00 2001 From: toge Date: Fri, 26 May 2023 01:45:17 +0900 Subject: [PATCH 08/32] revert protobuf-protoc.cmake (xxx-config.cmake is not permitted) --- recipes/protobuf/all/conanfile.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index f132d8efdf9eb..1f95594d81f6c 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -234,8 +234,15 @@ def package(self): cmake.install() rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-config-version.cmake")) - os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-targets.cmake")) os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, f"protobuf-targets-{str(self.settings.build_type).lower()}.cmake")) + os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-targets.cmake")) + if Version(self.version) < "4.22.0": + rename(self, os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-config.cmake"), + os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-generate.cmake")) + else: + # TODO: dirty hack, need to fix + rename(self, os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-config.cmake"), + os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-protoc.cmake")) if not self.options.lite: rm(self, "libprotobuf-lite*", os.path.join(self.package_folder, "lib")) @@ -251,10 +258,12 @@ def package_info(self): self.cpp_info.set_property("pkg_config_name", "protobuf_full_package") # unofficial, but required to avoid side effects (libprotobuf component "steals" the default global pkg_config name) build_modules = [ + os.path.join(self._cmake_install_base_path, "protobuf-generate.cmake"), os.path.join(self._cmake_install_base_path, "protobuf-module.cmake"), os.path.join(self._cmake_install_base_path, "protobuf-options.cmake"), - os.path.join(self._cmake_install_base_path, "protobuf-config.cmake"), ] + if Version(self.version) >= "4.22.0": + build_modules.append(os.path.join(self._cmake_install_base_path, "protobuf-protoc.cmake")) self.cpp_info.set_property("cmake_build_modules", build_modules) lib_prefix = "lib" if (is_msvc(self) or self._is_clang_cl) else "" From 944fd2cdd9835af76abbca3cca7ce5b31e04ca94 Mon Sep 17 00:00:00 2001 From: toge Date: Sat, 27 May 2023 02:29:49 +0900 Subject: [PATCH 09/32] fix validation --- recipes/protobuf/all/conanfile.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 1f95594d81f6c..8981191f6ab77 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -95,14 +95,9 @@ def requirements(self): def validate(self): if self.settings.compiler.cppstd: check_min_cppstd(self, self._min_cppstd) - def loose_lt_semver(v1, v2): - lv1 = [int(v) for v in v1.split(".")] - lv2 = [int(v) for v in v2.split(".")] - min_length = min(len(lv1), len(lv2)) - return lv1[:min_length] < lv2[:min_length] minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) - if minimum_version and loose_lt_semver(str(self.settings.compiler.version), minimum_version): + 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.", ) From 7bb3e3f9aa4139ca9c78273ea44d0d114c9dc81c Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 5 Dec 2023 18:25:42 +0200 Subject: [PATCH 10/32] protobuf: bump version to v3.25.1 --- recipes/protobuf/all/conandata.yml | 6 +-- recipes/protobuf/all/conanfile.py | 61 +++++++++++++++--------------- recipes/protobuf/config.yml | 2 +- 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/recipes/protobuf/all/conandata.yml b/recipes/protobuf/all/conandata.yml index c054da1b9504c..aaf9687d31ab4 100644 --- a/recipes/protobuf/all/conandata.yml +++ b/recipes/protobuf/all/conandata.yml @@ -1,7 +1,7 @@ sources: - "4.23.1": - url: "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v4.23.1.tar.gz" - sha256: "12ba4ad04e6de473d4c216da9964c7d65f41660d57185017dcf551e1be8b6180" + "3.25.1": + url: "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.25.1.tar.gz" + sha256: "1a2affa2fbad568b9895b72e3c7cb1f72a14bf2501fba056c724dc68c249cd0f" "3.21.12": url: "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.21.12.tar.gz" sha256: "930c2c3b5ecc6c9c12615cf5ad93f1cd6e12d0aba862b572e076259970ac3a53" diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 8981191f6ab77..6ce7c7e840ee1 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -2,9 +2,9 @@ from conan.errors import ConanInvalidConfiguration from conan.tools.apple import is_apple_os from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout -from conan.tools.build import check_min_cppstd +from conan.tools.build import check_min_cppstd, valid_min_cppstd from conan.tools.files import copy, rename, get, apply_conandata_patches, export_conandata_patches, replace_in_file, rmdir, rm -from conan.tools.microsoft import check_min_vs, msvc_runtime_flag, is_msvc, is_msvc_static_runtime +from conan.tools.microsoft import msvc_runtime_flag, is_msvc, is_msvc_static_runtime from conan.tools.scm import Version import os @@ -49,25 +49,25 @@ def _is_clang_cl(self): def _is_clang_x86(self): return self.settings.compiler == "clang" and self.settings.arch == "x86" - @property - def _can_disable_rtti(self): - return Version(self.version) >= "3.15.4" - @property def _min_cppstd(self): - return 11 if Version(self.version) < "4.22.0" else 14 + return 11 if Version(self.version) < "3.22.0" else 14 @property def _compilers_minimum_version(self): - return { - "14": { + if self._min_cppstd == 14: + return { "gcc": "7.3", "clang": "5", "apple-clang": "10", "Visual Studio": "15", "msvc": "191", - }, - }.get(str(self._min_cppstd), {}) + } + return { + "clang": "4", + "Visual Studio": "14", + "msvc": "190", + } def export_sources(self): export_conandata_patches(self) @@ -80,7 +80,7 @@ def configure(self): if self.options.shared: self.options.rm_safe("fPIC") # shared build protobuf requires Abseil as shared libraries to avoid ODR violations. - if Version(self.version) >= "4.22.0" and is_msvc(self): + if Version(self.version) >= "3.22.0" and is_msvc(self): self.options["abseil"].shared = True def layout(self): @@ -89,8 +89,8 @@ def layout(self): def requirements(self): if self.options.with_zlib: self.requires("zlib/[>=1.2.11 <2]") - if Version(self.version) >= "4.22.0": - self.requires("abseil/20230125.3", transitive_headers=True) + if Version(self.version) >= "3.22.0": + self.requires("abseil/20230802.1", transitive_headers=True) def validate(self): if self.settings.compiler.cppstd: @@ -105,12 +105,6 @@ def validate(self): if self.options.shared and is_msvc_static_runtime(self): raise ConanInvalidConfiguration(f"{self.ref} can't be built with shared + MT(d) runtimes") - if Version(self.version) < "4.22.0": - check_min_vs(self, "190") - if self.settings.compiler == "clang": - if Version(self.settings.compiler.version) < "4": - raise ConanInvalidConfiguration(f"{self.ref} doesn't support clang < 4") - def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) @@ -136,9 +130,9 @@ def generate(self): if is_apple_os(self) and self.options.shared: # Workaround against SIP on macOS for consumers while invoking protoc when protobuf lib is shared tc.variables["CMAKE_INSTALL_RPATH"] = "@loader_path/../lib" - if Version(self.version) >= "4.22.0": - tc.variables["protobuf_ABSL_PROVIDER"] = "package" - tc.variables["CMAKE_CXX_STANDARD"] = self._min_cppstd + tc.variables["protobuf_ABSL_PROVIDER"] = "package" + if not valid_min_cppstd(self, self._min_cppstd): + tc.variables["CMAKE_CXX_STANDARD"] = self._min_cppstd tc.generate() deps = CMakeDeps(self) @@ -161,7 +155,7 @@ def _patch_sources(self): exe_ext = ".exe" if self.settings.os == "Windows" else "" protoc_filename = "protoc" + exe_ext module_folder_depth = len(os.path.normpath(self._cmake_install_base_path).split(os.path.sep)) - protoc_rel_path = "{}bin/{}".format("".join(["../"] * module_folder_depth), protoc_filename) + protoc_rel_path = "{}bin/{}".format("../" * module_folder_depth, protoc_filename) protoc_target = textwrap.dedent(f"""\ if(NOT TARGET protobuf::protoc) # Locate protoc executable @@ -231,7 +225,7 @@ def package(self): os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-config-version.cmake")) os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, f"protobuf-targets-{str(self.settings.build_type).lower()}.cmake")) os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-targets.cmake")) - if Version(self.version) < "4.22.0": + if Version(self.version) < "3.22.0": rename(self, os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-config.cmake"), os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-generate.cmake")) else: @@ -243,7 +237,7 @@ def package(self): rm(self, "libprotobuf-lite*", os.path.join(self.package_folder, "lib")) rm(self, "libprotobuf-lite*", os.path.join(self.package_folder, "bin")) - if Version(self.version) >= "4.22.0": + if Version(self.version) >= "3.22.0": rmdir(self, os.path.join(self.package_folder, "lib", "cmake", "utf8_range")) def package_info(self): @@ -257,14 +251,14 @@ def package_info(self): os.path.join(self._cmake_install_base_path, "protobuf-module.cmake"), os.path.join(self._cmake_install_base_path, "protobuf-options.cmake"), ] - if Version(self.version) >= "4.22.0": + if Version(self.version) >= "3.22.0": build_modules.append(os.path.join(self._cmake_install_base_path, "protobuf-protoc.cmake")) self.cpp_info.set_property("cmake_build_modules", build_modules) lib_prefix = "lib" if (is_msvc(self) or self._is_clang_cl) else "" lib_suffix = "d" if self.settings.build_type == "Debug" and self.options.debug_suffix else "" - if Version(self.version) >= "4.22.0": + if Version(self.version) >= "3.22.0": utf8_lib_prefix = "lib" if self._is_clang_cl else "" # utf8_range self.cpp_info.components["utf8_range"].set_property("cmake_target_name", "protobuf::utf8_range") @@ -274,14 +268,15 @@ def package_info(self): self.cpp_info.components["utf8_validity"].libs = [utf8_lib_prefix + "utf8_validity"] # libprotobuf + # https://github.com/protocolbuffers/protobuf/blob/v25.1/cmake/libprotobuf.cmake self.cpp_info.components["libprotobuf"].set_property("cmake_target_name", "protobuf::libprotobuf") self.cpp_info.components["libprotobuf"].set_property("pkg_config_name", "protobuf") self.cpp_info.components["libprotobuf"].builddirs.append(self._cmake_install_base_path) self.cpp_info.components["libprotobuf"].libs = [lib_prefix + "protobuf" + lib_suffix] if self.options.with_zlib: - self.cpp_info.components["libprotobuf"].requires = ["zlib::zlib"] - if Version(self.version) >= "4.22.0": - self.cpp_info.components["libprotobuf"].requires.extend(["abseil::abseil", "utf8_range", "utf8_validity"]) + self.cpp_info.components["libprotobuf"].requires += ["zlib::zlib"] + if Version(self.version) >= "3.22.0": + self.cpp_info.components["libprotobuf"].requires += ["abseil::abseil", "utf8_range", "utf8_validity"] if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["libprotobuf"].system_libs.extend(["m", "pthread"]) if self._is_clang_x86 or "arm" in str(self.settings.arch): @@ -293,17 +288,21 @@ def package_info(self): self.cpp_info.components["libprotobuf"].defines = ["PROTOBUF_USE_DLLS"] # libprotoc + # https://github.com/protocolbuffers/protobuf/blob/v25.1/cmake/libprotobuc.cmake if self.settings.os != "tvOS": self.cpp_info.components["libprotoc"].set_property("cmake_target_name", "protobuf::libprotoc") self.cpp_info.components["libprotoc"].libs = [lib_prefix + "protoc" + lib_suffix] self.cpp_info.components["libprotoc"].requires = ["libprotobuf"] # libprotobuf-lite + # https://github.com/protocolbuffers/protobuf/blob/v25.1/cmake/libprotobuf-lite.cmake if self.options.lite: self.cpp_info.components["libprotobuf-lite"].set_property("cmake_target_name", "protobuf::libprotobuf-lite") self.cpp_info.components["libprotobuf-lite"].set_property("pkg_config_name", "protobuf-lite") self.cpp_info.components["libprotobuf-lite"].builddirs.append(self._cmake_install_base_path) self.cpp_info.components["libprotobuf-lite"].libs = [lib_prefix + "protobuf-lite" + lib_suffix] + if Version(self.version) >= "3.22.0": + self.cpp_info.components["libprotobuf-lite"].requires += ["abseil::abseil", "utf8_range", "utf8_validity"] if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["libprotobuf-lite"].system_libs.extend(["m", "pthread"]) if self._is_clang_x86 or "arm" in str(self.settings.arch): diff --git a/recipes/protobuf/config.yml b/recipes/protobuf/config.yml index aaa56d0c8fa85..84e58d772052f 100644 --- a/recipes/protobuf/config.yml +++ b/recipes/protobuf/config.yml @@ -1,5 +1,5 @@ versions: - "4.23.1": + "3.25.1": folder: all "3.21.12": folder: all From a0ba6ea9a458f9f3350ede02c2823de9d7c58db1 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 5 Dec 2023 19:04:07 +0200 Subject: [PATCH 11/32] protobuf: add check for shared abseil --- recipes/protobuf/all/conanfile.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 6ce7c7e840ee1..88ec73831804c 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -79,7 +79,6 @@ def config_options(self): def configure(self): if self.options.shared: self.options.rm_safe("fPIC") - # shared build protobuf requires Abseil as shared libraries to avoid ODR violations. if Version(self.version) >= "3.22.0" and is_msvc(self): self.options["abseil"].shared = True @@ -95,15 +94,17 @@ def requirements(self): 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.", ) - if self.options.shared and is_msvc_static_runtime(self): - raise ConanInvalidConfiguration(f"{self.ref} can't be built with shared + MT(d) runtimes") + if self.options.shared and is_msvc(self): + if is_msvc_static_runtime(self): + raise ConanInvalidConfiguration(f"{self.ref} can't be built with shared + MT(d) runtimes") + if Version(self.version) >= "3.22.0" and not self.dependencies["abseil"].options.shared: + raise ConanInvalidConfiguration(f"Shared build of protobuf requires shared Abseil on MSVC to avoid ODR violations.") def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) From 1a253a3656daa80873e41576ea0334f54d7f1a83 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 17 Jan 2024 14:16:18 +0200 Subject: [PATCH 12/32] protobuf: bump version to v3.25.2 --- recipes/protobuf/all/conandata.yml | 6 +++--- recipes/protobuf/config.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes/protobuf/all/conandata.yml b/recipes/protobuf/all/conandata.yml index aaf9687d31ab4..8f43771a8188e 100644 --- a/recipes/protobuf/all/conandata.yml +++ b/recipes/protobuf/all/conandata.yml @@ -1,7 +1,7 @@ sources: - "3.25.1": - url: "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.25.1.tar.gz" - sha256: "1a2affa2fbad568b9895b72e3c7cb1f72a14bf2501fba056c724dc68c249cd0f" + "3.25.2": + url: "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.25.2.tar.gz" + sha256: "3c83e4301b968d0b4f29a0c29c0b3cde1da81d790ffd344b111c523ba1954392" "3.21.12": url: "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.21.12.tar.gz" sha256: "930c2c3b5ecc6c9c12615cf5ad93f1cd6e12d0aba862b572e076259970ac3a53" diff --git a/recipes/protobuf/config.yml b/recipes/protobuf/config.yml index 84e58d772052f..4c4677ea158dc 100644 --- a/recipes/protobuf/config.yml +++ b/recipes/protobuf/config.yml @@ -1,5 +1,5 @@ versions: - "3.25.1": + "3.25.2": folder: all "3.21.12": folder: all From b0e6e095c2f1279a30cd3b74969fb3f456ac14f8 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 17 Jan 2024 14:19:20 +0200 Subject: [PATCH 13/32] protobuf: use is_msvc_static_runtime() --- recipes/protobuf/all/conanfile.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 88ec73831804c..b5c6c69838cdc 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -4,7 +4,7 @@ from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.build import check_min_cppstd, valid_min_cppstd from conan.tools.files import copy, rename, get, apply_conandata_patches, export_conandata_patches, replace_in_file, rmdir, rm -from conan.tools.microsoft import msvc_runtime_flag, is_msvc, is_msvc_static_runtime +from conan.tools.microsoft import is_msvc, is_msvc_static_runtime from conan.tools.scm import Version import os @@ -124,10 +124,7 @@ def generate(self): tc.cache_variables["protobuf_BUILD_LIBPROTOC"] = self.settings.os != "tvOS" tc.cache_variables["protobuf_DISABLE_RTTI"] = not self.options.with_rtti if is_msvc(self) or self._is_clang_cl: - runtime = msvc_runtime_flag(self) - if not runtime: - runtime = self.settings.get_safe("compiler.runtime") - tc.cache_variables["protobuf_MSVC_STATIC_RUNTIME"] = "MT" in runtime + tc.cache_variables["protobuf_MSVC_STATIC_RUNTIME"] = is_msvc_static_runtime(self) if is_apple_os(self) and self.options.shared: # Workaround against SIP on macOS for consumers while invoking protoc when protobuf lib is shared tc.variables["CMAKE_INSTALL_RPATH"] = "@loader_path/../lib" From d8dbd1b627a0eb4e136119e533d416f6446bfbf4 Mon Sep 17 00:00:00 2001 From: Ahajha Date: Sat, 9 Mar 2024 01:13:45 -0500 Subject: [PATCH 14/32] Bump patch version and correctly bump major version --- recipes/protobuf/all/conandata.yml | 6 +++--- recipes/protobuf/all/test_package/CMakeLists.txt | 2 +- recipes/protobuf/config.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/recipes/protobuf/all/conandata.yml b/recipes/protobuf/all/conandata.yml index 8f43771a8188e..729466107d329 100644 --- a/recipes/protobuf/all/conandata.yml +++ b/recipes/protobuf/all/conandata.yml @@ -1,7 +1,7 @@ sources: - "3.25.2": - url: "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.25.2.tar.gz" - sha256: "3c83e4301b968d0b4f29a0c29c0b3cde1da81d790ffd344b111c523ba1954392" + "4.25.3": + url: "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v4.25.3.tar.gz" + sha256: "1d6b8d9114cb5b33ce8711729893097a107d4fefff5423528eb1decb5451856c" "3.21.12": url: "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.21.12.tar.gz" sha256: "930c2c3b5ecc6c9c12615cf5ad93f1cd6e12d0aba862b572e076259970ac3a53" diff --git a/recipes/protobuf/all/test_package/CMakeLists.txt b/recipes/protobuf/all/test_package/CMakeLists.txt index b67320a18c7d2..78297d6a21111 100644 --- a/recipes/protobuf/all/test_package/CMakeLists.txt +++ b/recipes/protobuf/all/test_package/CMakeLists.txt @@ -6,7 +6,7 @@ find_package(protobuf CONFIG REQUIRED) add_executable(${PROJECT_NAME} test_package.cpp addressbook.proto) -if (protobuf_VERSION VERSION_LESS "4.20.0") +if (protobuf_VERSION VERSION_LESS "3.22.0") target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) else() target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/protobuf/config.yml b/recipes/protobuf/config.yml index 4c4677ea158dc..4e630566490da 100644 --- a/recipes/protobuf/config.yml +++ b/recipes/protobuf/config.yml @@ -1,5 +1,5 @@ versions: - "3.25.2": + "4.25.3": folder: all "3.21.12": folder: all From 6e4fa05efe18af983ec7a3cea060774d43d08248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Rinc=C3=B3n=20Blanco?= Date: Thu, 14 Mar 2024 10:19:14 +0100 Subject: [PATCH 15/32] Test --- recipes/protobuf/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index b5c6c69838cdc..4d5b8bc5d0ed1 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -10,7 +10,7 @@ import os import textwrap -required_conan_version = ">=1.53" +required_conan_version = ">=1.53.0" class ProtobufConan(ConanFile): From eaafddb961c793443e04074cedaea9cd4a640cc8 Mon Sep 17 00:00:00 2001 From: Ahajha Date: Fri, 15 Mar 2024 12:37:24 -0400 Subject: [PATCH 16/32] Add 5.26.0 --- recipes/protobuf/all/conandata.yml | 3 +++ recipes/protobuf/config.yml | 2 ++ 2 files changed, 5 insertions(+) diff --git a/recipes/protobuf/all/conandata.yml b/recipes/protobuf/all/conandata.yml index 729466107d329..1eb91ed277326 100644 --- a/recipes/protobuf/all/conandata.yml +++ b/recipes/protobuf/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "5.26.0": + url: "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v5.26.0.tar.gz" + sha256: "c3acedccecd385affbd0a32fbbc7e0c7af427d156789726cc27c8a54649e6926" "4.25.3": url: "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v4.25.3.tar.gz" sha256: "1d6b8d9114cb5b33ce8711729893097a107d4fefff5423528eb1decb5451856c" diff --git a/recipes/protobuf/config.yml b/recipes/protobuf/config.yml index 4e630566490da..a55e3244f5435 100644 --- a/recipes/protobuf/config.yml +++ b/recipes/protobuf/config.yml @@ -1,4 +1,6 @@ versions: + "5.26.0": + folder: all "4.25.3": folder: all "3.21.12": From 0b6b1ad5016cf5a08c5c940d568f27d1205a54aa Mon Sep 17 00:00:00 2001 From: Ahajha Date: Fri, 15 Mar 2024 12:43:50 -0400 Subject: [PATCH 17/32] Add note about protobuf versions --- recipes/protobuf/all/conandata.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes/protobuf/all/conandata.yml b/recipes/protobuf/all/conandata.yml index 1eb91ed277326..91df510f13497 100644 --- a/recipes/protobuf/all/conandata.yml +++ b/recipes/protobuf/all/conandata.yml @@ -1,4 +1,8 @@ sources: + # Protobuf maintains multiple different "versions" with the same code for different + # languages, so it is possible to bump these versions incorrectly. + # Follow https://protobuf.dev/support/version-support/#cpp to see what the correct + # version is for C++. "5.26.0": url: "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v5.26.0.tar.gz" sha256: "c3acedccecd385affbd0a32fbbc7e0c7af427d156789726cc27c8a54649e6926" From 97a1bf604a7acdd6bb3529d5de45d1ca68c5faa6 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 23 Mar 2024 10:26:03 +0200 Subject: [PATCH 18/32] protobuf: drop versions older than 3.20.3 --- recipes/protobuf/all/conandata.yml | 36 --------------- recipes/protobuf/all/conanfile.py | 7 --- ...rotobuf-3.17.1-upstream-macos-macros.patch | 46 ------------------- ...rotobuf-3.18.1-upstream-macos-macros.patch | 46 ------------------- ...rotobuf-3.19.6-upstream-macos-macros.patch | 46 ------------------- .../upstream-pr-9437-msvc-runtime.patch | 17 ------- recipes/protobuf/config.yml | 8 ---- 7 files changed, 206 deletions(-) delete mode 100644 recipes/protobuf/all/patches/protobuf-3.17.1-upstream-macos-macros.patch delete mode 100644 recipes/protobuf/all/patches/protobuf-3.18.1-upstream-macos-macros.patch delete mode 100644 recipes/protobuf/all/patches/protobuf-3.19.6-upstream-macos-macros.patch delete mode 100644 recipes/protobuf/all/patches/upstream-pr-9437-msvc-runtime.patch diff --git a/recipes/protobuf/all/conandata.yml b/recipes/protobuf/all/conandata.yml index 91df510f13497..6bbdd7cc918a8 100644 --- a/recipes/protobuf/all/conandata.yml +++ b/recipes/protobuf/all/conandata.yml @@ -18,18 +18,6 @@ sources: "3.20.3": url: "https://github.com/protocolbuffers/protobuf/archive/v3.20.3.tar.gz" sha256: "9c0fd39c7a08dff543c643f0f4baf081988129a411b977a07c46221793605638" - "3.20.0": - url: "https://github.com/protocolbuffers/protobuf/archive/v3.20.0.tar.gz" - sha256: "b07772d38ab07e55eca4d50f4b53da2d998bb221575c60a4f81100242d4b4889" - "3.19.6": - url: "https://github.com/protocolbuffers/protobuf/archive/v3.19.6.tar.gz" - sha256: "9a301cf94a8ddcb380b901e7aac852780b826595075577bb967004050c835056" - "3.18.3": - url: "https://github.com/protocolbuffers/protobuf/archive/v3.18.3.tar.gz" - sha256: "663b3a6d56605e6ab7888d32a1525c34f34639b25b8996337821591e60c37041" - "3.17.1": - url: "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.17.1.tar.gz" - sha256: "036d66d6eec216160dd898cfb162e9d82c1904627642667cc32b104d407bb411" patches: "3.21.12": - patch_file: "patches/protobuf-3.21.12-upstream-macos-macros.patch" @@ -46,27 +34,3 @@ patches: patch_description: "Handle case where macOS SDK macros may conflict with protobuf message types" patch_type: "bugfix" patch_source: "https://github.com/protocolbuffers/protobuf/pull/10103" - "3.20.0": - - patch_file: "patches/protobuf-3.20.0-upstream-macos-macros.patch" - patch_description: "Handle case where macOS SDK macros may conflict with protobuf message types" - patch_type: "bugfix" - patch_source: "https://github.com/protocolbuffers/protobuf/pull/10103" - "3.19.6": - - patch_file: "patches/upstream-pr-9437-msvc-runtime.patch" - patch_description: "Properly handle CMAKE_MSVC_RUNTIME_LIBRARY when using CMake >= 3.15" - patch_type: "portability" - patch_source: "https://github.com/protocolbuffers/protobuf/pull/9437" - - patch_file: "patches/protobuf-3.19.6-upstream-macos-macros.patch" - patch_description: "Handle case where macOS SDK macros may conflict with protobuf message types" - patch_type: "bugfix" - patch_source: "https://github.com/protocolbuffers/protobuf/pull/10103" - "3.18.3": - - patch_file: "patches/protobuf-3.18.1-upstream-macos-macros.patch" - patch_description: "Handle case where macOS SDK macros may conflict with protobuf message types" - patch_type: "bugfix" - patch_source: "https://github.com/protocolbuffers/protobuf/pull/10103" - "3.17.1": - - patch_file: "patches/protobuf-3.17.1-upstream-macos-macros.patch" - patch_description: "Handle case where macOS SDK macros may conflict with protobuf message types" - patch_type: "bugfix" - patch_source: "https://github.com/protocolbuffers/protobuf/pull/10103" diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 4d5b8bc5d0ed1..26221025f1604 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -201,13 +201,6 @@ def _patch_sources(self): "endif()", ) - # https://github.com/protocolbuffers/protobuf/issues/9916 - # it will be solved in protobuf 3.21.0 - if Version(self.version) == "3.20.0": - replace_in_file(self, os.path.join(self.source_folder, "src", "google", "protobuf", "port_def.inc"), - "#elif PROTOBUF_GNUC_MIN(12, 0)", - "#elif PROTOBUF_GNUC_MIN(12, 2)") - def build(self): self._patch_sources() cmake = CMake(self) diff --git a/recipes/protobuf/all/patches/protobuf-3.17.1-upstream-macos-macros.patch b/recipes/protobuf/all/patches/protobuf-3.17.1-upstream-macos-macros.patch deleted file mode 100644 index d8f8f14a25361..0000000000000 --- a/recipes/protobuf/all/patches/protobuf-3.17.1-upstream-macos-macros.patch +++ /dev/null @@ -1,46 +0,0 @@ -diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc -index 61f0859..d673519 100644 ---- a/src/google/protobuf/port_def.inc -+++ b/src/google/protobuf/port_def.inc -@@ -616,6 +616,22 @@ - #undef timezone - #endif // _MSC_VER - -+#ifdef __APPLE__ -+// Inconvenient macro names from usr/include/math.h in some macOS SDKs. -+#pragma push_macro("DOMAIN") -+#undef DOMAIN -+// Inconvenient macro names from /usr/include/mach/boolean.h in some macOS SDKs. -+#pragma push_macro("TRUE") -+#undef TRUE -+#pragma push_macro("FALSE") -+#undef FALSE -+// Inconvenient macro names from usr/include/sys/syslimits.h in some macOS SDKs. -+#pragma push_macro("UID_MAX") -+#undef UID_MAX -+#pragma push_macro("GID_MAX") -+#undef GID_MAX -+#endif // __APPLE__ -+ - #if defined(__clang__) || PROTOBUF_GNUC_MIN(3, 0) || defined(_MSC_VER) - // Don't let Objective-C Macros interfere with proto identifiers with the same - // name. -diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc -index 82fe794..dfbbf5b 100644 ---- a/src/google/protobuf/port_undef.inc -+++ b/src/google/protobuf/port_undef.inc -@@ -112,6 +112,14 @@ - #pragma pop_macro("timezone") - #endif - -+#ifdef __APPLE__ -+#pragma pop_macro("DOMAIN") -+#pragma pop_macro("TRUE") -+#pragma pop_macro("FALSE") -+#pragma pop_macro("UID_MAX") -+#pragma pop_macro("GID_MAX") -+#endif // __APPLE__ -+ - #if defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER) - #pragma pop_macro("DEBUG") - #endif // defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER) diff --git a/recipes/protobuf/all/patches/protobuf-3.18.1-upstream-macos-macros.patch b/recipes/protobuf/all/patches/protobuf-3.18.1-upstream-macos-macros.patch deleted file mode 100644 index 4825966e01d9d..0000000000000 --- a/recipes/protobuf/all/patches/protobuf-3.18.1-upstream-macos-macros.patch +++ /dev/null @@ -1,46 +0,0 @@ -diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc -index 01384c8..8f8a44d 100644 ---- a/src/google/protobuf/port_def.inc -+++ b/src/google/protobuf/port_def.inc -@@ -736,6 +736,22 @@ - #undef timezone - #endif // _MSC_VER - -+#ifdef __APPLE__ -+// Inconvenient macro names from usr/include/math.h in some macOS SDKs. -+#pragma push_macro("DOMAIN") -+#undef DOMAIN -+// Inconvenient macro names from /usr/include/mach/boolean.h in some macOS SDKs. -+#pragma push_macro("TRUE") -+#undef TRUE -+#pragma push_macro("FALSE") -+#undef FALSE -+// Inconvenient macro names from usr/include/sys/syslimits.h in some macOS SDKs. -+#pragma push_macro("UID_MAX") -+#undef UID_MAX -+#pragma push_macro("GID_MAX") -+#undef GID_MAX -+#endif // __APPLE__ -+ - #if defined(__clang__) || PROTOBUF_GNUC_MIN(3, 0) || defined(_MSC_VER) - // Don't let Objective-C Macros interfere with proto identifiers with the same - // name. -diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc -index 5fef6e4..9efd5d6 100644 ---- a/src/google/protobuf/port_undef.inc -+++ b/src/google/protobuf/port_undef.inc -@@ -128,6 +128,14 @@ - #pragma pop_macro("timezone") - #endif - -+#ifdef __APPLE__ -+#pragma pop_macro("DOMAIN") -+#pragma pop_macro("TRUE") -+#pragma pop_macro("FALSE") -+#pragma pop_macro("UID_MAX") -+#pragma pop_macro("GID_MAX") -+#endif // __APPLE__ -+ - #if defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER) - #pragma pop_macro("DEBUG") - #endif // defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER) diff --git a/recipes/protobuf/all/patches/protobuf-3.19.6-upstream-macos-macros.patch b/recipes/protobuf/all/patches/protobuf-3.19.6-upstream-macos-macros.patch deleted file mode 100644 index 5aadd2a257043..0000000000000 --- a/recipes/protobuf/all/patches/protobuf-3.19.6-upstream-macos-macros.patch +++ /dev/null @@ -1,46 +0,0 @@ -diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc -index 30af1cf..4ddf5dc 100644 ---- a/src/google/protobuf/port_def.inc -+++ b/src/google/protobuf/port_def.inc -@@ -763,6 +763,22 @@ - #undef timezone - #endif // _MSC_VER - -+#ifdef __APPLE__ -+// Inconvenient macro names from usr/include/math.h in some macOS SDKs. -+#pragma push_macro("DOMAIN") -+#undef DOMAIN -+// Inconvenient macro names from /usr/include/mach/boolean.h in some macOS SDKs. -+#pragma push_macro("TRUE") -+#undef TRUE -+#pragma push_macro("FALSE") -+#undef FALSE -+// Inconvenient macro names from usr/include/sys/syslimits.h in some macOS SDKs. -+#pragma push_macro("UID_MAX") -+#undef UID_MAX -+#pragma push_macro("GID_MAX") -+#undef GID_MAX -+#endif // __APPLE__ -+ - #if defined(__clang__) || PROTOBUF_GNUC_MIN(3, 0) || defined(_MSC_VER) - // Don't let Objective-C Macros interfere with proto identifiers with the same - // name. -diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc -index 579eb41..7a179f9 100644 ---- a/src/google/protobuf/port_undef.inc -+++ b/src/google/protobuf/port_undef.inc -@@ -129,6 +129,14 @@ - #pragma pop_macro("timezone") - #endif - -+#ifdef __APPLE__ -+#pragma pop_macro("DOMAIN") -+#pragma pop_macro("TRUE") -+#pragma pop_macro("FALSE") -+#pragma pop_macro("UID_MAX") -+#pragma pop_macro("GID_MAX") -+#endif // __APPLE__ -+ - #if defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER) - #pragma pop_macro("DEBUG") - #endif // defined(__clang__) || defined(__GNUC__) || defined(_MSC_VER) diff --git a/recipes/protobuf/all/patches/upstream-pr-9437-msvc-runtime.patch b/recipes/protobuf/all/patches/upstream-pr-9437-msvc-runtime.patch deleted file mode 100644 index 06cb0a97681d1..0000000000000 --- a/recipes/protobuf/all/patches/upstream-pr-9437-msvc-runtime.patch +++ /dev/null @@ -1,17 +0,0 @@ -Fix from Protobuf PR: https://github.com/protocolbuffers/protobuf/pull/9437 - ---- a/cmake/CMakeLists.txt -+++ b/cmake/CMakeLists.txt -@@ -182,7 +182,11 @@ else (protobuf_BUILD_SHARED_LIBS) - # making programmatic control difficult. Prefer the functionality in newer - # CMake versions when available. - if(CMAKE_VERSION VERSION_GREATER 3.15 OR CMAKE_VERSION VERSION_EQUAL 3.15) -- set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$:Debug>) -+ if (protobuf_MSVC_STATIC_RUNTIME) -+ set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$:Debug>) -+ else() -+ set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$:Debug>DLL) -+ endif() - else() - # In case we are building static libraries, link also the runtime library statically - # so that MSVCR*.DLL is not required at runtime. diff --git a/recipes/protobuf/config.yml b/recipes/protobuf/config.yml index a55e3244f5435..089beee346402 100644 --- a/recipes/protobuf/config.yml +++ b/recipes/protobuf/config.yml @@ -9,11 +9,3 @@ versions: folder: all "3.20.3": folder: all - "3.20.0": - folder: all - "3.19.6": - folder: all - "3.18.3": - folder: all - "3.17.1": - folder: all From 4b11ccb0df1c55d0958d1ae3dfbba5717dfd03fd Mon Sep 17 00:00:00 2001 From: Alex Trotta Date: Fri, 5 Apr 2024 00:41:57 -0400 Subject: [PATCH 19/32] Update to protobuf 5.26.1 --- recipes/protobuf/all/conandata.yml | 6 +++--- recipes/protobuf/config.yml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes/protobuf/all/conandata.yml b/recipes/protobuf/all/conandata.yml index 6bbdd7cc918a8..8209ccb2fb05d 100644 --- a/recipes/protobuf/all/conandata.yml +++ b/recipes/protobuf/all/conandata.yml @@ -3,9 +3,9 @@ sources: # languages, so it is possible to bump these versions incorrectly. # Follow https://protobuf.dev/support/version-support/#cpp to see what the correct # version is for C++. - "5.26.0": - url: "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v5.26.0.tar.gz" - sha256: "c3acedccecd385affbd0a32fbbc7e0c7af427d156789726cc27c8a54649e6926" + "5.26.1": + url: "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v5.26.1.tar.gz" + sha256: "3754236f50b12d6b7acbc8a8b233a4324b576fa1f49c7098fb743b788ffade41" "4.25.3": url: "https://github.com/protocolbuffers/protobuf/archive/refs/tags/v4.25.3.tar.gz" sha256: "1d6b8d9114cb5b33ce8711729893097a107d4fefff5423528eb1decb5451856c" diff --git a/recipes/protobuf/config.yml b/recipes/protobuf/config.yml index 089beee346402..ae38f15d13008 100644 --- a/recipes/protobuf/config.yml +++ b/recipes/protobuf/config.yml @@ -1,5 +1,5 @@ versions: - "5.26.0": + "5.26.1": folder: all "4.25.3": folder: all From 02fbd30ccebf45deb15cac477bc4599459b9bf78 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 16 Apr 2024 20:35:10 +0300 Subject: [PATCH 20/32] protobuf: avoid tool_requires() in test_package --- .../protobuf/all/test_package/conanfile.py | 22 ++++++++++----- .../all/test_v1_package/CMakeLists.txt | 8 ------ .../protobuf/all/test_v1_package/conanfile.py | 27 ------------------- 3 files changed, 15 insertions(+), 42 deletions(-) delete mode 100644 recipes/protobuf/all/test_v1_package/CMakeLists.txt delete mode 100644 recipes/protobuf/all/test_v1_package/conanfile.py diff --git a/recipes/protobuf/all/test_package/conanfile.py b/recipes/protobuf/all/test_package/conanfile.py index 81404c86104a8..d8778140e6946 100644 --- a/recipes/protobuf/all/test_package/conanfile.py +++ b/recipes/protobuf/all/test_package/conanfile.py @@ -3,24 +3,32 @@ from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain import os +from conan.tools.env import VirtualRunEnv + class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "CMakeDeps", "VirtualBuildEnv", "VirtualRunEnv" + generators = "CMakeDeps" test_type = "explicit" def layout(self): cmake_layout(self) def requirements(self): - self.requires(self.tested_reference_str) - - def build_requirements(self): - self.tool_requires(self.tested_reference_str) + # A workaround for CI only. + # https://github.com/conan-io/conan-center-index/pull/23573#issue-2246020949 + # Should normally be added without run=True and with a self.tool_requires("protobuf/...") instead + # to avoid propagating run=True in the host context in the graph. + self.requires(self.tested_reference_str, run=True) def generate(self): + venv = VirtualRunEnv(self) + venv.generate(scope="run") + # Needed for the CI workaround. + venv.generate(scope="build") + tc = CMakeToolchain(self) - tc.cache_variables["protobuf_LITE"] = self.dependencies[self.tested_reference_str].options.lite + tc.variables["protobuf_LITE"] = self.dependencies[self.tested_reference_str].options.lite tc.generate() def build(self): @@ -30,5 +38,5 @@ def build(self): def test(self): if can_run(self): - bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + bin_path = os.path.join(self.cpp.build.bindir, "test_package") self.run(bin_path, env="conanrun") diff --git a/recipes/protobuf/all/test_v1_package/CMakeLists.txt b/recipes/protobuf/all/test_v1_package/CMakeLists.txt deleted file mode 100644 index f16bc97992e86..0000000000000 --- a/recipes/protobuf/all/test_v1_package/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -cmake_minimum_required(VERSION 3.8) -project(test_v1_package LANGUAGES CXX) - -include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(TARGETS) - -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/ - ${CMAKE_CURRENT_BINARY_DIR}/test_package/) diff --git a/recipes/protobuf/all/test_v1_package/conanfile.py b/recipes/protobuf/all/test_v1_package/conanfile.py deleted file mode 100644 index f31e33d3b0ff4..0000000000000 --- a/recipes/protobuf/all/test_v1_package/conanfile.py +++ /dev/null @@ -1,27 +0,0 @@ -from conans import ConanFile, CMake, tools -import os - - -class TestPackageConan(ConanFile): - settings = "os", "arch", "compiler", "build_type" - generators = "cmake", "cmake_find_package_multi" - test_type = "explicit" - - def requirements(self): - self.requires(self.tested_reference_str) - - def build_requirements(self): - if hasattr(self, "settings_build"): - self.build_requires(self.tested_reference_str) - - def build(self): - with tools.no_op() if hasattr(self, "settings_build") else tools.run_environment(self): - cmake = CMake(self) - cmake.definitions["protobuf_LITE"] = self.options["protobuf"].lite - cmake.configure() - cmake.build() - - def test(self): - if not tools.cross_building(self): - self.run("protoc --version", run_environment=True) - self.run(os.path.join("bin", "test_package"), run_environment=True) From 4529c72a1eae02feddce0a0f4f52b3c4d1a6e73c Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 16 Apr 2024 21:03:24 +0300 Subject: [PATCH 21/32] protobuf: format imports --- recipes/protobuf/all/test_package/conanfile.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/recipes/protobuf/all/test_package/conanfile.py b/recipes/protobuf/all/test_package/conanfile.py index d8778140e6946..b9745e7107a54 100644 --- a/recipes/protobuf/all/test_package/conanfile.py +++ b/recipes/protobuf/all/test_package/conanfile.py @@ -1,9 +1,8 @@ from conan import ConanFile from conan.tools.build import can_run from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain -import os - from conan.tools.env import VirtualRunEnv +import os class TestPackageConan(ConanFile): From f1ed8fadcba3a5762146a74f256c56edc7364a16 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 16 Apr 2024 23:21:35 +0300 Subject: [PATCH 22/32] protobuf: skip protobuf_generate() test when cross-compiling --- recipes/protobuf/all/test_package/CMakeLists.txt | 7 ++++--- recipes/protobuf/all/test_package/conanfile.py | 3 +++ recipes/protobuf/all/test_package/test_package.cpp | 14 ++++++-------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/recipes/protobuf/all/test_package/CMakeLists.txt b/recipes/protobuf/all/test_package/CMakeLists.txt index 78297d6a21111..cec43ed3f3a5d 100644 --- a/recipes/protobuf/all/test_package/CMakeLists.txt +++ b/recipes/protobuf/all/test_package/CMakeLists.txt @@ -1,5 +1,4 @@ cmake_minimum_required(VERSION 3.15) - project(test_package LANGUAGES CXX) find_package(protobuf CONFIG REQUIRED) @@ -23,5 +22,7 @@ if(TARGET protobuf::libprotoc) target_link_libraries(${PROJECT_NAME} PRIVATE protobuf::libprotoc) endif() -protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS TARGET ${PROJECT_NAME}) -protobuf_generate(LANGUAGE cpp TARGET ${PROJECT_NAME} PROTOS addressbook.proto) +if(NOT CMAKE_CROSSCOMPILING) + protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS TARGET ${PROJECT_NAME}) + protobuf_generate(LANGUAGE cpp TARGET ${PROJECT_NAME} PROTOS addressbook.proto) +endif() diff --git a/recipes/protobuf/all/test_package/conanfile.py b/recipes/protobuf/all/test_package/conanfile.py index b9745e7107a54..8922919c0443e 100644 --- a/recipes/protobuf/all/test_package/conanfile.py +++ b/recipes/protobuf/all/test_package/conanfile.py @@ -39,3 +39,6 @@ def test(self): if can_run(self): bin_path = os.path.join(self.cpp.build.bindir, "test_package") self.run(bin_path, env="conanrun") + + assert os.path.exists(os.path.join(self.build_folder, "addressbook.pb.cc")) + assert os.path.exists(os.path.join(self.build_folder, "addressbook.pb.h")) diff --git a/recipes/protobuf/all/test_package/test_package.cpp b/recipes/protobuf/all/test_package/test_package.cpp index aee0c47205eed..3d3122ddd2587 100644 --- a/recipes/protobuf/all/test_package/test_package.cpp +++ b/recipes/protobuf/all/test_package/test_package.cpp @@ -1,17 +1,15 @@ #include #include -#include "addressbook.pb.h" +#include +#include int main() { - std::cout << "Bincrafters\n"; + google::protobuf::Timestamp ts; + google::protobuf::util::TimeUtil::FromString("1972-01-01T10:00:20.021Z", &ts); + const auto nanoseconds = ts.nanos(); - tutorial::Person p; - p.set_id(21); - p.set_name("conan-center-index"); - p.set_email("info@conan.io"); - - std::cout << p.SerializeAsString() << "\n"; + std::cout << nanoseconds << "\n"; return EXIT_SUCCESS; } From ac7941e26f39bb64e8ec8ad54ce41dbbb1bc1117 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 17 Apr 2024 10:07:36 +0300 Subject: [PATCH 23/32] protobuf: try a macOS workaround from grpc recipe --- recipes/protobuf/all/test_package/conanfile.py | 3 +++ .../all/test_package/macos_make_override.cmake | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 recipes/protobuf/all/test_package/macos_make_override.cmake diff --git a/recipes/protobuf/all/test_package/conanfile.py b/recipes/protobuf/all/test_package/conanfile.py index 8922919c0443e..dd8471a595b31 100644 --- a/recipes/protobuf/all/test_package/conanfile.py +++ b/recipes/protobuf/all/test_package/conanfile.py @@ -28,6 +28,9 @@ def generate(self): tc = CMakeToolchain(self) tc.variables["protobuf_LITE"] = self.dependencies[self.tested_reference_str].options.lite + # Additional logic to override the make program on MacOS if /usr/bin/make is found by CMake + # which otherwise prevents the propagation of DYLD_LIBRARY_PATH as set by the VirtualBuildEnv + tc.cache_variables["CMAKE_PROJECT_test_package_INCLUDE"] = os.path.join(self.source_folder, "macos_make_override.cmake") tc.generate() def build(self): diff --git a/recipes/protobuf/all/test_package/macos_make_override.cmake b/recipes/protobuf/all/test_package/macos_make_override.cmake new file mode 100644 index 0000000000000..e7078c1b51419 --- /dev/null +++ b/recipes/protobuf/all/test_package/macos_make_override.cmake @@ -0,0 +1,13 @@ +if (CMAKE_GENERATOR MATCHES "Unix Makefiles" AND CMAKE_HOST_APPLE AND CMAKE_MAKE_PROGRAM MATCHES "/usr/bin/make") + execute_process( + COMMAND xcrun --find make + OUTPUT_VARIABLE xcode_make OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE xcrun_error) + if(xcode_make) + #Override the value of `CMAKE_MAKE_PROGRAM` + set_property(CACHE CMAKE_MAKE_PROGRAM PROPERTY VALUE "${xcode_make}") + else() + message(WARNING "Using /usr/bin/make may prevent execution of Conan tool_requires that require DYLD_LIBRARY_PATH" + " to be set at build time.") + endif() +endif() From 4696eebbc89f3fc3b5a30e6bed3795c42fdf3017 Mon Sep 17 00:00:00 2001 From: Alex Trotta Date: Thu, 18 Apr 2024 01:07:24 -0400 Subject: [PATCH 24/32] Remove CMake calls for now --- recipes/protobuf/all/test_package/CMakeLists.txt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/recipes/protobuf/all/test_package/CMakeLists.txt b/recipes/protobuf/all/test_package/CMakeLists.txt index f26cd7983b7a9..1af13c1f4b0ea 100644 --- a/recipes/protobuf/all/test_package/CMakeLists.txt +++ b/recipes/protobuf/all/test_package/CMakeLists.txt @@ -21,8 +21,3 @@ endif() if(TARGET protobuf::libprotoc) target_link_libraries(${PROJECT_NAME} PRIVATE protobuf::libprotoc) endif() - -if(NOT CMAKE_CROSSCOMPILING) - protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS TARGET ${PROJECT_NAME}) - protobuf_generate(LANGUAGE cpp TARGET ${PROJECT_NAME} PROTOS addressbook.proto) -endif () From 3958f9bd5e993185e809782f3c2c8ad3724cbab3 Mon Sep 17 00:00:00 2001 From: Alex Trotta Date: Thu, 18 Apr 2024 01:07:38 -0400 Subject: [PATCH 25/32] Fix running test package with whitespace in path --- recipes/protobuf/all/test_package/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/protobuf/all/test_package/conanfile.py b/recipes/protobuf/all/test_package/conanfile.py index b9f2b335c4343..bedfcfa3e6a06 100644 --- a/recipes/protobuf/all/test_package/conanfile.py +++ b/recipes/protobuf/all/test_package/conanfile.py @@ -41,6 +41,6 @@ def test(self): self.run(bin_path, env="conanrun") # Invoke protoc in the same way CMake would - self.run(f"protoc --proto_path={self.source_folder} --cpp_out={self.build_folder} {self.source_folder}/addressbook.proto", env="conanrun") + self.run(f"protoc --proto_path=\"{self.source_folder}\" --cpp_out=\"{self.build_folder}\" \"{self.source_folder}\"/addressbook.proto", env="conanrun") assert os.path.exists(os.path.join(self.build_folder, "addressbook.pb.cc")) assert os.path.exists(os.path.join(self.build_folder, "addressbook.pb.h")) From 7f03206100570065ca5c5b07b673b48a3dfa3740 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 14 May 2024 12:08:49 +0300 Subject: [PATCH 26/32] protobuf: try building without setting CMAKE_CXX_STANDARD --- recipes/protobuf/all/conanfile.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 26221025f1604..9787ad93aa907 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -2,7 +2,7 @@ from conan.errors import ConanInvalidConfiguration from conan.tools.apple import is_apple_os from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout -from conan.tools.build import check_min_cppstd, valid_min_cppstd +from conan.tools.build import check_min_cppstd from conan.tools.files import copy, rename, get, apply_conandata_patches, export_conandata_patches, replace_in_file, rmdir, rm from conan.tools.microsoft import is_msvc, is_msvc_static_runtime from conan.tools.scm import Version @@ -129,8 +129,6 @@ def generate(self): # Workaround against SIP on macOS for consumers while invoking protoc when protobuf lib is shared tc.variables["CMAKE_INSTALL_RPATH"] = "@loader_path/../lib" tc.variables["protobuf_ABSL_PROVIDER"] = "package" - if not valid_min_cppstd(self, self._min_cppstd): - tc.variables["CMAKE_CXX_STANDARD"] = self._min_cppstd tc.generate() deps = CMakeDeps(self) From d454a59bd0faecf442ca6a78cfb77a49d0f4fa15 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 14 May 2024 12:25:11 +0300 Subject: [PATCH 27/32] protobuf: revert left-over workarounds in test_package --- .../protobuf/all/test_package/conanfile.py | 21 ++++++------------- .../test_package/macos_make_override.cmake | 13 ------------ 2 files changed, 6 insertions(+), 28 deletions(-) delete mode 100644 recipes/protobuf/all/test_package/macos_make_override.cmake diff --git a/recipes/protobuf/all/test_package/conanfile.py b/recipes/protobuf/all/test_package/conanfile.py index bedfcfa3e6a06..f31fbd67038e1 100644 --- a/recipes/protobuf/all/test_package/conanfile.py +++ b/recipes/protobuf/all/test_package/conanfile.py @@ -1,13 +1,12 @@ from conan import ConanFile from conan.tools.build import can_run from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain -from conan.tools.env import VirtualRunEnv import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "CMakeDeps" + generators = "CMakeDeps", "VirtualBuildEnv", "VirtualRunEnv" test_type = "explicit" def layout(self): @@ -18,16 +17,8 @@ def requirements(self): self.requires(self.tested_reference_str, run=True) def generate(self): - venv = VirtualRunEnv(self) - venv.generate(scope="run") - # Needed for the CI workaround. - venv.generate(scope="build") - tc = CMakeToolchain(self) - tc.variables["protobuf_LITE"] = self.dependencies[self.tested_reference_str].options.lite - # Additional logic to override the make program on MacOS if /usr/bin/make is found by CMake - # which otherwise prevents the propagation of DYLD_LIBRARY_PATH as set by the VirtualBuildEnv - tc.cache_variables["CMAKE_PROJECT_test_package_INCLUDE"] = os.path.join(self.source_folder, "macos_make_override.cmake") + tc.cache_variables["protobuf_LITE"] = self.dependencies[self.tested_reference_str].options.lite tc.generate() def build(self): @@ -37,10 +28,10 @@ def build(self): def test(self): if can_run(self): - bin_path = os.path.join(self.cpp.build.bindir, "test_package") + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") self.run(bin_path, env="conanrun") # Invoke protoc in the same way CMake would - self.run(f"protoc --proto_path=\"{self.source_folder}\" --cpp_out=\"{self.build_folder}\" \"{self.source_folder}\"/addressbook.proto", env="conanrun") - assert os.path.exists(os.path.join(self.build_folder, "addressbook.pb.cc")) - assert os.path.exists(os.path.join(self.build_folder, "addressbook.pb.h")) + self.run(f"protoc --proto_path={self.source_folder} --cpp_out={self.build_folder} {self.source_folder}/addressbook.proto", env="conanrun") + assert os.path.exists(os.path.join(self.build_folder,"addressbook.pb.cc")) + assert os.path.exists(os.path.join(self.build_folder,"addressbook.pb.h")) diff --git a/recipes/protobuf/all/test_package/macos_make_override.cmake b/recipes/protobuf/all/test_package/macos_make_override.cmake deleted file mode 100644 index e7078c1b51419..0000000000000 --- a/recipes/protobuf/all/test_package/macos_make_override.cmake +++ /dev/null @@ -1,13 +0,0 @@ -if (CMAKE_GENERATOR MATCHES "Unix Makefiles" AND CMAKE_HOST_APPLE AND CMAKE_MAKE_PROGRAM MATCHES "/usr/bin/make") - execute_process( - COMMAND xcrun --find make - OUTPUT_VARIABLE xcode_make OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_VARIABLE xcrun_error) - if(xcode_make) - #Override the value of `CMAKE_MAKE_PROGRAM` - set_property(CACHE CMAKE_MAKE_PROGRAM PROPERTY VALUE "${xcode_make}") - else() - message(WARNING "Using /usr/bin/make may prevent execution of Conan tool_requires that require DYLD_LIBRARY_PATH" - " to be set at build time.") - endif() -endif() From b39a2949aef9c56a6c0d7f997a2efee3e6d7761e Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 14 May 2024 13:33:10 +0300 Subject: [PATCH 28/32] Revert "protobuf: try building without setting CMAKE_CXX_STANDARD" This reverts commit 7f03206100570065ca5c5b07b673b48a3dfa3740. --- recipes/protobuf/all/conanfile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 9787ad93aa907..26221025f1604 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -2,7 +2,7 @@ from conan.errors import ConanInvalidConfiguration from conan.tools.apple import is_apple_os from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout -from conan.tools.build import check_min_cppstd +from conan.tools.build import check_min_cppstd, valid_min_cppstd from conan.tools.files import copy, rename, get, apply_conandata_patches, export_conandata_patches, replace_in_file, rmdir, rm from conan.tools.microsoft import is_msvc, is_msvc_static_runtime from conan.tools.scm import Version @@ -129,6 +129,8 @@ def generate(self): # Workaround against SIP on macOS for consumers while invoking protoc when protobuf lib is shared tc.variables["CMAKE_INSTALL_RPATH"] = "@loader_path/../lib" tc.variables["protobuf_ABSL_PROVIDER"] = "package" + if not valid_min_cppstd(self, self._min_cppstd): + tc.variables["CMAKE_CXX_STANDARD"] = self._min_cppstd tc.generate() deps = CMakeDeps(self) From 48d326392d6a810800bfd07f8dcc87439156a672 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 14 May 2024 17:21:24 +0300 Subject: [PATCH 29/32] protobuf: apply review suggestions --- recipes/protobuf/all/conanfile.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 26221025f1604..d0ca7f582dff1 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -63,11 +63,7 @@ def _compilers_minimum_version(self): "Visual Studio": "15", "msvc": "191", } - return { - "clang": "4", - "Visual Studio": "14", - "msvc": "190", - } + return {} def export_sources(self): export_conandata_patches(self) @@ -80,6 +76,8 @@ def configure(self): if self.options.shared: self.options.rm_safe("fPIC") if Version(self.version) >= "3.22.0" and is_msvc(self): + # Protobuf requires absl::abseil_dll + # https://github.com/protocolbuffers/protobuf/blob/v25.3/cmake/abseil-cpp.cmake#L40 self.options["abseil"].shared = True def layout(self): @@ -130,6 +128,8 @@ def generate(self): tc.variables["CMAKE_INSTALL_RPATH"] = "@loader_path/../lib" tc.variables["protobuf_ABSL_PROVIDER"] = "package" if not valid_min_cppstd(self, self._min_cppstd): + # Protobuf does not pass a C++ standard but requires C++14 (>=3.22) + # https://github.com/protocolbuffers/protobuf/blob/v4.25.3/cmake/README.md#c-version tc.variables["CMAKE_CXX_STANDARD"] = self._min_cppstd tc.generate() From c83f1cdda6567fb58bb8d1357bb50d2d90cf28f6 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Thu, 16 May 2024 15:15:09 +0300 Subject: [PATCH 30/32] protobuf: restore "linkage" test for CMake functions in test_package --- recipes/protobuf/all/test_package/CMakeLists.txt | 5 ++++- recipes/protobuf/all/test_package/conanfile.py | 15 +++++++-------- .../protobuf/all/test_package/test_package.cpp | 7 +++++++ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/recipes/protobuf/all/test_package/CMakeLists.txt b/recipes/protobuf/all/test_package/CMakeLists.txt index 1af13c1f4b0ea..e6718f879648c 100644 --- a/recipes/protobuf/all/test_package/CMakeLists.txt +++ b/recipes/protobuf/all/test_package/CMakeLists.txt @@ -3,7 +3,7 @@ project(test_package LANGUAGES CXX) find_package(protobuf CONFIG REQUIRED) -add_executable(${PROJECT_NAME} test_package.cpp) +add_executable(${PROJECT_NAME} test_package.cpp addressbook.proto) if (protobuf_VERSION VERSION_LESS "3.22.0") target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) @@ -21,3 +21,6 @@ endif() if(TARGET protobuf::libprotoc) target_link_libraries(${PROJECT_NAME} PRIVATE protobuf::libprotoc) endif() + +protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS TARGET ${PROJECT_NAME}) +protobuf_generate(LANGUAGE cpp TARGET ${PROJECT_NAME} PROTOS addressbook.proto) diff --git a/recipes/protobuf/all/test_package/conanfile.py b/recipes/protobuf/all/test_package/conanfile.py index f31fbd67038e1..ea3b4dadb6396 100644 --- a/recipes/protobuf/all/test_package/conanfile.py +++ b/recipes/protobuf/all/test_package/conanfile.py @@ -1,12 +1,13 @@ from conan import ConanFile from conan.tools.build import can_run from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain +from conan.tools.env import VirtualRunEnv import os class TestPackageConan(ConanFile): settings = "os", "arch", "compiler", "build_type" - generators = "CMakeDeps", "VirtualBuildEnv", "VirtualRunEnv" + generators = "CMakeDeps", "VirtualBuildEnv" test_type = "explicit" def layout(self): @@ -17,8 +18,11 @@ def requirements(self): self.requires(self.tested_reference_str, run=True) def generate(self): + venv = VirtualRunEnv(self) + venv.generate(scope="build") + venv.generate(scope="run") tc = CMakeToolchain(self) - tc.cache_variables["protobuf_LITE"] = self.dependencies[self.tested_reference_str].options.lite + tc.variables["protobuf_LITE"] = self.dependencies[self.tested_reference_str].options.lite tc.generate() def build(self): @@ -28,10 +32,5 @@ def build(self): def test(self): if can_run(self): - bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + bin_path = os.path.join(self.cpp.build.bindir, "test_package") self.run(bin_path, env="conanrun") - - # Invoke protoc in the same way CMake would - self.run(f"protoc --proto_path={self.source_folder} --cpp_out={self.build_folder} {self.source_folder}/addressbook.proto", env="conanrun") - assert os.path.exists(os.path.join(self.build_folder,"addressbook.pb.cc")) - assert os.path.exists(os.path.join(self.build_folder,"addressbook.pb.h")) diff --git a/recipes/protobuf/all/test_package/test_package.cpp b/recipes/protobuf/all/test_package/test_package.cpp index 3d3122ddd2587..e7804c4160568 100644 --- a/recipes/protobuf/all/test_package/test_package.cpp +++ b/recipes/protobuf/all/test_package/test_package.cpp @@ -4,8 +4,15 @@ #include #include +#include "addressbook.pb.h" + int main() { + tutorial::Person p; + p.set_id(21); + p.set_name("conan-center-index"); + p.set_email("info@conan.io"); + google::protobuf::Timestamp ts; google::protobuf::util::TimeUtil::FromString("1972-01-01T10:00:20.021Z", &ts); const auto nanoseconds = ts.nanos(); From 9bc1f1255531f624a821116471f5e38f24455bb4 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Thu, 16 May 2024 15:17:47 +0300 Subject: [PATCH 31/32] protobuf: simplify CMake module packaging --- recipes/protobuf/all/conanfile.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index d0ca7f582dff1..4983c247110d4 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -216,13 +216,9 @@ def package(self): os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-config-version.cmake")) os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, f"protobuf-targets-{str(self.settings.build_type).lower()}.cmake")) os.unlink(os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-targets.cmake")) - if Version(self.version) < "3.22.0": - rename(self, os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-config.cmake"), - os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-generate.cmake")) - else: - # TODO: dirty hack, need to fix - rename(self, os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-config.cmake"), - os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-protoc.cmake")) + # Avoid packaging of protobuf-config.cmake due to potential confusion in find_package(protobuf CONFIG) + rename(self, os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-config.cmake"), + os.path.join(self.package_folder, self._cmake_install_base_path, "protobuf-protoc.cmake")) if not self.options.lite: rm(self, "libprotobuf-lite*", os.path.join(self.package_folder, "lib")) @@ -238,12 +234,12 @@ def package_info(self): self.cpp_info.set_property("pkg_config_name", "protobuf_full_package") # unofficial, but required to avoid side effects (libprotobuf component "steals" the default global pkg_config name) build_modules = [ - os.path.join(self._cmake_install_base_path, "protobuf-generate.cmake"), os.path.join(self._cmake_install_base_path, "protobuf-module.cmake"), os.path.join(self._cmake_install_base_path, "protobuf-options.cmake"), + os.path.join(self._cmake_install_base_path, "protobuf-protoc.cmake"), ] if Version(self.version) >= "3.22.0": - build_modules.append(os.path.join(self._cmake_install_base_path, "protobuf-protoc.cmake")) + build_modules.append(os.path.join(self._cmake_install_base_path, "protobuf-generate.cmake")) self.cpp_info.set_property("cmake_build_modules", build_modules) lib_prefix = "lib" if (is_msvc(self) or self._is_clang_cl) else "" @@ -307,7 +303,7 @@ def package_info(self): # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed self.cpp_info.filenames["cmake_find_package"] = "Protobuf" self.cpp_info.filenames["cmake_find_package_multi"] = "protobuf" - self.cpp_info.names["pkg_config"] ="protobuf_full_package" + self.cpp_info.names["pkg_config"] = "protobuf_full_package" for generator in ["cmake_find_package", "cmake_find_package_multi"]: self.cpp_info.components["libprotobuf"].build_modules[generator] = build_modules if self.options.lite: From 6da91e5ebd05ee88cbc164c3cfe0d329ea12b05f Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Fri, 17 May 2024 15:55:35 +0300 Subject: [PATCH 32/32] protobuf: restore macOS CMake test_package workaround --- recipes/protobuf/all/test_package/conanfile.py | 2 ++ .../all/test_package/macos_make_override.cmake | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 recipes/protobuf/all/test_package/macos_make_override.cmake diff --git a/recipes/protobuf/all/test_package/conanfile.py b/recipes/protobuf/all/test_package/conanfile.py index ea3b4dadb6396..81ffa6db31bbf 100644 --- a/recipes/protobuf/all/test_package/conanfile.py +++ b/recipes/protobuf/all/test_package/conanfile.py @@ -21,8 +21,10 @@ def generate(self): venv = VirtualRunEnv(self) venv.generate(scope="build") venv.generate(scope="run") + tc = CMakeToolchain(self) tc.variables["protobuf_LITE"] = self.dependencies[self.tested_reference_str].options.lite + tc.cache_variables["CMAKE_PROJECT_test_package_INCLUDE"] = os.path.join(self.source_folder, "macos_make_override.cmake") tc.generate() def build(self): diff --git a/recipes/protobuf/all/test_package/macos_make_override.cmake b/recipes/protobuf/all/test_package/macos_make_override.cmake new file mode 100644 index 0000000000000..ee0109e60a6a7 --- /dev/null +++ b/recipes/protobuf/all/test_package/macos_make_override.cmake @@ -0,0 +1,15 @@ +# Additional logic to override the make program on MacOS if /usr/bin/make is found by CMake +# which otherwise prevents the propagation of DYLD_LIBRARY_PATH as set by the VirtualBuildEnv +if (CMAKE_GENERATOR MATCHES "Unix Makefiles" AND CMAKE_HOST_APPLE AND CMAKE_MAKE_PROGRAM MATCHES "/usr/bin/make") + execute_process( + COMMAND xcrun --find make + OUTPUT_VARIABLE xcode_make OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE xcrun_error) + if(xcode_make) + #Override the value of `CMAKE_MAKE_PROGRAM` + set_property(CACHE CMAKE_MAKE_PROGRAM PROPERTY VALUE "${xcode_make}") + else() + message(WARNING "Using /usr/bin/make may prevent execution of Conan tool_requires that require DYLD_LIBRARY_PATH" + " to be set at build time.") + endif() +endif()