Tradias/asio-grpc

Linking against gRPC::grpc++ vs gRPC::grpc++_unsecure

Closed this issue · 6 comments

Hi,

we have a project that already uses grpc and we link against gRPC::grpc++. We now want to introduce asio-grpc, which links against gRPC::grpc++_unsecure when using the generated asio-grpcConfig.cmake. This leads to problems, apparently it is not possible to link against both targets in the same binary.

I found this commit: 2731e5b
So first of all the question would be: Why was this changed? Why is the default the _unsecure target?

We can fix our build by manually patching the asio-grpcConfig.cmake.in file and making sure that asio-grpc also links against gRPC::grpc++, but this is quite ugly and will break on any changes to that file.
Would it be possible to add a cmake config variable so that we can optionally link asio-grpc against gRPC::grpc++ instead of the default of gRPC::grpc++_unsecure?

As an immediate workaround you can set the CMake variable ASIO_GRPC_DISABLE_AUTOLINK before calling find_package/add_subdirectory for asio-grpc. Then it won't link with anything.

I changed it because I though that _unsecure is the baseline and that everything else depends on it. Seems like that is not the case.

Thank you for the quick response!

I'll try that, thanks.

I changed it because I though that _unsecure is the baseline and that everything else depends on it. Seems like that is not the case.

Yeah, and there is not a lot of documentation what those different grpc targets are and when to use what. It doesn't even lead to link errors, when both are linked in the same binary, it just leads to grpc calls hanging indefinitely.

This is the issue that happens in that case: grpc/grpc#24422 (comment)

I will change the default linkage back to gRPC::grpc++ in v3 of asio-grpc and let power users utilize ASIO_GRPC_DISABLE_AUTOLINK + gRPC::grpc++_unsecure as they see fit.

Did my suggestion regarding ASIO_GRPC_DISABLE_AUTOLINK work for you?

Thank you, sounds great!

To be honest, I have yet to try ASIO_GRPC_DISABLE_AUTOLINK , currently still working with my ugly workaround.

Asio-grpc v3 now links with gRPC::grpc++ by default. I am also changing that in conan-center conan-io/conan-center-index#22910.

Cool, thank you! I'll look into migrating to v3