protocolbuffers/protobuf

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

Open

#14,492 创建于 2023年10月20日

在 GitHub 查看
 (0 评论) (5 反应) (0 负责人)C++ (16,128 fork)batch import
cmakehelp wanted

仓库指标

Star
 (71,223 star)
PR 合并指标
 (平均合并 2天 11小时) (30 天内合并 185 个 PR)

描述

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

贡献者指南