<div dir="ltr">Hi Eric.<br><br>Thanks a lot for getting back to me.<br><br><div class="gmail_quote">2008/9/18 Eric Noulard <span dir="ltr"><<a href="mailto:eric.noulard@gmail.com">eric.noulard@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">2008/9/18 Neil Girdhar <<a href="mailto:mistersheik@gmail.com">mistersheik@gmail.com</a>>:<br>
<div class="Ih2E3d">><br>
> Hi, I'm trying to add a special cmake rule to build google's protocol<br>
> buffers, and I was hoping someone could help me do it. I've broken down the<br>
> details of the protocol compiler here, so all that's missing is a cmake<br>
> expert.<br>
<br>
</div>Did you look at the recently posted CMake module:<br>
<a href="http://www.cmake.org/pipermail/cmake/2008-September/023963.html" target="_blank">http://www.cmake.org/pipermail/cmake/2008-September/023963.html</a><br>
</blockquote><div><br>That's great!<br><br>I couldn't figure out how to use it though. I copied it to cmake's modules directory (there should be a ~/.cmake/Modules place where you can add your own modules), and got it loaded just fine. I had to add /opt/local/include/google/protobuf so that it would find the place where macports puts protobufs, but there is no documentation on how to use wrap_proto(...). It looks like I need to put at least two things in those brackets, but what?<br>
<br>Thanks<br><br>Neil<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
I've added some suggested "basic" commands afterwards<br>
but I really suggest to try the preceding module and may be improve it or<br>
fix it, if it does not suit your needs and give feedback to the original author.<br>
<div class="Ih2E3d"><br>
> I have some ".proto" files that live in the same directories as the source.<br>
> I want to specify a rule that calls this:<br>
><br>
> protoc DIR/SOMEFILE.proto --cpp_out=SOMEDIR<br>
><br>
> SOMEDIR should probably be DIR/CMakeFiles/DIR.dir<br>
<br>
</div>What would you do that?<br>
I suggest that SOMEDIR should be<br>
${CMAKE_CURRENT_BINARY_DIR}<br>
which the directory in the build tree which the sibbling<br>
of the corresponding source tree directory (${CMAKE_CURRENT_SOURCE_DIR})<br>
<div class="Ih2E3d"><br>
> this will generate<br>
> SOMEDIR/SOMEFILE.pb.h<br>
> SOMEDIR/<a href="http://SOMEFILE.pb.cc" target="_blank">SOMEFILE.pb.cc</a><br>
<br>
</div>Then something like this in DIR/CMakeLists.txt<br>
<br>
ADD_CUSTOM_COMMAND(<br>
OUTPUT SOMEFILE.pb.h <a href="http://SOMEFILE.pb.cc" target="_blank">SOMEFILE.pb.cc</a><br>
COMMAND protoc SOMEFILE.proto --cpp_out=${CMAKE_CURRENT_BINARY_DIR}<br>
DEPENDS<br>
SOMEFILE.proto<br>
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})<br>
<div class="Ih2E3d"><br>
<br>
<br>
> I want to include SOMEFILE.pb.h in my source files and<br>
> I want them to be found.<br>
> I want to compile and link <a href="http://SOMEFILE.pb.cc" target="_blank">SOMEFILE.pb.cc</a> automatically<br>
<br>
</div>Then those file are compiled in a LIBRARY or EXECUTABLE<br>
ADD_LIBRARY(mylib<br>
SOMEFILE.pb.h <a href="http://SOMEFILE.pb.cc" target="_blank">SOMEFILE.pb.cc</a>)<br>
<br>
then do not forget to tell CMake that those files are to be generated:<br>
set_source_files_properties(SOMEFILE.pb.h <a href="http://SOMEFILE.pb.cc" target="_blank">SOMEFILE.pb.cc</a><br>
PROPERTIES<br>
GENERATED TRUE)<br>
<div><div></div><div class="Wj3C7c">><br>
> what is the easiest set of rules that I can use to extend cmake to do this?<br>
</div></div></blockquote><div><br>Thanks for the rules! I'll fall back on these if I can't get the module to work. The module is a bit nice of a solution. <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div class="Wj3C7c"><br>
<br>
<br>
</div></div><font color="#888888">--<br>
Erk<br>
</font></blockquote></div><br></div>