If you have two proto files, you may want to have the things done in the 
example twice; one for main.proto and the other for commonutil.proto.
And others are pretty regular cmake wiring; You can have a single proto 
target including two generated sources or two proto target having a 
dependency.



On Thursday, December 24, 2020 at 9:57:05 AM UTC-8 Eric Smith wrote:

> Based on a [HelloWorld][1] from grpc, I have created a project with my own 
> proto file. This proto file also imports another proto file in the same 
> directory:
>
> MainProto.proto:
>
>     syntax = "proto3";
>
>     package MyProject;
>     option csharp_namespace = "MyProject";
>
>     option optimize_for = SPEED;
>     option cc_enable_arenas = true;
>     import "google/protobuf/empty.proto";
>     import "google/protobuf/timestamp.proto";
>     import "google/protobuf/wrappers.proto";
>     import "CommonUtils.proto";
>     ....
>
> Followed by a bunch of enums, messages and services, some of which use the 
> enums/messages from CommonUtils.proto.
>
> In the CMakeLists.txt file, I generate the .cc and .hh based on the 
> MainProto.proto file. However, this does not seem to generate the necessary 
> files for CommonUtils.proto, which are then detected as errors in 
> MainProto.pb.h and the other generated header files.
>
> My question is:
>
>  1. How do I modify my CMakeLists or Makefile to also build the headers 
> and cc files for CommonUtils?
>
>  2. How do I link the generated files together to avoid "unresolved 
> external symbol" errors?
>
> I have tried replacing the proto file in my CMakeList.txt file (the lines 
> # Proto file and # Generating source) with the CommonUtils.proto, and then 
> replacing it and running with the original MainProto.proto, but I get a 
> bunch of unresolved external symbol errors in the generated MainProto.pb.h 
> for all the fields that should be imported from CommonUtils.proto.
>
> My CMakeLists.txt is similar to the HelloWorld, with only 
> greeter_async_client and greeter_async_server and the rest removed, and my 
> Makefile is the same as the example. 
>
> See my full file text in nice formatting here 
> https://stackoverflow.com/questions/65433642/linking-imported-proto-file-in-cmakelists-txt
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/29675aeb-0386-4f06-a61d-206563a22721n%40googlegroups.com.

Reply via email to