<div class="gmail_quote">On Fri, Jan 15, 2010 at 10:35 AM, Michael Wild <span dir="ltr"><<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</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"><br>
On 15. Jan, 2010, at 16:25 , Marcel Loose wrote:<br>
<br>
> 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>
> 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>
> Best regards,<br>
> 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 "static" 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 "@CMAKE_SOURCE_DIR@")<br>
set(CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@")<br>
set(SVN_EXECUTABLE "@SVN_EXECUTABLE@")<br>
# ... do what you need to to ...<br>
-------------------<br>
<br>
<br>
But I still don't see why you have to extract version-information at build time, because IMHO that shouldn't change between CMake-runs.<br><font class="Apple-style-span" color="#888888"><br></font></blockquote><div>
<br></div><div>I'm assuming he wants to encode "up-to-the-minute" 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>