From f320810f840ab43bfa2c514ac25e89f77830fed8 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Wed, 3 Mar 2021 17:54:55 +0100 Subject: [PATCH 01/27] really provide protobuf::protoc target --- recipes/protobuf/all/conanfile.py | 84 +++++++++++++++---------------- 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 55acec5195834..327b1cd5f6d04 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -51,9 +51,6 @@ def configure(self): if self.settings.os == "Windows" and self.settings.compiler in ["Visual Studio", "clang"] and "MT" in self.settings.compiler.runtime: raise ConanInvalidConfiguration("Protobuf can't be built with shared + MT(d) runtimes") - if tools.is_apple_os(self.settings.os): - raise ConanInvalidConfiguration("Protobuf could not be built as shared library for Mac.") - if self.settings.compiler == "Visual Studio": if Version(self.settings.compiler.version) < "14": raise ConanInvalidConfiguration("On Windows Protobuf can only be built with " @@ -83,57 +80,61 @@ def _patch_sources(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) - find_protoc = """ - -# Find the protobuf compiler within the paths added by Conan, for use below. -find_program(PROTOC_PROGRAM protoc) -if(NOT PROTOC_PROGRAM) - set(PROTOC_PROGRAM "protoc") -endif() -""" + # Inject relocatable protobuf::protoc target in protobuf-config.cmake.in + # TODO: some of the following logic might be disabled when conan will + # allow to create executable imported targets in package_info() + protobuf_config_cmake = os.path.join(self._source_subfolder, "cmake", "protobuf-config.cmake.in") tools.replace_in_file( - os.path.join(self._source_subfolder, "cmake", "protobuf-config.cmake.in"), + protobuf_config_cmake, "@_protobuf_FIND_ZLIB@", - "# CONAN PATCH _protobuf_FIND_ZLIB@" + "# BEGIN CONAN PATCH\n#_protobuf_FIND_ZLIB@\n# END CONAN PATCH" ) + + 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) tools.replace_in_file( - os.path.join(self._source_subfolder, "cmake", "protobuf-config.cmake.in"), + protobuf_config_cmake, "include(\"${CMAKE_CURRENT_LIST_DIR}/protobuf-targets.cmake\")", - "# CONAN PATCH include(\"${CMAKE_CURRENT_LIST_DIR}/protobuf-targets.cmake\")" + find_protoc + ("if(NOT TARGET protobuf::protoc)\n" + " add_executable(protobuf::protoc IMPORTED)\n" + " get_filename_component(PROTOC_FULL_PATH \"${{CMAKE_CURRENT_LIST_DIR}}/{protoc_rel_path}\" ABSOLUTE)\n" + " set_property(TARGET protobuf::protoc PROPERTY IMPORTED_LOCATION ${{PROTOC_FULL_PATH}})\n" + "endif()" + ).format(protoc_rel_path=protoc_rel_path) ) - if tools.Version(self.version) < "3.12.0": + # Set DYLD_LIBRARY_PATH in command line to avoid issues with shared protobuf + # (even with virtualrunenv, this fix might be required due to SIP) + # Only works with cmake, cmake_find_package or cmake_find_package_multi generators + if tools.is_apple_os(self.settings.os): + protobuf_lib_path = (# from cmake generator + "${CONAN_LIB_DIRS}:" + # from cmake_find_package generator + "${Protobuf_LIB_DIRS}:" + # from cmake_find_package_multi generator + "${Protobuf_LIB_DIRS_RELEASE}:${Protobuf_LIB_DIRS_DEBUG}:${Protobuf_LIB_DIRS_RELWITHDEBINFO}:${Protobuf_LIB_DIRS_MINSIZEREL}") tools.replace_in_file( - os.path.join(self._source_subfolder, "cmake", "protobuf-config.cmake.in"), - """COMMAND protobuf::protoc - ARGS --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${protobuf_generate_PROTOC_OUT_DIR} ${_protobuf_include_path} ${_abs_file} - DEPENDS ${_abs_file} protobuf::protoc""", - """COMMAND "${CMAKE_COMMAND}" - ARGS -E env "DYLD_LIBRARY_PATH=${Protobuf_LIB_DIRS}:${CONAN_LIB_DIRS}:${Protobuf_LIB_DIRS_RELEASE}:${Protobuf_LIB_DIRS_DEBUG}:${Protobuf_LIB_DIRS_RELWITHDEBINFO}:${Protobuf_LIB_DIRS_MINSIZEREL}" ${PROTOC_PROGRAM} --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${protobuf_generate_PROTOC_OUT_DIR} ${_protobuf_include_path} ${_abs_file} - DEPENDS ${_abs_file} USES_TERMINAL""" - ) - else: - tools.replace_in_file( - os.path.join(self._source_subfolder, "cmake", "protobuf-config.cmake.in"), - """COMMAND protobuf::protoc - ARGS --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${protobuf_generate_PROTOC_OUT_DIR} ${_plugin} ${_protobuf_include_path} ${_abs_file} - DEPENDS ${_abs_file} protobuf::protoc""", - """COMMAND "${CMAKE_COMMAND}" - ARGS -E env "DYLD_LIBRARY_PATH=${Protobuf_LIB_DIRS}:${CONAN_LIB_DIRS}:${Protobuf_LIB_DIRS_RELEASE}:${Protobuf_LIB_DIRS_DEBUG}:${Protobuf_LIB_DIRS_RELWITHDEBINFO}:${Protobuf_LIB_DIRS_MINSIZEREL}" ${PROTOC_PROGRAM} --${protobuf_generate_LANGUAGE}_out ${_dll_export_decl}${protobuf_generate_PROTOC_OUT_DIR} ${_plugin} ${_protobuf_include_path} ${_abs_file} - DEPENDS ${_abs_file} USES_TERMINAL""" + protobuf_config_cmake, + "COMMAND protobuf::protoc", + ("COMMAND export DYLD_LIBRARY_PATH={}\n" + "COMMAND protobuf::protoc").format(protobuf_lib_path), ) + # Disable a potential warning in protobuf-module.cmake.in + # TODO: remove this patch? Is it really useful? + protobuf_module_cmake = os.path.join(self._source_subfolder, "cmake", "protobuf-module.cmake.in") tools.replace_in_file( - os.path.join(self._source_subfolder, "cmake", "protobuf-module.cmake.in"), - 'if(DEFINED Protobuf_SRC_ROOT_FOLDER)', - """if(0) -if(DEFINED Protobuf_SRC_ROOT_FOLDER)""", + protobuf_module_cmake, + "if(DEFINED Protobuf_SRC_ROOT_FOLDER)", + "if(0)\nif(DEFINED Protobuf_SRC_ROOT_FOLDER)", ) tools.replace_in_file( - os.path.join(self._source_subfolder, "cmake", "protobuf-module.cmake.in"), - '# Define upper case versions of output variables', - 'endif()', + protobuf_module_cmake, + "# Define upper case versions of output variables", + "endif()", ) def build(self): @@ -196,9 +197,6 @@ def package_info(self): self.cpp_info.components["libprotoc"].libs = [lib_prefix + "protoc" + lib_suffix] self.cpp_info.components["libprotoc"].requires = ["libprotobuf"] - self.cpp_info.components["protoc"].name = "protoc" - self.cpp_info.components["protoc"].requires.extend(["libprotoc", "libprotobuf"]) - bindir = os.path.join(self.package_folder, "bin") self.output.info("Appending PATH environment variable: {}".format(bindir)) self.env_info.PATH.append(bindir) From f13d5b74bbf44a76b01ace666d7c076aa74d7871 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Wed, 3 Mar 2021 18:55:15 +0100 Subject: [PATCH 02/27] cosmetic change --- recipes/protobuf/all/conanfile.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 327b1cd5f6d04..05f8e40529b46 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -34,12 +34,6 @@ def _build_subfolder(self): def _is_clang_x86(self): return self.settings.compiler == "clang" and self.settings.arch == "x86" - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - extracted_folder = self.name + "-" + self.version - os.rename(extracted_folder, self._source_subfolder) - - def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -55,10 +49,16 @@ def configure(self): if Version(self.settings.compiler.version) < "14": raise ConanInvalidConfiguration("On Windows Protobuf can only be built with " "Visual Studio 2015 or higher.") + def requirements(self): if self.options.with_zlib: self.requires("zlib/1.2.11") + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + extracted_folder = self.name + "-" + self.version + os.rename(extracted_folder, self._source_subfolder) + @property def _cmake_install_base_path(self): return os.path.join("lib", "cmake", "protobuf") From d636224665b6d608afa9a62601476bcf60160e8f Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Wed, 3 Mar 2021 18:58:09 +0100 Subject: [PATCH 03/27] simplify check of runtime --- 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 05f8e40529b46..49e6b5c8a0c24 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -42,7 +42,7 @@ def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.os == "Windows" and self.settings.compiler in ["Visual Studio", "clang"] and "MT" in self.settings.compiler.runtime: + if self.settings.compiler.get_safe("runtime") in ["MT", "MTd"]: raise ConanInvalidConfiguration("Protobuf can't be built with shared + MT(d) runtimes") if self.settings.compiler == "Visual Studio": From c4037a25b564fe55e5e622742374e3039409e8c5 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Wed, 3 Mar 2021 19:54:35 +0100 Subject: [PATCH 04/27] properly handle protobuf with zlib previous injection of lib directories was too fragile. It breaks as soon as there is a dependency --- recipes/protobuf/all/conanfile.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 49e6b5c8a0c24..832fc7a757e29 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -110,17 +110,18 @@ def _patch_sources(self): # (even with virtualrunenv, this fix might be required due to SIP) # Only works with cmake, cmake_find_package or cmake_find_package_multi generators if tools.is_apple_os(self.settings.os): - protobuf_lib_path = (# from cmake generator - "${CONAN_LIB_DIRS}:" - # from cmake_find_package generator - "${Protobuf_LIB_DIRS}:" - # from cmake_find_package_multi generator - "${Protobuf_LIB_DIRS_RELEASE}:${Protobuf_LIB_DIRS_DEBUG}:${Protobuf_LIB_DIRS_RELWITHDEBINFO}:${Protobuf_LIB_DIRS_MINSIZEREL}") + tools.replace_in_file( + protobuf_config_cmake, + "add_custom_command(", + ("set(CUSTOM_DYLD_LIBRARY_PATH ${CONAN_LIB_DIRS} ${Protobuf_LIB_DIRS} ${Protobuf_LIB_DIRS_RELEASE} ${Protobuf_LIB_DIRS_DEBUG} ${Protobuf_LIB_DIRS_RELWITHDEBINFO} ${Protobuf_LIB_DIRS_MINSIZEREL})\n" + "string(REPLACE \";\" \":\" CUSTOM_DYLD_LIBRARY_PATH ${CUSTOM_DYLD_LIBRARY_PATH})\n" + "add_custom_command(") + ) tools.replace_in_file( protobuf_config_cmake, "COMMAND protobuf::protoc", - ("COMMAND export DYLD_LIBRARY_PATH={}\n" - "COMMAND protobuf::protoc").format(protobuf_lib_path), + ("COMMAND export DYLD_LIBRARY_PATH=${CUSTOM_DYLD_LIBRARY_PATH}\n" + "COMMAND protobuf::protoc") ) # Disable a potential warning in protobuf-module.cmake.in From 5df0f0892f1bd2787517708b876ec51a621b0c8a Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Wed, 3 Mar 2021 20:02:18 +0100 Subject: [PATCH 05/27] append to builddirs --- recipes/protobuf/all/conanfile.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 832fc7a757e29..a5c216ab1503a 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -183,11 +183,9 @@ def package_info(self): if self.options.shared: self.cpp_info.components["libprotobuf"].defines = ["PROTOBUF_USE_DLLS"] - self.cpp_info.components["libprotobuf"].builddirs = [ - self._cmake_install_base_path, - ] + self.cpp_info.components["libprotobuf"].builddirs.append(self._cmake_install_base_path) - self.cpp_info.components["libprotobuf"].builddirs = [self._cmake_install_base_path] + self.cpp_info.components["libprotobuf"].builddirs.append(self._cmake_install_base_path) self.cpp_info.components["libprotobuf"].build_modules.extend([ os.path.join(self._cmake_install_base_path, "protobuf-generate.cmake"), os.path.join(self._cmake_install_base_path, "protobuf-module.cmake"), @@ -215,7 +213,7 @@ def package_info(self): if self.options.shared: self.cpp_info.components["libprotobuf-lite"].defines = ["PROTOBUF_USE_DLLS"] - self.cpp_info.components["libprotobuf-lite"].builddirs = [self._cmake_install_base_path] + self.cpp_info.components["libprotobuf-lite"].builddirs.append(self._cmake_install_base_path) self.cpp_info.components["libprotobuf-lite"].build_modules.extend([ os.path.join(self._cmake_install_base_path, "protobuf-generate.cmake"), os.path.join(self._cmake_install_base_path, "protobuf-module.cmake"), From 0913f5fab9641476a393685ec3cd5e6050d0fdb7 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Wed, 3 Mar 2021 20:51:36 +0100 Subject: [PATCH 06/27] cleanup --- recipes/protobuf/all/conanfile.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index a5c216ab1503a..d97d3f1c9c81a 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -182,15 +182,12 @@ def package_info(self): if self.settings.os == "Windows": if self.options.shared: self.cpp_info.components["libprotobuf"].defines = ["PROTOBUF_USE_DLLS"] - - self.cpp_info.components["libprotobuf"].builddirs.append(self._cmake_install_base_path) - self.cpp_info.components["libprotobuf"].builddirs.append(self._cmake_install_base_path) - self.cpp_info.components["libprotobuf"].build_modules.extend([ + self.cpp_info.components["libprotobuf"].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"), - ]) + ] self.cpp_info.components["libprotoc"].name = "libprotoc" self.cpp_info.components["libprotoc"].libs = [lib_prefix + "protoc" + lib_suffix] @@ -214,8 +211,8 @@ def package_info(self): self.cpp_info.components["libprotobuf-lite"].defines = ["PROTOBUF_USE_DLLS"] self.cpp_info.components["libprotobuf-lite"].builddirs.append(self._cmake_install_base_path) - self.cpp_info.components["libprotobuf-lite"].build_modules.extend([ + self.cpp_info.components["libprotobuf-lite"].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"), - ]) + ] From 725d9d4b09104cc61bbceccf371c01d357c31c21 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Wed, 3 Mar 2021 22:31:17 +0100 Subject: [PATCH 07/27] fix semicolon replacement --- 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 d97d3f1c9c81a..5c22640f6236a 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -114,7 +114,7 @@ def _patch_sources(self): protobuf_config_cmake, "add_custom_command(", ("set(CUSTOM_DYLD_LIBRARY_PATH ${CONAN_LIB_DIRS} ${Protobuf_LIB_DIRS} ${Protobuf_LIB_DIRS_RELEASE} ${Protobuf_LIB_DIRS_DEBUG} ${Protobuf_LIB_DIRS_RELWITHDEBINFO} ${Protobuf_LIB_DIRS_MINSIZEREL})\n" - "string(REPLACE \";\" \":\" CUSTOM_DYLD_LIBRARY_PATH ${CUSTOM_DYLD_LIBRARY_PATH})\n" + "string(REPLACE \";\" \":\" CUSTOM_DYLD_LIBRARY_PATH \"${CUSTOM_DYLD_LIBRARY_PATH}\")\n" "add_custom_command(") ) tools.replace_in_file( From d879ac259b78c3fc7ae064245b03c5c02284a044 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Thu, 4 Mar 2021 12:42:53 +0100 Subject: [PATCH 08/27] more robust DYLD_LIBRARY_PATH injection --- recipes/protobuf/all/conanfile.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 5c22640f6236a..4a1bb51cbe00c 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -120,8 +120,7 @@ def _patch_sources(self): tools.replace_in_file( protobuf_config_cmake, "COMMAND protobuf::protoc", - ("COMMAND export DYLD_LIBRARY_PATH=${CUSTOM_DYLD_LIBRARY_PATH}\n" - "COMMAND protobuf::protoc") + "COMMAND ${CMAKE_COMMAND} -E env \"DYLD_LIBRARY_PATH=${CUSTOM_DYLD_LIBRARY_PATH}\" ${PROTOC_FULL_PATH}" ) # Disable a potential warning in protobuf-module.cmake.in From c2c6033bd1876f6a4e0e950f49dcf564a0b946b5 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Thu, 4 Mar 2021 14:28:48 +0100 Subject: [PATCH 09/27] cosmetic change --- recipes/protobuf/all/conanfile.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 4a1bb51cbe00c..e6ed1bcd39687 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -1,8 +1,6 @@ -import os -import glob from conans import ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration -from conans.tools import Version +import os class ProtobufConan(ConanFile): @@ -13,13 +11,25 @@ class ProtobufConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/protocolbuffers/protobuf" license = "BSD-3-Clause" - exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake" - short_paths = True + settings = "os", "arch", "compiler", "build_type" - options = {"shared": [True, False], "with_zlib": [True, False], "fPIC": [True, False], "lite": [True, False]} - default_options = {"with_zlib": False, "shared": False, "fPIC": True, "lite": False} + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_zlib": [True, False], + "lite": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "with_zlib": False, + "lite": False, + } + + short_paths = True + exports_sources = ["CMakeLists.txt", "patches/*"] + generators = "cmake" _cmake = None @property @@ -46,7 +56,7 @@ def configure(self): raise ConanInvalidConfiguration("Protobuf can't be built with shared + MT(d) runtimes") if self.settings.compiler == "Visual Studio": - if Version(self.settings.compiler.version) < "14": + if tools.Version(self.settings.compiler.version) < "14": raise ConanInvalidConfiguration("On Windows Protobuf can only be built with " "Visual Studio 2015 or higher.") From ab34548a3a4b78c1830f9f358098370acc89d38b Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Thu, 4 Mar 2021 14:32:57 +0100 Subject: [PATCH 10/27] improve runtime handling --- recipes/protobuf/all/conanfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index e6ed1bcd39687..faba82615929b 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -52,7 +52,7 @@ def configure(self): if self.options.shared: del self.options.fPIC - if self.settings.compiler.get_safe("runtime") in ["MT", "MTd"]: + if str(self.settings.compiler.get_safe("runtime")) in ["MT", "MTd", "static"]: raise ConanInvalidConfiguration("Protobuf can't be built with shared + MT(d) runtimes") if self.settings.compiler == "Visual Studio": @@ -81,8 +81,8 @@ def _configure_cmake(self): self._cmake.definitions["protobuf_BUILD_TESTS"] = False self._cmake.definitions["protobuf_BUILD_PROTOC_BINARIES"] = True self._cmake.definitions["protobuf_BUILD_LIBPROTOC"] = True - if self.settings.compiler == "Visual Studio": - self._cmake.definitions["protobuf_MSVC_STATIC_RUNTIME"] = "MT" in str(self.settings.compiler.runtime) + if self.settings.compiler.get_safe("runtime"): + self._cmake.definitions["protobuf_MSVC_STATIC_RUNTIME"] = str(self.settings.compiler.runtime) in ["MT", "MTd", "static"] self._cmake.configure(build_folder=self._build_subfolder) return self._cmake From 0408def08fa2144488485f92887947accc95517b Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Thu, 4 Mar 2021 14:33:45 +0100 Subject: [PATCH 11/27] no protobuf_BUILD_LIBPROTOC option before 3.14.0 --- recipes/protobuf/all/conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index faba82615929b..f0a8ea53cd1f4 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -80,7 +80,8 @@ def _configure_cmake(self): self._cmake.definitions["protobuf_WITH_ZLIB"] = self.options.with_zlib self._cmake.definitions["protobuf_BUILD_TESTS"] = False self._cmake.definitions["protobuf_BUILD_PROTOC_BINARIES"] = True - self._cmake.definitions["protobuf_BUILD_LIBPROTOC"] = True + if tools.Version(self.version) >= "3.14.0": + self._cmake.definitions["protobuf_BUILD_LIBPROTOC"] = True if self.settings.compiler.get_safe("runtime"): self._cmake.definitions["protobuf_MSVC_STATIC_RUNTIME"] = str(self.settings.compiler.runtime) in ["MT", "MTd", "static"] self._cmake.configure(build_folder=self._build_subfolder) From f5a965dbbeed02e857ab09ab33cbeb3fcd8e0496 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Thu, 4 Mar 2021 14:41:42 +0100 Subject: [PATCH 12/27] honor upstream default value for with_zlib --- 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 f0a8ea53cd1f4..e457eb8f656a1 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -22,7 +22,7 @@ class ProtobufConan(ConanFile): default_options = { "shared": False, "fPIC": True, - "with_zlib": False, + "with_zlib": True, "lite": False, } From a7d67600017d2dde8ba811efdbfdad0c94157a62 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Thu, 4 Mar 2021 14:49:47 +0100 Subject: [PATCH 13/27] add protobuf/3.15.4 --- recipes/protobuf/all/conandata.yml | 15 +++++++++------ recipes/protobuf/all/conanfile.py | 2 ++ recipes/protobuf/config.yml | 10 ++++++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/recipes/protobuf/all/conandata.yml b/recipes/protobuf/all/conandata.yml index c3ba8d116ec39..c50cb48a13da2 100644 --- a/recipes/protobuf/all/conandata.yml +++ b/recipes/protobuf/all/conandata.yml @@ -1,22 +1,25 @@ sources: - 3.9.1: + "3.9.1": sha256: 98e615d592d237f94db8bf033fba78cd404d979b0b70351a9e5aaff725398357 url: https://github.com/protocolbuffers/protobuf/archive/v3.9.1.tar.gz - 3.11.4: + "3.11.4": sha256: a79d19dcdf9139fa4b81206e318e33d245c4c9da1ffed21c87288ed4380426f9 url: https://github.com/protocolbuffers/protobuf/archive/v3.11.4.tar.gz - 3.12.4: + "3.12.4": sha256: 512e5a674bf31f8b7928a64d8adf73ee67b8fe88339ad29adaa3b84dbaa570d8 url: https://github.com/protocolbuffers/protobuf/archive/v3.12.4.tar.gz - 3.13.0: + "3.13.0": sha256: 9b4ee22c250fe31b16f1a24d61467e40780a3fbb9b91c3b65be2a376ed913a1a url: https://github.com/protocolbuffers/protobuf/archive/v3.13.0.tar.gz + "3.15.4": + sha256: 07f8a02afc14a657f727ed89a8ec5627b9ecc47116d60acaabaa1da233bd2e8f + url: https://github.com/protocolbuffers/protobuf/archive/v3.15.4.tar.gz patches: - 3.12.4: + "3.12.4": - patch_file: "patches/upstream-pr-7761-cmake-regex-fix.patch" base_path: "source_subfolder" - patch_file: "patches/upstream-issue-7567-no-export-template-define.patch" base_path: "source_subfolder" - 3.13.0: + "3.13.0": - patch_file: "patches/upstream-pr-7761-cmake-regex-fix.patch" base_path: "source_subfolder" diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index e457eb8f656a1..8eb1ccf42d237 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -82,6 +82,8 @@ def _configure_cmake(self): self._cmake.definitions["protobuf_BUILD_PROTOC_BINARIES"] = True if tools.Version(self.version) >= "3.14.0": self._cmake.definitions["protobuf_BUILD_LIBPROTOC"] = True + if tools.Version(self.version) >= "3.15.4": + self._cmake.definitions["protobuf_DISABLE_RTTI"] = True # TODO: create an option for 3.15.4+? if self.settings.compiler.get_safe("runtime"): self._cmake.definitions["protobuf_MSVC_STATIC_RUNTIME"] = str(self.settings.compiler.runtime) in ["MT", "MTd", "static"] self._cmake.configure(build_folder=self._build_subfolder) diff --git a/recipes/protobuf/config.yml b/recipes/protobuf/config.yml index 0899537fde3dc..5497a64cc6d8c 100644 --- a/recipes/protobuf/config.yml +++ b/recipes/protobuf/config.yml @@ -1,9 +1,11 @@ versions: - 3.9.1: + "3.9.1": folder: all - 3.11.4: + "3.11.4": folder: all - 3.12.4: + "3.12.4": folder: all - 3.13.0: + "3.13.0": + folder: all + "3.15.4": folder: all From 10ac43a0b7662ac4ae22f1cbfe7bb2f14a528640 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Thu, 4 Mar 2021 16:54:53 +0100 Subject: [PATCH 14/27] provide Protobuf_PROTOC_EXECUTABLE CACHE variable --- recipes/protobuf/all/conanfile.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 8eb1ccf42d237..200dc8a63f371 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -93,7 +93,7 @@ def _patch_sources(self): for patch in self.conan_data.get("patches", {}).get(self.version, []): tools.patch(**patch) - # Inject relocatable protobuf::protoc target in protobuf-config.cmake.in + # Provide relocatable protobuf::protoc target and Protobuf_PROTOC_EXECUTABLE cache variable # TODO: some of the following logic might be disabled when conan will # allow to create executable imported targets in package_info() protobuf_config_cmake = os.path.join(self._source_subfolder, "cmake", "protobuf-config.cmake.in") @@ -111,10 +111,11 @@ def _patch_sources(self): tools.replace_in_file( protobuf_config_cmake, "include(\"${CMAKE_CURRENT_LIST_DIR}/protobuf-targets.cmake\")", - ("if(NOT TARGET protobuf::protoc)\n" - " add_executable(protobuf::protoc IMPORTED)\n" - " get_filename_component(PROTOC_FULL_PATH \"${{CMAKE_CURRENT_LIST_DIR}}/{protoc_rel_path}\" ABSOLUTE)\n" - " set_property(TARGET protobuf::protoc PROPERTY IMPORTED_LOCATION ${{PROTOC_FULL_PATH}})\n" + ("get_filename_component(PROTOC_FULL_PATH \"${{CMAKE_CURRENT_LIST_DIR}}/{protoc_rel_path}\" ABSOLUTE)\n" + "set(Protobuf_PROTOC_EXECUTABLE ${{PROTOC_FULL_PATH}} CACHE FILEPATH \"The protoc compiler\")\n" + "if(NOT TARGET protobuf::protoc)\n" + " add_executable(protobuf::protoc IMPORTED)\n" + " set_property(TARGET protobuf::protoc PROPERTY IMPORTED_LOCATION ${{Protobuf_PROTOC_EXECUTABLE}})\n" "endif()" ).format(protoc_rel_path=protoc_rel_path) ) @@ -133,7 +134,7 @@ def _patch_sources(self): tools.replace_in_file( protobuf_config_cmake, "COMMAND protobuf::protoc", - "COMMAND ${CMAKE_COMMAND} -E env \"DYLD_LIBRARY_PATH=${CUSTOM_DYLD_LIBRARY_PATH}\" ${PROTOC_FULL_PATH}" + "COMMAND ${CMAKE_COMMAND} -E env \"DYLD_LIBRARY_PATH=${CUSTOM_DYLD_LIBRARY_PATH}\" ${Protobuf_PROTOC_EXECUTABLE}" ) # Disable a potential warning in protobuf-module.cmake.in From abb921f37dc4ef5b86a90d9b3f84a7382e2b741b Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Thu, 4 Mar 2021 17:01:11 +0100 Subject: [PATCH 15/27] trick to no break pkg_config generator internal handling in conan --- recipes/protobuf/all/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 200dc8a63f371..f9995c6b8d399 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -178,6 +178,7 @@ def package_info(self): self.cpp_info.names["cmake_find_package"] = "protobuf" self.cpp_info.names["cmake_find_package_multi"] = "protobuf" + self.cpp_info.names["pkg_config"] = "protobuf_full_package" # unofficial, but required to avoid side effects (libprotobuf component "steals" the default global pkg_config name) lib_prefix = "lib" if self.settings.compiler == "Visual Studio" else "" lib_suffix = "d" if self.settings.build_type == "Debug" else "" From dc170c4f24b0b575c9a53298973b50550693e184 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Thu, 4 Mar 2021 20:43:47 +0100 Subject: [PATCH 16/27] workaround for invalid-constexpr with clang --- recipes/protobuf/all/conanfile.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index f9995c6b8d399..4b2d5fb783c75 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -86,6 +86,10 @@ def _configure_cmake(self): self._cmake.definitions["protobuf_DISABLE_RTTI"] = True # TODO: create an option for 3.15.4+? if self.settings.compiler.get_safe("runtime"): self._cmake.definitions["protobuf_MSVC_STATIC_RUNTIME"] = str(self.settings.compiler.runtime) in ["MT", "MTd", "static"] + if self.settings.compiler == "clang": + # Required at least for 3.15.4 + self._cmake.definitions["CMAKE_C_FLAGS"] = "-Wno-invalid-constexpr" + self._cmake.definitions["CMAKE_CXX_FLAGS"] = "-Wno-invalid-constexpr" self._cmake.configure(build_folder=self._build_subfolder) return self._cmake From 610126daa2f527bc30c542b31f8e9c9f6c2d05d3 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Fri, 5 Mar 2021 01:04:34 +0100 Subject: [PATCH 17/27] clang < 4 not supported in recent protobuf --- recipes/protobuf/all/conanfile.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 4b2d5fb783c75..64b98bcde4135 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -60,6 +60,10 @@ def configure(self): raise ConanInvalidConfiguration("On Windows Protobuf can only be built with " "Visual Studio 2015 or higher.") + if self.settings.compiler == "clang": + if tools.Version(self.version) >= "3.15.4" and tools.Version(self.settings.compiler.version) < "4": + raise ConanInvalidConfiguration("protobuf {} doesn't support clang < 4".format(self.version)) + def requirements(self): if self.options.with_zlib: self.requires("zlib/1.2.11") From d877dc5ba4faf5234ea840f0ea1a261b8d792bb3 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Fri, 5 Mar 2021 01:05:52 +0100 Subject: [PATCH 18/27] cleanup --- 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 eb53c00983cf2..43ed795d5e8c8 100644 --- a/recipes/protobuf/all/test_package/conanfile.py +++ b/recipes/protobuf/all/test_package/conanfile.py @@ -1,4 +1,4 @@ -from conans import ConanFile, CMake, RunEnvironment, tools +from conans import ConanFile, CMake, tools import os From af51bdba3b41e32d39747c449e0292888c42afaf Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Fri, 5 Mar 2021 02:20:28 +0100 Subject: [PATCH 19/27] do not disable rtti by default --- 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 64b98bcde4135..04c9c402261d1 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -87,7 +87,7 @@ def _configure_cmake(self): if tools.Version(self.version) >= "3.14.0": self._cmake.definitions["protobuf_BUILD_LIBPROTOC"] = True if tools.Version(self.version) >= "3.15.4": - self._cmake.definitions["protobuf_DISABLE_RTTI"] = True # TODO: create an option for 3.15.4+? + self._cmake.definitions["protobuf_DISABLE_RTTI"] = False # TODO: create an option for 3.15.4+? if self.settings.compiler.get_safe("runtime"): self._cmake.definitions["protobuf_MSVC_STATIC_RUNTIME"] = str(self.settings.compiler.runtime) in ["MT", "MTd", "static"] if self.settings.compiler == "clang": From 55a8007766d6c520df958e4d246ce6602ed6a1f7 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Fri, 5 Mar 2021 08:51:38 +0100 Subject: [PATCH 20/27] Revert "workaround for invalid-constexpr with clang" This reverts commit dc170c4f24b0b575c9a53298973b50550693e184. --- recipes/protobuf/all/conanfile.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 04c9c402261d1..98c44bb72cafc 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -90,10 +90,6 @@ def _configure_cmake(self): self._cmake.definitions["protobuf_DISABLE_RTTI"] = False # TODO: create an option for 3.15.4+? if self.settings.compiler.get_safe("runtime"): self._cmake.definitions["protobuf_MSVC_STATIC_RUNTIME"] = str(self.settings.compiler.runtime) in ["MT", "MTd", "static"] - if self.settings.compiler == "clang": - # Required at least for 3.15.4 - self._cmake.definitions["CMAKE_C_FLAGS"] = "-Wno-invalid-constexpr" - self._cmake.definitions["CMAKE_CXX_FLAGS"] = "-Wno-invalid-constexpr" self._cmake.configure(build_folder=self._build_subfolder) return self._cmake From 72f94bf650faa1a160bc99618633eec012765b14 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Fri, 5 Mar 2021 08:54:48 +0100 Subject: [PATCH 21/27] remove useless test of find_program --- 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 4fa906bb74e70..1c4669f524a5f 100644 --- a/recipes/protobuf/all/test_package/CMakeLists.txt +++ b/recipes/protobuf/all/test_package/CMakeLists.txt @@ -6,11 +6,6 @@ conan_basic_setup(TARGETS) find_package(protobuf CONFIG REQUIRED) -find_program(PROTOC_PROGRAM protoc) -if (NOT PROTOC_PROGRAM) - message(WARNING "Protoc was not found") -endif() - add_executable(${PROJECT_NAME} test_package.cpp addressbook.proto) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) target_include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_BINARY_DIR}") From 427035bbab7f63f713771b93b4164390c98fe717 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Fri, 5 Mar 2021 09:17:34 +0100 Subject: [PATCH 22/27] use TARGET_FILE in apple patch --- 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 98c44bb72cafc..c7fe047e47fd3 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -138,7 +138,7 @@ def _patch_sources(self): tools.replace_in_file( protobuf_config_cmake, "COMMAND protobuf::protoc", - "COMMAND ${CMAKE_COMMAND} -E env \"DYLD_LIBRARY_PATH=${CUSTOM_DYLD_LIBRARY_PATH}\" ${Protobuf_PROTOC_EXECUTABLE}" + "COMMAND ${CMAKE_COMMAND} -E env \"DYLD_LIBRARY_PATH=${CUSTOM_DYLD_LIBRARY_PATH}\" $" ) # Disable a potential warning in protobuf-module.cmake.in From b3d5a0c7dc73fb2316281661d142b4dfadc92177 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Fri, 5 Mar 2021 09:20:59 +0100 Subject: [PATCH 23/27] add 3.15.5 instead of 3.15.4 --- 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 c50cb48a13da2..29ab3c36b596f 100644 --- a/recipes/protobuf/all/conandata.yml +++ b/recipes/protobuf/all/conandata.yml @@ -11,9 +11,9 @@ sources: "3.13.0": sha256: 9b4ee22c250fe31b16f1a24d61467e40780a3fbb9b91c3b65be2a376ed913a1a url: https://github.com/protocolbuffers/protobuf/archive/v3.13.0.tar.gz - "3.15.4": - sha256: 07f8a02afc14a657f727ed89a8ec5627b9ecc47116d60acaabaa1da233bd2e8f - url: https://github.com/protocolbuffers/protobuf/archive/v3.15.4.tar.gz + "3.15.5": + sha256: bc3dbf1f09dba1b2eb3f2f70352ee97b9049066c9040ce0c9b67fb3294e91e4b + url: https://github.com/protocolbuffers/protobuf/archive/v3.15.5.tar.gz patches: "3.12.4": - patch_file: "patches/upstream-pr-7761-cmake-regex-fix.patch" diff --git a/recipes/protobuf/config.yml b/recipes/protobuf/config.yml index 5497a64cc6d8c..797ab9e4d0664 100644 --- a/recipes/protobuf/config.yml +++ b/recipes/protobuf/config.yml @@ -7,5 +7,5 @@ versions: folder: all "3.13.0": folder: all - "3.15.4": + "3.15.5": folder: all From 3a565443a21718d508a96757d95894c588a2461b Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Sun, 7 Mar 2021 18:38:26 +0100 Subject: [PATCH 24/27] add rtti option if protobuf >= 3.15.4 --- recipes/protobuf/all/conanfile.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index c7fe047e47fd3..4482a71c790f8 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -17,12 +17,14 @@ class ProtobufConan(ConanFile): "shared": [True, False], "fPIC": [True, False], "with_zlib": [True, False], + "rtti": [True, False], "lite": [True, False], } default_options = { "shared": False, "fPIC": True, "with_zlib": True, + "rtti": True, "lite": False, } @@ -44,9 +46,15 @@ def _build_subfolder(self): def _is_clang_x86(self): return self.settings.compiler == "clang" and self.settings.arch == "x86" + @property + def _has_rtti_option(self): + return tools.Version(self.version) >= "3.15.4" + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if not self._has_rtti_option: + del self.options.rtti def configure(self): if self.options.shared: @@ -86,8 +94,8 @@ def _configure_cmake(self): self._cmake.definitions["protobuf_BUILD_PROTOC_BINARIES"] = True if tools.Version(self.version) >= "3.14.0": self._cmake.definitions["protobuf_BUILD_LIBPROTOC"] = True - if tools.Version(self.version) >= "3.15.4": - self._cmake.definitions["protobuf_DISABLE_RTTI"] = False # TODO: create an option for 3.15.4+? + if self._has_rtti_option: + self._cmake.definitions["protobuf_DISABLE_RTTI"] = not self.options.rtti if self.settings.compiler.get_safe("runtime"): self._cmake.definitions["protobuf_MSVC_STATIC_RUNTIME"] = str(self.settings.compiler.runtime) in ["MT", "MTd", "static"] self._cmake.configure(build_folder=self._build_subfolder) From 4de7716ac0764cf0e1a257097facaa5812f7258b Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Thu, 11 Mar 2021 16:55:52 +0100 Subject: [PATCH 25/27] removed duplicated version --- recipes/protobuf/config.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/recipes/protobuf/config.yml b/recipes/protobuf/config.yml index 158a39e1ccbf5..797ab9e4d0664 100644 --- a/recipes/protobuf/config.yml +++ b/recipes/protobuf/config.yml @@ -9,5 +9,3 @@ versions: folder: all "3.15.5": folder: all - 3.15.5: - folder: all From a46fe2d549b60a83fc28026a93051cc0c783f60d Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Fri, 19 Mar 2021 14:53:01 +0100 Subject: [PATCH 26/27] empty commit From a0f4c761d7f44167961a272a407d215a439e086c Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Sun, 21 Mar 2021 14:14:47 +0100 Subject: [PATCH 27/27] keep find_program protoc logic for cross compilation --- recipes/protobuf/all/conanfile.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 921870f56b404..4258311d65c56 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -1,6 +1,7 @@ from conans import ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration import os +import textwrap class ProtobufConan(ConanFile): @@ -120,16 +121,22 @@ def _patch_sources(self): 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_target = textwrap.dedent("""\ + if(NOT TARGET protobuf::protoc) + find_program(PROTOC_PROGRAM protoc PATHS ENV PATH NO_DEFAULT_PATH) + if(NOT PROTOC_PROGRAM) + set(PROTOC_PROGRAM \"${{CMAKE_CURRENT_LIST_DIR}}/{protoc_rel_path}\") + endif() + get_filename_component(PROTOC_PROGRAM \"${{PROTOC_PROGRAM}}\" ABSOLUTE) + set(Protobuf_PROTOC_EXECUTABLE ${{PROTOC_PROGRAM}} CACHE FILEPATH \"The protoc compiler\") + add_executable(protobuf::protoc IMPORTED) + set_property(TARGET protobuf::protoc PROPERTY IMPORTED_LOCATION ${{Protobuf_PROTOC_EXECUTABLE}}) + endif() + """.format(protoc_rel_path=protoc_rel_path)) tools.replace_in_file( protobuf_config_cmake, "include(\"${CMAKE_CURRENT_LIST_DIR}/protobuf-targets.cmake\")", - ("get_filename_component(PROTOC_FULL_PATH \"${{CMAKE_CURRENT_LIST_DIR}}/{protoc_rel_path}\" ABSOLUTE)\n" - "set(Protobuf_PROTOC_EXECUTABLE ${{PROTOC_FULL_PATH}} CACHE FILEPATH \"The protoc compiler\")\n" - "if(NOT TARGET protobuf::protoc)\n" - " add_executable(protobuf::protoc IMPORTED)\n" - " set_property(TARGET protobuf::protoc PROPERTY IMPORTED_LOCATION ${{Protobuf_PROTOC_EXECUTABLE}})\n" - "endif()" - ).format(protoc_rel_path=protoc_rel_path) + protoc_target ) # Set DYLD_LIBRARY_PATH in command line to avoid issues with shared protobuf