0

I've been working to prevent our CMake system at work from always regenerating the Java wrapper classes for our protobufs; as it stands, a single change in a C++ unit test requires rebuilding a couple hundred of these. The Python and C++ protoc commands are not executed in the same circumstances.

Since I don't use the Java class files, I was not paying too close attention; but I've finally figured out the issue: when compiling XMessage.proto which contains a protobuf called XMessage, protoc generates the output file as XMessageOuterClass.java (to match the name used for the wrapper class). This does not match the expected output name specified in CMake, and so it always rebuilds.

My question is: how can I tell, from a CMake level, whether the protobuf will or will not have this name mangling, so that I can specify the command's OUTPUT correctly and prevent unneeded rebuilding?

Mike C
  • 1,224
  • 10
  • 26
  • How do you generate java files with protobuf? The module [FindProtobuf](https://cmake.org/cmake/help/latest/module/FindProtobuf.html), shipped with CMake, can only generate C++ and Python files. – Tsyvarev Jul 03 '21 at 16:59
  • @Tsyvarev I guess the answer is, we have a custom FindProtobuf. I didn't write it; I just want it to stop misbehaving. – Mike C Jul 03 '21 at 17:19
  • So you need to specify in the CMake OUTPUT those files, which are **actually** produced by protobuf. (In other words, you specification of OUTPUT should **predict** files which will be created by protobuf compiler.) – Tsyvarev Jul 03 '21 at 17:28

0 Answers0