Kotori0
Kotori0

Reputation: 147

How to build gRPC++ with OpenSSL instead of BoringSSL

My project uses MySQL connector, which use OpenSSL as its dependency. I've integrate gRPC with my project using FetchContent, with OpenSSL installed in my system. But it still use BoringSSL.

Upvotes: 4

Views: 8116

Answers (3)

JonasVautherin
JonasVautherin

Reputation: 8033

gRPC offers two ways to get its dependencies: with add_subdirectory (I'm not a big fan of this way), and with find_package (that's my favorite).

As documented here:

# Providers for third-party dependencies (gRPC_*_PROVIDER properties):
# "module": build the dependency using sources from git submodule (under third_party)
# "package": use cmake's find_package functionality to locate a pre-installed dependency

So in order to use your own SSL library, the best way is to:

  1. Make sure gRPC uses find_package, with -DgRPC_SSL_PROVIDER=package.
  2. Make sure that your SSL library will be found by find_package. Either because it is installed system-wide, or by using -DCMAKE_PREFIX_PATH to help find_package find it.

Here is an example fetching and building gRPC and its dependencies from sources. Note this line in particular, where gRPC is instructed to use the "package" mode.

I would advise against adding set(gRPC_SSL_PROVIDER package) to your CMakeLists.txt. This should not be a concern of your project's CMakeLists, hence it's better to pass it as a command (-DgRPC_SSL_PROVIDER=package).

Upvotes: 1

Ajay Sabat
Ajay Sabat

Reputation: 1

We use gRPC by compiling source code. There was an issue (application segfault) due to which it was needed to to disable boringSSL for gRPC and use OpenSSL installed on the system. There are many suggestions. But the one that worked for me is below.

cmake -DgRPC_SSL_PROVIDER=OpenSSL . && make && make install

Upvotes: -1

Kotori0
Kotori0

Reputation: 147

Add these to your CMakeList.txt

set(gRPC_SSL_PROVIDER package)

Upvotes: 6

Related Questions