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

<br>
some_script.cmake:<br>
------------------<br>
set(CMAKE_SOURCE_DIR &quot;@CMAKE_SOURCE_DIR@&quot;)<br>
set(CMAKE_BINARY_DIR &quot;@CMAKE_BINARY_DIR@&quot;)<br>
set(SVN_EXECUTABLE &quot;@SVN_EXECUTABLE@&quot;)<br>
# ... do what you need to to ...<br>
-------------------<br>
<br>
<br>
But I still don&#39;t see why you have to extract version-information at build time, because IMHO that shouldn&#39;t change between CMake-runs.<br><font class="Apple-style-span" color="#888888"><br></font></blockquote><div>
<br></div><div>I&#39;m assuming he wants to encode &quot;up-to-the-minute&quot; svn status output in the build, which changes the second you make a local mod to any source file anywhere in your tree...</div><div><br></div>
<div>Admirable goal, but sure does suck to depend on everything. :-)</div><div><br></div></div>