-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: better support for cross-compilation #11782
fix: better support for cross-compilation #11782
Conversation
Allow overrides for the `protobuf::protoc` and `gRPC::grpc_cpp_plugin` targets. On cross-compilation builds the targets point to the binaries for the *target*, but we need binaries that can run on the *host* build.
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## main #11782 +/- ##
=======================================
Coverage 93.79% 93.79%
=======================================
Files 1834 1834
Lines 165867 165867
=======================================
+ Hits 155574 155576 +2
+ Misses 10293 10291 -2 ☔ View full report in Codecov by Sentry. |
cmake/CompileProtos.cmake
Outdated
if (NOT DEFINED _gRPC_CPP_PLUGIN_EXECUTABLE) | ||
set(_gRPC_CPP_PLUGIN_EXECUTABLE | ||
$<TARGET_FILE:grpc::grpc_cpp_plugin>) | ||
endif () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be safe even for cross-compilation to locate grpc-cpp wherever Protobuf_PROTOC_EXECUTABLE
is. This is what we ended up doing for open-telemetry, for example.
That would save you a magical, private variable, but to be clear: that's a perfectly fine solution as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems intriguing. If I am following the suggestion one would install protoc
and grpc_cpp_plugin
in $PREFIX/bin
or something similar? Unfortunately vcpkg installs protoc
in $PREFIX/tools/protobuf/protoc
and the gRPC plugins in $PREFIX/tools/grpc/*
.
I can give that a try once I get something working across all our builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I am following the suggestion one would install
protoc
andgrpc_cpp_plugin
in$PREFIX/bin
or something similar?
To be honest I don't know how exactly CMake does it, but the idea is to search grpc_cpp_plugin
relative to protoc
. For cross-compilation (in conda-forge), the latter will be in $BUILD_PREFIX/bin
, which will similarly be correct for grpc, while for native compilation, protoc will be in $PREFIX/bin
and again that suits grpc too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately vcpkg installs
protoc
in$PREFIX/tools/protobuf/protoc
and the gRPC plugins in$PREFIX/tools/grpc/*
.
Yeah, that might mean it's not a directly suitable idea for you here. 😑
I don't know how the path traversal in find_program(<something> HINTS ${PATH} ...)
would look like. Perhaps it's still salvageable, but we'd have to try to find out...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how the path traversal in
find_program(<something> HINTS ${PATH} ...)
would look like. Perhaps it's still salvageable, but we'd have to try to find out...
Seems like we are getting to diminishing returns pretty quickly. The default works for most builds, and a CMake flag should work in all (I hope) other cases. Seems like each package manager would require a different HINT
entry and at the point we might as well keep the setting in the package manager recipe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess was that CMake will exhaustively search the entire folder hierarchy under HINT
, and then the hint of "start with protoc" would also have been correct for vcpkg. But I don't care about this very much, it was just a thought to save you some complexity
Allow overrides for the
protobuf::protoc
andgRPC::grpc_cpp_plugin
targets. On cross-compilation builds the targets point to the binaries for the target, but we need binaries that can run on the host build.Fixes #11779
This change is