I’m trying to build gRPC (cpp) using CMake, but running into errors. I am able to successfully build gRPC with make
per the instructions on the gRPC cpp page. Using make
is deprecated, but CMake isn’t working for me.
After following the instructions for downloading, cloning etc., I go to the “Building with CMake”, where it says for Linux/Unix, do this:
$ mkdir -p cmake/build $ cd cmake/build $ cmake ../.. $ make
For me, it fails at the 3rd line (cmake
). The following is the output:
$ cmake ../.. -- The C compiler identification is GNU 7.4.0 -- The CXX compiler identification is GNU 7.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Error at CMakeLists.txt:138 (include): include could not find load file: cmake/zlib.cmake < repeats above error for the following .cmake files: cares, protobuf, ssl, gflags, benchmark, address_sorting and nanopb>
Those files (cmake/<package name>.cmake
) don’t exist in the cmake/
directory on my system. I’m not sure what in the CMakeLists.txt file would cause them to appear there.
Researching this issue, I tried various combinations of cmake
options such as -DBUILD_SHARED_LIBS=ON
, -DgRPC_INSTALL=ON
, and -DgRPC<package_name>_PROVIDER=package
for each of the fails listed above. I always get the same errors. Finally, I tried running the run_distrib_test_cmake.sh
script. It eventually failed the same way.
Any ideas?
Advertisement
Answer
The third party CMake files (e.g. cmake/zlib.cmake
) do exist in the GitHub repository you cloned (see here). Please be sure your repository finished cloning completely, to include all of the submodules, per the gRPC build documentation:
Run from grpc directory after cloning the repo with –recursive or updating submodules.
$ mkdir -p cmake/build $ cd cmake/build $ cmake ../.. $ make
So be sure everything is cloned with:
git checkout --recurse-submodules
or
git submodule update --recursive