I am having issues building the grpc
cpp
helloworld
example with cmake
.
I built and installed grpc
with cmake
initially, and then with make
directly.
I have found this issue raised by someone else in the past, which was closed as resolved.
It does not appear to be resolved and I opened a new issue for it, but I feel it will be some time until I get some help, so here I am.
The OP of the original issue offers a workaround with his FindGRPC cmake module, but I am not sure how is this suppose to help if gRPCTargets.cmake
is still missing.
I dropped FindGRPC.cmake
inside my cmake modules path, but nothing changes.
The error is this:
CMake Error at /usr/local/lib/cmake/grpc/gRPCConfig.cmake:8 (include):
include could not find load file:
/usr/local/lib/cmake/grpc/gRPCTargets.cmake
Call Stack (most recent call first):
CMakeLists.txt:73 (find_package)
-- Using gRPC 1.20.0
-- Configuring incomplete, errors occurred
I want to be able to use grpc
from my cmake projects without much hassle (using find_package(gRPC CONFIG REQUIRED)
)
EDIT:
When running cmake
on grpc
I get this error:
gRPC_INSTALL will be forced to FALSE because gRPC_ZLIB_PROVIDER is "module"
This is printed from zlib.cmake
:
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_ZLIB_PROVIDER is \"module\"")
Apparently all the providers must be "package"
as mentioned in grpc
's CMakeLists.txt
:
set(gRPC_INSTALL ${gRPC_INSTALL_default} CACHE BOOL
"Generate installation target: gRPC_ZLIB_PROVIDER, gRPC_CARES_PROVIDER, gRPC_SSL_PROVIDER and gRPC_PROTOBUF_PROVIDER must all be \"package\"")
I am not sure why zlib
is a module here though, or how make it a package.
Do I need to somehow to specify to cmake
to use the installed zlib instead of the submodule one?
The cause of this problem is explained at https://github.com/grpc/grpc/issues/13841:
Because of some limitations of our current CMakeLists.txt, the install targets (see gRPC_INSTALL option) will only be generated if you are building using a pre-installed version of our dependencies (gRPC_CARES_PROVIDER in your case needs to be set to package).
The warning you saw "gRPC_INSTALL will be forced to FALSE because gRPC_CARES_PROVIDER" is "module" basically tells you that even though gRPC_INSTALL was set to ON by you, we're setting it back to OFF because your gRPC_CARES_PROVIDER is set to use c-ares from git submodule (which wouldn't work well with the current CMakeLists.txt) - so you shouldn't expect anything to be installed (not even grpc_cpp_plugin.
To fix this issue, you should carefully look at the output when invoking cmake
. For every gRPC_*_PROVIDER
that is reported as "module", you should force it to "package" with -DgRPC_CARES_PROVIDER=package
(make sure to install the package as well, then!)
Or just force everything with the command-line linked in the issue:
cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DgRPC_PROTOBUF_PROVIDER=package -DgRPC_ZLIB_PROVIDER=package -DgRPC_CARES_PROVIDER=package -DgRPC_SSL_PROVIDER=package -DCMAKE_BUILD_TYPE=Release ../..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With