<div class="gmail_quote">On Fri, Jan 15, 2010 at 10:25 AM, Marcel Loose <span dir="ltr"><<a href="mailto:loose@astron.nl">loose@astron.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">On Fri, 2010-01-15 at 10:07 -0500, David Cole wrote:<br>
> On Fri, Jan 15, 2010 at 9:44 AM, Marcel Loose <<a href="mailto:loose@astron.nl">loose@astron.nl</a>> wrote:<br>
> Hi Jack,<br>
><br>
> The difference with your and my case is that you have an input<br>
> file<br>
> (the .xsd file) and output files (the .h and .cpp files). In<br>
> my case I<br>
> generate the output file, e.g. myheader.h, from <a href="http://myheader.h.in" target="_blank">myheader.h.in</a>,<br>
> using<br>
> configure_file(). The problem is that I cannot get this to<br>
> work during<br>
> 'make', only during 'cmake'.<br>
><br>
> Best regards,<br>
> Marcel Loose.<br>
><br>
> On Fri, 2010-01-15 at 15:04 +0100, Smith Jack (Ext. - UGIS -<br>
> UniCredit<br>
><br>
> Group) wrote:<br>
> > I do a similar thing with an XSD file from which I generate<br>
> c++<br>
> wrapper classes for accessing the corresponding XML<br>
> ><br>
> > Note the DEPENDS line !<br>
> ><br>
> > MACRO(XSD FILE NAMESPACE)<br>
> > ADD_CUSTOM_COMMAND(<br>
> > OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/xml/${FILE}.cpp<br>
> > OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/xml/${FILE}.h<br>
> > DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/xml/${FILE}.xsd<br>
> > COMMAND ${XAPI_CODESYNTH}/bin/xsd<br>
> > ARGS cxx-tree --generate-serialization<br>
> --hxx-suffix .h<br>
> --cxx-suffix .cpp --fwd-suffix -fwd.hxx --type-naming java<br>
> --function-naming java --namespace-map =${NAMESPACE}<br>
> --generate-polymorphic --output-dir<br>
> ${CMAKE_CURRENT_SOURCE_DIR}/xml<br>
> ${CMAKE_CURRENT_SOURCE_DIR}/xml/${FILE}.xsd<br>
> > COMMENT "generating Codesynthesis Wrappers")<br>
> > ENDMACRO(XSD)<br>
> ><br>
> ><br>
> ><br>
> > > -----Original Message-----<br>
> > > From: <a href="mailto:cmake-bounces@cmake.org">cmake-bounces@cmake.org</a><br>
> > > [mailto:<a href="mailto:cmake-bounces@cmake.org">cmake-bounces@cmake.org</a>] On Behalf Of Marcel Loose<br>
> > > Sent: Friday, January 15, 2010 2:55 PM<br>
> > > To: <a href="mailto:cmake@cmake.org">cmake@cmake.org</a><br>
> > > Subject: [CMake] How to regenerate source file during<br>
> make?<br>
> > ><br>
> > > Hi all,<br>
> > ><br>
> > > I've been struggling with this for hours now and I can't<br>
> seem<br>
> > > to get a grip on it.<br>
> > ><br>
> > > I have a header file that must be (re)generated during<br>
> 'make'<br>
> > > when some external data have changed. I can successfully<br>
> > > generate this file during 'cmake' using configure_file(),<br>
> but<br>
> > > I haven't been able to figure out how I can trigger the<br>
> > > configure_file() during make.<br>
> > ><br>
> > > Should I define a target for this header file? Or can I<br>
> > > specify some kind of file dependency, such that when the<br>
> > > header file is missing our out-of-date, it will be<br>
> (re)generated?<br>
> > ><br>
> > > I guess it must be some clever combination of<br>
> > > add_custom_command() and add_custom_target().<br>
> > ><br>
> > > Best regards,<br>
> > > Marcel Loose.<br>
><br>
><br>
><br>
> This should work already: if you change <a href="http://my_header.h.in" target="_blank">my_header.h.in</a> then cmake<br>
> should re-run to re-configure your file at 'make' time.<br>
><br>
><br>
> If you have additional dependencies that should trigger a<br>
> re-configure, you should probably convert it to an add_custom_command<br>
> such that it happens at build time.<br>
<br>
</div></div>It's not the <a href="http://myheader.h.in" target="_blank">myheader.h.in</a> that's changing; myheader.h should be<br>
regenerated because the value of one of the variables in <a href="http://myheader.h.in" target="_blank">myheader.h.in</a><br>
(that get expanded) change.<br>
<br>
To be more precise, I try to record the svn revision number (and some<br>
more svn info). I carefully read<br>
<a href="http://www.mail-archive.com/cmake@cmake.org/msg25922.html" target="_blank">http://www.mail-archive.com/cmake@cmake.org/msg25922.html</a>, because it<br>
closely matches my problem, but I couldn't figure out what<br>
update_version.cmake should do exactly. In my case, I would need the<br>
values of a number CMake variables (like CMAKE_CURRENT_BINARY_DIR), but<br>
of course, these values are not around anymore when running 'make'.<br>
Should all these variables be passed using -D?<br>
<br></blockquote><div><br></div><div>Yes. Put the configure_file call into a cmake -P script. Then use add_custom_command to call it, passing all the variables required with -D args before the -P arg.</div><div><br></div>
<div>Sounds like you'll need to run svn status and svn info *always* and then run this command afterwards *if* something is different than last time it ran...</div><div><br></div><div>HTH,</div><div>David</div><div><br>
</div></div>