Re: [protobuf] Best practices for proto file organization in large projects
Okay, so I got this build tree working. I had to: (1) Modify FindProtobuf.cmake (the build rule) so that I can specify the proto_path (2) Modify each .proto import to specify the file to import using the full path from the root, even if the files are parallel to the .proto source. (3) Add CMAKE_SOURCE_DIR (the source tree root) to the proto_path (4) Add CMAKE_BINARY_DIR (the build root) to the gcc_path. (5) Do a clean build. I had old generated .pb.h files in the source tree, and they were being included rather then the newly generated files that lives in the build-tree. Thanks for your help. Justin On Wednesday, June 20, 2012 6:24:23 AM UTC-7, Evan Jones wrote: On Jun 19, 2012, at 13:53 , Justin Muncaster wrote: 1Running C++ protocol buffer compiler on common/bar/bar.proto 1common/foo/foo.proto: File not found. 1bar.proto: Import common/foo/foo.proto was not found or had errors. I can fix the error by hacking FindProtobuf.cmake and passing in additional include directories, but I run into problems down the line, which leads me to think there must be a better way. Every example I see has all proto files in one folder and does not have cross-library protobuf message dependencies. This should work, and with the project you attached it does work (well, once I fixed a bad field number): Yamnuska:project ej$ protoc --cpp_out=build common/bar/bar.proto Yamnuska:project ej$ I don't know how CMake or this PROTOBUF_GENERATE_CPP rule works, but maybe you need to pass the appropriate --proto_path argument so it looks for the included .proto in the right place? Good luck, Evan -- http://evanjones.ca/ -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To view this discussion on the web visit https://groups.google.com/d/msg/protobuf/-/19Xfy9exiscJ. To post to this group, send email to protobuf@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
[protobuf] Best practices for proto file organization in large projects
Hello, I've been using protocol buffers for a while, and I love the library, however I find that when using them in large projects I generally have to fight with the compiler to get protoc to play nicely with my build system. My projects are organized as follows: common/foo/foo.h common/foo/foo.cpp common/foo/foo.proto ... common/bar/bar.h common/bar/bar.cpp common/bar/bar.proto where bar.proto contains import common/foo/foo.proto ... and elsewhere... app1/baz.proto ... app1/fud.proto and baz.proto and fud.proto contain import common/bar/bar.proto I'm currently changing our build system to be cmake based and I'm again finding myself fighting with the build system to get the .proto to be automatically generated in a way where they build correctly. This leads me to believe that I am doing something wrong or at least not organizing files in a way that is expected. In light of that, How do you organize your proto files when you have many in common libraries? Do all .proto files live in one folder? Should one avoid import a/b/c/d/f.proto? Do you have any recommendations for how one ought one setup the cmake build system to work with proto files that are organized as they are above? Any general recommendations? Thanks, Justin -- You received this message because you are subscribed to the Google Groups Protocol Buffers group. To view this discussion on the web visit https://groups.google.com/d/msg/protobuf/-/S24EsiM971cJ. To post to this group, send email to protobuf@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
Recursive import problem
I have the following message structure: ===A.proto=== message A { optional B1 b1 = 1; } message B1 { optional A a = 1; } Everything works as intended when the messages are in the same file. However, in my situation there are several child messages (B2, B3, ...) which all naturally all go in their own separate files (B2.proto, B3.proto, ...). Unfortunately, B1 cannot go in its own file due to a problem with a recursive import. Is there any way to solve this? Can I forward declare messages? Thanks, Justin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Protocol Buffers group. To post to this group, send email to protobuf@googlegroups.com To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/protobuf?hl=en -~--~~~~--~~--~--~---