Search code examples
google-cloud-platformcmakegoogle-cloud-cpp

CMake of google-cloud-cpp Fails


The CMake build of google-cloud-cpp fails with this error:

$ cmake -H. -Bcmake-out
-- The CXX compiler identification is GNU 9.3.0
-- The C compiler identification is GNU 9.3.0
-- 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
-- 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
CMake Error at google/cloud/storage/CMakeLists.txt:17 (find_package):
  Could not find a package configuration file provided by
  "google_cloud_cpp_common" with any of the following names:

    google_cloud_cpp_commonConfig.cmake
    google_cloud_cpp_common-config.cmake

  Add the installation prefix of "google_cloud_cpp_common" to
  CMAKE_PREFIX_PATH or set "google_cloud_cpp_common_DIR" to a directory
  containing one of the above files.  If "google_cloud_cpp_common" provides a
  separate development package or SDK, be sure it has been installed.


-- Configuring incomplete, errors occurred!

Solution

  • The CMake command:

    cmake -H. -Bcmake-out
    

    will only work well after you have installed all of the google-cloud-cpp dependencies. From the INSTALL.md file:

    If all the dependencies of google-cloud-cpp are installed and provide CMake support files, then compiling and installing the libraries requires two commands:

    cmake -H. -Bcmake-out
    cmake --build cmake-out --target install
    

    Unfortunately getting your system to this state may require multiple steps, the following sections describe how to install google-cloud-cpp on several platforms.

    It goes on to describe how to install each of the dependencies individually, for several platforms. This is a painful process, but an easier approach is use the suggested CMake super-build, described in the main README.md file. This will download and build all of the google-cloud-cpp dependencies for you. Try the CMake super-build command instead:

    cmake -Hsuper -Bcmake-out