Hi,<br><br>I have done some experiments and I have found something interesting.<br><br>Let's take my old example:<br><br>=== root/src/CMakeLists.txt === (build a shared library)<br>
<br># Compilation<br>add_library(<br> ${CMAKE_PROJECT_NAME} SHARED <br> ${CMAKE_BINARY_DIR}/xsd/mapping_file.cxx)<br><div><br># XML mapping source files are generated<br>set_source_files_properties(<br>
${CMAKE_BINARY_DIR}/xsd/mapping_file.cxx<br>
PROPERTIES GENERATED 1)<br><br># Make sure the source files are generated before the executable builds.<br>add_dependencies(${CMAKE_PROJECT_NAME} cxx_xml_mapping)<br><br>=== root/xsd/CMakeLists.txt === (generates C++ / XML mapping files using code synthesis XSD)<br>
<br># Add a custom target to manage dependencies<br>add_custom_target(cxx_xml_mapping DEPENDS xml_mapping)<br><br>add_custom_command(<br> OUTPUT xml_mapping<br> COMMAND ${XSD_EXECUTABLE} ARGS ${XSD_ARGS} ${CMAKE_CURRENT_SOURCE_DIR}/*.xsd<br>
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.xsd<br> COMMENT "Generating C++ / XML mapping files")</div><br>Instead of putting "xml_mapping" (i.e a logical name) as the name of the OUTPUT in the add_custom_command, I put the list of file names generated by the command, and I put the same list in the add_custom_target. Now it is working, the compilation is done only once (during "make").<br>
<br>I would expect to be able to define a logical name for the OUTPUT variable. When you have a huge list of files generated by a particular command, it is very troublesome to list them all. In another case, I am using XJC compiler and I got about 80 files generated from a few XML schemas... It will not make sense to hard-code them in the list of OUTPUT.<br>
<br>Is there any other way to implement such things? If not, I would suggest an improvement of these two commands to CMake developers. @Bill: any comments on this matter?<br><br>Cheers,<br><br>Romain Chanu<br><br><br><div class="gmail_quote">
2009/11/2 Tyler Roscoe <span dir="ltr"><<a href="mailto:tyler@cryptio.net" target="_blank">tyler@cryptio.net</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;"><div>On Mon, Nov 02, 2009 at 11:28:08PM +0800, Romain CHANU wrote:<br>
> 1. If there is a restriction / condition regarding the "out-of-date"<br>
> behavior, it might be good to update the documentation.<br>
<br>
</div>Agreed, but I don't understand the behavior so I can't help with that.<br>
<div><br>
> 3. I am not 100% sure also... Anyone to give us an advice on that matter??<br>
<br>
</div>Why don't you experiment with an explicit list and see if the behavior<br>
changes? Science to the rescue!<br>
<font color="#888888"><br>
tyler<br>
</font></blockquote></div><br>