I building a project that depends on gRPC. In the project I want to use gRPC, I'm using the following lines to find the package and add it as a dependency
# gRPC
find_package(gRPC CONFIG REQUIRED)
message(STATUS "Using gRPC ${gRPC_VERSION}")
#gRPC C++ plugin
find_program(gRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
In the above snippet, cmake fails while executing find_package
command and outputs the following error:
CMake Error at /usr/local/lib/cmake/grpc/gRPCConfig.cmake:15 (include):
include could not find load file:
/usr/local/lib/cmake/grpc/gRPCTargets.cmake
Call Stack (most recent call first):
src/CMakeLists.txt:15 (find_package)
I'm building the project inside a docker image where I've installed gRPC in the image, and the above error happens when trying to build the project that depends on it. This is how gRPC is installed in the Dockerfile
(following the documentation)
RUN cd /tmp && git clone --recurse-submodules -b v1.46.3 --depth 1 --shallow-submodules https://github.com/grpc/grpc && \
cd grpc && git submodule update --init && \
mkdir build && cd build && \
cmake -DgRPC_INSTALL=ON -DgRPC_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/usr/local .. && \
make -j8 && \
make install && \
ldconfig && \
make clean && \
cd ../.. && \
rm -r grpc
Looking at the source code for gRPCConfig.cmake
, it fails at the last line
(include(${CMAKE_CURRENT_LIST_DIR}/gRPCTargets.cmake)
It can't find the file gRPCTargets.cmake
and the file doesn't exist in the grpc repo.
Has anyone faced a similar issue? How can I fix this?