protocolbuffers / protocolbuffers/protobuf

[CMake] Simplify cross compilation of C++ projects with proto files

Open
#14,492 0 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cmake help wanted
Dominant language
C++
Stars
72k
Forks
16.3k
Avg merge
1d 17h
Merged PRs (30d)
140

Description

What language does this apply to?
C++ codegen

Describe the problem you are trying to solve.
When cross compiling a C++ project that makes use of the Protobuf-Config.cmake file to resolve the dependency the build for the target platform is found. For linking to libprotobuf.so this is correct, but the protoc compiler in that package can't be executed during build.

This situation requires workarounds in the client projects, for example grpc's cmake scaffold has the -D_gRPC_PROTOBUF_PROTOC_EXECUTABLE option to pass in the appropriate executable.

Describe the solution you'd like
Alter the CMake installation setup so that something like find_package(protoc) exports protoc only. I think the installed protobuf-*.cmake files can still export both if you want to preserve backwards compatibility.

Describe alternatives you've considered

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the installed Protobuf-Config.cmake and protobuf-*.cmake files, then compare their behavior with the grpc CMake scaffold and its -D_gRPC_PROTOBUF_PROTOC_EXECUTABLE workaround. Done means a cross-compiled C++ project can resolve the target library while using an executable protoc without client-specific overrides, while preserving the stated backwards compatibility.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.