[CMake] Simplify cross compilation of C++ projects with proto files
#14,492 opened on Oct 20, 2023
Repository metrics
- Stars
- (71,223 stars)
- PR merge metrics
- (Avg merge 2d 11h) (185 merged PRs in 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