On Sun, 9 Jun 2019 at 14:51, 'Kenton Varda' via Cap'n Proto < [email protected]> wrote:
> Hi Adam, > > Is cmake running the capnp tool every time, or only when the capnp files > change? I would suggest configuring it to only re-run the code generation > when the .capnp files have changed. I don't personally know cmake but it > surely supports this. > > Unfortunately you are correct that there's no good way to forward-declare > the nested types generated by the capnp tool. > > -Kenton > > On Fri, Jun 7, 2019 at 6:54 AM Ádám Balázs <[email protected]> wrote: > >> Hi all, >> >> I try to use Cap'NProto in a CMake based C++ project. CMake runs capnp >> tool to generate headers/sources and adds them to the project. With this >> approach I eliminate the inconsistent states, however the generated files >> are touched every time CMake runs, so the compiler recompiles them during >> the build. With forward declaration it wouldn't be a big deal, but as far >> as I understand the generated code I can not forward declare builders and >> readers since they are nested classes. This is a really unfortunate >> situation, because the headers using the generated code are used in many >> components (configurations). Can I somehow forward declare generated >> classes? Could you advise some technique to solve the described situation? >> Is it intended to prohibit forward declaration? >> >> Thank you in advance: Adam >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Cap'n Proto" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> Visit this group at https://groups.google.com/group/capnproto. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/capnproto/d84ad038-22be-48c0-aac3-050fafc18ca1%40googlegroups.com >> <https://groups.google.com/d/msgid/capnproto/d84ad038-22be-48c0-aac3-050fafc18ca1%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- > You received this message because you are subscribed to the Google Groups > "Cap'n Proto" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > Visit this group at https://groups.google.com/group/capnproto. > To view this discussion on the web visit > https://groups.google.com/d/msgid/capnproto/CAJouXQ%3DSbRggayxzM1goybtb-%3D6LsEKMAoVeMJTDH-envvBw%3DQ%40mail.gmail.com > <https://groups.google.com/d/msgid/capnproto/CAJouXQ%3DSbRggayxzM1goybtb-%3D6LsEKMAoVeMJTDH-envvBw%3DQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . There’s a function (CAPNP_GENERATE_CPP) defined in the file ‘CapnProtoMacros.cmake’ which has CMake code to generate C++ files for capnp files. It looks like it’s set up properly to only run when required (by which I mean it uses ‘add_custom_command’ with appropriate output & dependency parameters set up). I’ve used the same setup for other codegen tasks, and it’s worked fine. The custom command generates the source (by default) in CMAKE_CURRENT_BINARY_DIR, which is what you’d expect for CMake. It’ll regenerate the files for a new build directory, but after that should manage dependencies correctly after that. Stuart -- You received this message because you are subscribed to the Google Groups "Cap'n Proto" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. Visit this group at https://groups.google.com/group/capnproto. To view this discussion on the web visit https://groups.google.com/d/msgid/capnproto/CA%2BL%2BJktf_ivaDsTsi%3D6dSUWkDAewKZ1v0%3Dz3O%2BddR4XH1XXnZg%40mail.gmail.com.
