Skip to content
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

Allow cross-compilation with protobuf #3117

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tobim
Copy link
Contributor

@tobim tobim commented Oct 31, 2024

The upstream config module from protobuf always declares targets for the protobuf library and protoc of the same platform. This means one of the two is always wrong, as protoc needs to be run on the build machine, but the library must be linked for the "host" platform.

A small change in the CMake scaffold allows the user to pass -DPROTOBUF_PROTOC_EXECUTABLE=<path/to/protoc> to cmake when creating the build tree.

Fixes # (issue)

Changes

Please provide a brief description of the changes here.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@tobim tobim requested a review from a team as a code owner October 31, 2024 07:25
Copy link

netlify bot commented Oct 31, 2024

Deploy Preview for opentelemetry-cpp-api-docs canceled.

Name Link
🔨 Latest commit 8a48d35
🔍 Latest deploy log https://app.netlify.com/sites/opentelemetry-cpp-api-docs/deploys/674576f8a39e8c0008d25546

endif()
include(CMakeDependentOption)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated to the rest of the change, but seeing that the module isn't used anywhere in the project I thought I might as well clean it up.

Copy link

codecov bot commented Oct 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.84%. Comparing base (955a807) to head (8a48d35).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3117      +/-   ##
==========================================
- Coverage   87.86%   87.84%   -0.01%     
==========================================
  Files         195      195              
  Lines        6151     6151              
==========================================
- Hits         5404     5403       -1     
- Misses        747      748       +1     

see 1 file with indirect coverage changes

set(PROTOBUF_PROTOC_EXECUTABLE protobuf::protoc)
if(NOT PROTOBUF_PROTOC_EXECUTABLE)
# Latest Protobuf imported targets and without legacy module support
if(TARGET protobuf::protoc)
Copy link
Member

@owent owent Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not build protobuf::protoc when cross compilation beforem but it's reasonable to support cross compilation when it's built.
Could you please also check and set PROTOBUF_PROTOC_EXECUTABLE?
PROTOBUF_PROTOC_EXECUTABLE is for the old version of cmake, and now it's PROTOBUF_PROTOC_EXECUTABLE.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent of this change is so that one cat supply -DPROTOBUF_PROTOC_EXECUTABLE=<path/to/protoc> when invoking cmake on the command line.
I assume you mean I should also make -DProtobuf_PROTOC_EXECUTABLE possible, but I don't see a good reason for it. Having to options that do the same thing just creates confusion.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For thus project, doesn't this also need precompiled grpc protoc plugin?

@owent
Copy link
Member

owent commented Nov 26, 2024

@tobim Could you please update this PR? Find scripts of some packages are already be added in other PRs.

The upstream config module from protobuf always declares targets
for the protobuf library and protoc of the same platform. This means
one of the two is always wrong, as protoc needs to be run on the
build machine, but the library must be linked for the "host" platform.

A small change in the CMake scaffold allows the user to pass
`-DPROTOBUF_PROTOC_EXECUTABLE=<path/to/protoc>` to cmake when creating
the build tree.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants