diff --git a/recipes/protobuf/all/conandata.yml b/recipes/protobuf/all/conandata.yml index c3ba8d116ec39..33e33f632156a 100644 --- a/recipes/protobuf/all/conandata.yml +++ b/recipes/protobuf/all/conandata.yml @@ -17,6 +17,14 @@ patches: base_path: "source_subfolder" - patch_file: "patches/upstream-issue-7567-no-export-template-define.patch" base_path: "source_subfolder" + - patch_file: "patches/upstream-pr-7288-android-log.patch" + base_path: "source_subfolder" + - patch_file: "patches/upstream-pr-8301-bundle-destination.patch" + base_path: "source_subfolder" 3.13.0: - patch_file: "patches/upstream-pr-7761-cmake-regex-fix.patch" base_path: "source_subfolder" + - patch_file: "patches/upstream-pr-7288-android-log.patch" + base_path: "source_subfolder" + - patch_file: "patches/upstream-pr-8301-bundle-destination.patch" + base_path: "source_subfolder" diff --git a/recipes/protobuf/all/conanfile.py b/recipes/protobuf/all/conanfile.py index 55acec5195834..7abfba728d0a4 100644 --- a/recipes/protobuf/all/conanfile.py +++ b/recipes/protobuf/all/conanfile.py @@ -86,7 +86,7 @@ def _patch_sources(self): find_protoc = """ # Find the protobuf compiler within the paths added by Conan, for use below. -find_program(PROTOC_PROGRAM protoc) +find_program(PROTOC_PROGRAM protoc PATHS ENV PATH NO_DEFAULT_PATH) if(NOT PROTOC_PROGRAM) set(PROTOC_PROGRAM "protoc") endif() @@ -177,6 +177,8 @@ def package_info(self): self.cpp_info.components["libprotobuf"].system_libs.append("pthread") if self._is_clang_x86 or "arm" in str(self.settings.arch): self.cpp_info.components["libprotobuf"].system_libs.append("atomic") + if self.settings.os == "Android": + self.cpp_info.components["libprotobuf"].system_libs.append("log") if self.settings.os == "Windows": if self.options.shared: self.cpp_info.components["libprotobuf"].defines = ["PROTOBUF_USE_DLLS"] @@ -215,6 +217,8 @@ def package_info(self): if self.settings.os == "Windows": if self.options.shared: self.cpp_info.components["libprotobuf-lite"].defines = ["PROTOBUF_USE_DLLS"] + if self.settings.os == "Android": + self.cpp_info.components["libprotobuf-lite"].system_libs.append("log") self.cpp_info.components["libprotobuf-lite"].builddirs = [self._cmake_install_base_path] self.cpp_info.components["libprotobuf-lite"].build_modules.extend([ diff --git a/recipes/protobuf/all/patches/upstream-pr-7288-android-log.patch b/recipes/protobuf/all/patches/upstream-pr-7288-android-log.patch new file mode 100644 index 0000000000000..ee8110a0c6e02 --- /dev/null +++ b/recipes/protobuf/all/patches/upstream-pr-7288-android-log.patch @@ -0,0 +1,26 @@ +https://github.com/protocolbuffers/protobuf/pull/7288 +--- a/cmake/libprotobuf.cmake ++++ b/cmake/libprotobuf.cmake +@@ -121,6 +121,9 @@ endif() + if(protobuf_LINK_LIBATOMIC) + target_link_libraries(libprotobuf atomic) + endif() ++if(${CMAKE_SYSTEM_NAME} STREQUAL "Android") ++ target_link_libraries(libprotobuf log) ++endif() + target_include_directories(libprotobuf PUBLIC ${protobuf_source_dir}/src) + if(MSVC AND protobuf_BUILD_SHARED_LIBS) + target_compile_definitions(libprotobuf + +--- a/cmake/libprotobuf-lite.cmake ++++ b/cmake/libprotobuf-lite.cmake +@@ -67,6 +67,9 @@ target_link_libraries(libprotobuf-lite ${CMAKE_THREAD_LIBS_INIT}) + if(protobuf_LINK_LIBATOMIC) + target_link_libraries(libprotobuf-lite atomic) + endif() ++if(${CMAKE_SYSTEM_NAME} STREQUAL "Android") ++ target_link_libraries(libprotobuf-lite log) ++endif() + target_include_directories(libprotobuf-lite PUBLIC ${protobuf_source_dir}/src) + if(MSVC AND protobuf_BUILD_SHARED_LIBS) + target_compile_definitions(libprotobuf-lite diff --git a/recipes/protobuf/all/patches/upstream-pr-8301-bundle-destination.patch b/recipes/protobuf/all/patches/upstream-pr-8301-bundle-destination.patch new file mode 100644 index 0000000000000..63aa4daaae4e4 --- /dev/null +++ b/recipes/protobuf/all/patches/upstream-pr-8301-bundle-destination.patch @@ -0,0 +1,11 @@ +--- a/cmake/install.cmake ++++ b/cmake/install.cmake +@@ -30,7 +30,7 @@ endforeach() + + if (protobuf_BUILD_PROTOC_BINARIES) + install(TARGETS protoc EXPORT protobuf-targets +- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc) ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc) + if (UNIX AND NOT APPLE) + set_property(TARGET protoc + PROPERTY INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") 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}") diff --git a/recipes/protobuf/all/test_package/conanfile.py b/recipes/protobuf/all/test_package/conanfile.py index eb53c00983cf2..65898b23a1bd1 100644 --- a/recipes/protobuf/all/test_package/conanfile.py +++ b/recipes/protobuf/all/test_package/conanfile.py @@ -6,12 +6,15 @@ class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" generators = "cmake", "cmake_find_package_multi" + def build_requirements(self): + if tools.cross_building(self.settings): + self.build_requires(str(self.requires['protobuf'])) + def build(self): - if not tools.cross_building(self.settings, skip_x64_x86=True): - cmake = CMake(self) - cmake.definitions["protobuf_LITE"] = self.options["protobuf"].lite - cmake.configure() - cmake.build() + cmake = CMake(self) + cmake.definitions["protobuf_LITE"] = self.options["protobuf"].lite + cmake.configure() + cmake.build() def test(self): if not tools.cross_building(self.settings):