Skip to content

Commit

Permalink
(#5404) [grpc] Use build_modules to find executable grpc_cpp_plugin
Browse files Browse the repository at this point in the history
* [google-cloud-cpp] Add library

* start to work on deps

* exclude tests, use config for CMake packages

* Add build module to find grpc_cpp_plugin

* [crc32c] Add recipe

* add crc32c dep

* update grpc

* remove, not for this PR

* [grpc] Use build_modules to find the grcp_cpp_plugin

* Update recipes/grpc/all/conanfile.py

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* grpc: add version 1.37.1 (#6)

Generated and committed by [Conan Center Bot](https://github.com/qchateau/conan-center-bot)
Find more updatable recipes in the [GitHub Pages](https://qchateau.github.io/conan-center-bot/)

Co-authored-by: Quentin Chateau via Conan Center Bot <quentin.chateau@gmail.com>

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
Co-authored-by: Quentin Chateau via Conan Center Bot <quentin.chateau@gmail.com>
  • Loading branch information
3 people authored May 5, 2021
1 parent a46a4a6 commit 74588f1
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 9 deletions.
18 changes: 18 additions & 0 deletions recipes/grpc/all/cmake/grpc_cpp_plugin.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
if(NOT TARGET gRPC::grpc_cpp_plugin)
if(CMAKE_CROSSCOMPILING)
find_program(GRPC_CPP_PLUGIN_PROGRAM
NAMES grpc_cpp_plugin
PATHS ENV
PATH NO_DEFAULT_PATH)
else()
find_program(GRPC_CPP_PLUGIN_PROGRAM
NAMES grpc_cpp_plugin
PATHS "${CMAKE_CURRENT_LIST_DIR}/../../bin/"
NO_DEFAULT_PATH)
endif()

get_filename_component(GRPC_CPP_PLUGIN_PROGRAM "${GRPC_CPP_PLUGIN_PROGRAM}" ABSOLUTE)

add_executable(gRPC::grpc_cpp_plugin IMPORTED)
set_property(TARGET gRPC::grpc_cpp_plugin PROPERTY IMPORTED_LOCATION ${GRPC_CPP_PLUGIN_PROGRAM})
endif()
3 changes: 3 additions & 0 deletions recipes/grpc/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"1.37.1":
url: "https://github.com/grpc/grpc/archive/v1.37.1.tar.gz"
sha256: "acf247ec3a52edaee5dee28644a4e485c5e5badf46bdb24a80ca1d76cb8f1174"
"1.37.0":
url: https://github.com/grpc/grpc/archive/refs/tags/v1.37.0.tar.gz
sha256: "c2dc8e876ea12052d6dd16704492fd8921df8c6d38c70c4708da332cf116df22"
10 changes: 8 additions & 2 deletions recipes/grpc/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class grpcConan(ConanFile):
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/grpc/grpc"
license = "Apache-2.0"
exports_sources = ["CMakeLists.txt"]
exports_sources = ["CMakeLists.txt", "cmake/*"]
generators = "cmake", "cmake_find_package", "cmake_find_package_multi"
short_paths = True

Expand Down Expand Up @@ -116,13 +116,15 @@ def build(self):
cmake.build()

def package(self):
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()

tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "share"))

self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
self.copy(pattern="*.cmake", dst=os.path.join("lib", "cmake"), src=os.path.join(self.source_folder, "cmake"))

def package_info(self):
bindir = os.path.join(self.package_folder, "bin")
Expand Down Expand Up @@ -232,6 +234,10 @@ def package_info(self):

# Executables
# gRPC::grpc_cpp_plugin
if self.options.cpp_plugin:
module_target_rel_path = os.path.join("lib", "cmake", "grpc_cpp_plugin.cmake")
self.cpp_info.components["execs"].build_modules["cmake_find_package"] = [module_target_rel_path]
self.cpp_info.components["execs"].build_modules["cmake_find_package_multi"] = [module_target_rel_path]
# gRPC::grpc_csharp_plugin
# gRPC::grpc_node_plugin
# gRPC::grpc_objective_c_plugin
Expand Down
3 changes: 1 addition & 2 deletions recipes/grpc/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ message(STATUS "Using protobuf ${protobuf_VERSION}")
# Find gRPC installation
find_package(gRPC CONFIG REQUIRED)
message(STATUS "Using gRPC ${gRPC_VERSION}")
# set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin ${CONAN_BIN_DIRS_GRPC} NO_DEFAULT_PATH)
set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)

# Proto file
get_filename_component(hw_proto "helloworld.proto" ABSOLUTE)
Expand Down
5 changes: 0 additions & 5 deletions recipes/grpc/all/test_package/greeter_client_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@
#include <thread>

#include <grpcpp/grpcpp.h>

#ifdef BAZEL_BUILD
#include "examples/protos/helloworld.grpc.pb.h"
#else
#include "helloworld.grpc.pb.h"
#endif

using grpc::Channel;
using grpc::ClientContext;
Expand Down
2 changes: 2 additions & 0 deletions recipes/grpc/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
versions:
"1.37.1":
folder: "all"
"1.37.0":
folder: "all"

0 comments on commit 74588f1

Please sign in to comment.