Skip to content

Commit

Permalink
review comments, fix some TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
jtattermusch committed Mar 12, 2020
1 parent 2aef52c commit 71a80c8
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions content/blog/2020-03-06-cmake-improvements.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ url: blog/cmake-improvements

For the past few months, [Kitware Inc.](https://www.kitware.com/) has been working with the gRPC team to improve gRPC’s CMake support. The goal of the effort was to modernize gRPC’s CMake build with the most current features and techniques CMake has to offer. This has improved the user experience for gRPC developers choosing to use gRPC’s CMake as a build system. During the effort the CMake build was looked at as a whole, and CMake related issues in GitHub were explored and resolved. A number of improvements were made that will give developers and end users a better experience when building gRPC with CMake.

One of the more exciting changes is the ability to seamlessly add gRPC to any CMake project and have all of its dependent libraries built using a simple CMake file. Prior to our recent changes this was a multi-step process. The user had to build and install each of gRPC’s dependencies separately, then build and install gRPC before finally building their own project. Now, this can all be done in one step. The following CMake code clones and builds the master branch of gRPC as documented [here](https://github.com/grpc/grpc/blob/master/src/cpp/README.md#cmake):
One of the more exciting changes is the ability to seamlessly add gRPC to any CMake project and have all of its dependent libraries built using a simple CMake file. Prior to our recent changes this was a multi-step process. The user had to build and install each of gRPC’s dependencies separately, then build and install gRPC before finally building their own project. Now, this can all be done in one step. The following CMake code clones and builds the latest stable release of gRPC as documented [here](https://github.com/grpc/grpc/blob/master/src/cpp/README.md#cmake):

TODO: try rendering the latest release version on the page?

```
```cmake
cmake_minimum_required(VERSION 3.15)
project(my_exe)
Expand All @@ -22,20 +20,20 @@ include(FetchContent)
FetchContent_Declare(
gRPC
GIT_REPOSITORY https://github.com/grpc/grpc
GIT_TAG master
GIT_TAG {{< param grpc_release_tag >}}
)
set(FETCHCONTENT_QUIET OFF)
FetchContent_MakeAvailable(gRPC)
add_executable(my_exe my_exe.cxx)
add_executable(my_exe my_exe.cc)
target_link_libraries(my_exe grpc++)
```

At configure time CMake uses git to clone the gRPC repository using the specified tag. Then gRPC will be added to the current CMake project via [add_subdirectory](https://cmake.org/cmake/help/latest/command/add_subdirectory.html) and built as part of the project.

## What has changed?

We have addressed many of the CMake-related issues on GitHub, with bug fixes, documentation updates, and new features.
We have addressed many of the CMake-related issues on GitHub, with bug fixes, documentation updates, and new features. All the fixes and features are available starting from gRPC 1.28.0 release.

- We’ve improved the documentation for [building gRPC from source](https://github.com/grpc/grpc/blob/master/BUILDING.md) and [adding gRPC as a dependency to your CMake project](https://github.com/grpc/grpc/blob/master/src/cpp/README.md#cmake) giving developers several options for using gRPC from CMake from simply linking to a pre-built gRPC to downloading and building gRPC as part of the project.
- The CMake build now generates pkgconfig (*.pc) files in the installation directory, just like the Makefile build. This allows for pkgconfig to correctly find and report a CMake built version of gRPC.
Expand All @@ -47,6 +45,6 @@ We have addressed many of the CMake-related issues on GitHub, with bug fixes, do
- If gRPC is built without testing enabled, the dependent testing frameworks will automatically be disabled, in order to avoid unnecessary compilation.
- Some issues with parallel builds have been addressed.

TODO(jtattermusch): add a note starting from what version are all the features available?
As a bonus, there is one extra change that wasn't technically part of this effort, but also contributes to simpler and easier cmake build:

TODO(jtattermusch): add a note that we also removed the dependency on boringssl developer build
- To build the boringssl dependency, a much more [lightweight cmake build is now used](https://github.com/grpc/grpc/pull/21527), which eliminates some odd build-time dependencies (e.g. `golang`).

0 comments on commit 71a80c8

Please sign in to comment.