protocolbuffers/protobuf

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

Open

#14.492 aberto em 20 de out. de 2023

Ver no GitHub
 (0 comments) (5 reactions) (0 assignees)C++ (16.128 forks)batch import
cmakehelp wanted

Métricas do repositório

Stars
 (71.223 stars)
Métricas de merge de PR
 (Mesclagem média 2d 11h) (185 fundiu PRs em 30d)

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

Guia do colaborador