diff --git a/BUILDING.md b/BUILDING.md index 27d1b18a26e..4a8d1441301 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -172,13 +172,23 @@ If you want to build DLLs, run `cmake` with `-DBUILD_SHARED_LIBS=ON`. ### Dependency management -gRPC's CMake build system provides two modes for handling dependencies. -* module - build dependencies alongside gRPC. -* package - use external copies of dependencies that are already available -on your system. +gRPC's CMake build system has two options for handling dependencies. +CMake can build the dependencies for you, or it can search for libraries +that are already installed on your system and use them to build gRPC. This behavior is controlled by the `gRPC__PROVIDER` CMake variables, -ie `gRPC_CARES_PROVIDER`. +e.g. `gRPC_CARES_PROVIDER`. The options that these variables take are as follows: + +* module - build dependencies alongside gRPC. The source code is obtained from +gRPC's git submodules. +* package - use external copies of dependencies that are already available +on your system. These could come from your system package manager, or perhaps +you pre-installed them using CMake with the `CMAKE_INSTALL_PREFIX` option. + +For example, if you set `gRPC_CARES_PROVIDER=module`, then CMake will build +c-ares before building gRPC. On the other hand, if you set +`gRPC_CARES_PROVIDER=package`, then CMake will search for a copy of c-ares +that's already installed on your system and use it to build gRPC. ### Install after build diff --git a/src/cpp/README.md b/src/cpp/README.md index 3f1d4a6fcf8..4f2dbc6014b 100755 --- a/src/cpp/README.md +++ b/src/cpp/README.md @@ -70,18 +70,26 @@ also sets up an `add_subdirectory()` rule for you. This causes gRPC to be built as part of your project. ```cmake +cmake_minimum_required(VERSION 3.15) +project(my_project) + include(FetchContent) FetchContent_Declare( gRPC GIT_REPOSITORY https://github.com/grpc/grpc - GIT_TAG v1.25.0 + GIT_TAG RELEASE_TAG_HERE # e.g v1.28.0 ) +set(FETCHCONTENT_QUIET OFF) FetchContent_MakeAvailable(gRPC) add_executable(my_exe my_exe.cc) target_link_libraries(my_exe grpc++) ``` +Note that you need to +[install the prerequisites](../../BUILDING.md#pre-requisites) +before building gRPC. + ### git submodule If you cannot use FetchContent, another approach is to add the gRPC source tree to your project as a