Hi,<div><br></div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
</div>CMake takes great care regarding dependencies on files which are needed<br>
to build targets, i.e. usually, it&#39;s not necessary to specify any extra<br>
dependencies of a target on a file. In my exemplary project, the README<br>
file is actually not needed to build the library target, so CMake does<br>
not add an appropriate dependency. However, the README file is needed<br>
to generate the ZIP file, so the latter must be a separate target with<br>
dependencies on its own, whereas the approach to generate the ZIP file<br>
by a TARGET-style custom command for the library target is wrong, IMO;<br>
one can just trigger the ZIP file target in this way. In other words:<br>
You have two targets with different dependencies - don&#39;t mix them up.<br></blockquote><div><br></div><div>In my case the output is the ZIP file. So the zip file is produced by the top level target, and I don&#39;t want/need a separate target for it.</div>
<div>The generated zip file (bundle) is the deployable unit which contains a library and additional information needed (at runtime) to use the library, which is located in the manifest file. If the manifest file changes, without a change to the library source, the zip file still needs to be regenerated. As such the output of the target depends on the manifest file, hence the need for a dependency to a file.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
PS: Please don&#39;t drop the ML.<br></blockquote><div><br></div><div>I am used to mailing lists having the reply-to set, will try to keep it in mind.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="HOEnZb"><div class="h5"><br>
&gt; 2011/12/13 Michael Hertling &lt;<a href="mailto:mhertling@online.de">mhertling@online.de</a>&gt;<br>
&gt;<br>
&gt;&gt; On 12/12/2011 11:40 AM, Alexander Broekhuis wrote:<br>
&gt;&gt;&gt; Hi,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Can anyone help me with this? I haven&#39;t found a proper solution myself<br>
&gt;&gt; yet..<br>
&gt;&gt;<br>
&gt;&gt; Does the following examplary project do what you intend?<br>
&gt;&gt;<br>
&gt;&gt; CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)<br>
&gt;&gt; PROJECT(P C)<br>
&gt;&gt; SET(CMAKE_VERBOSE_MAKEFILE ON)<br>
&gt;&gt; # The library target:<br>
&gt;&gt; FILE(WRITE ${CMAKE_BINARY_DIR}/f.c &quot;void f(void){}\n&quot;)<br>
&gt;&gt; ADD_LIBRARY(f SHARED f.c)<br>
&gt;&gt; # The README file:<br>
&gt;&gt; FILE(WRITE ${CMAKE_BINARY_DIR}/README &quot;Very important information!\n&quot;)<br>
&gt;&gt; # The ZIP file command:<br>
&gt;&gt; ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/f.zip<br>
&gt;&gt;    COMMAND zip -j ${CMAKE_BINARY_DIR}/f.zip<br>
&gt;&gt;                   ${CMAKE_BINARY_DIR}/README<br>
&gt;&gt;                   $&lt;TARGET_FILE:f&gt;<br>
&gt;&gt;    DEPENDS ${CMAKE_BINARY_DIR}/README)<br>
&gt;&gt; # The ZIP file target:<br>
&gt;&gt; ADD_CUSTOM_TARGET(zip ALL DEPENDS ${CMAKE_BINARY_DIR}/f.zip)<br>
&gt;&gt; # Trigger ZIP file target after library target:<br>
&gt;&gt; ADD_CUSTOM_COMMAND(TARGET f POST_BUILD<br>
&gt;&gt;    COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/f.zip<br>
&gt;&gt;    COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}<br>
&gt;&gt;                             --config $&lt;CONFIGURATION&gt;<br>
&gt;&gt;                             --target zip)<br>
&gt;&gt;<br>
&gt;&gt; The basic idea is the decomposition of the ZIP file&#39;s generation into a<br>
&gt;&gt; custom target, an OUTPUT-style custom command and a TARGET-style custom<br>
&gt;&gt; command, the latter in conjunction with CMake&#39;s --build switch.<br>
&gt;&gt;<br>
&gt;&gt; Regards,<br>
&gt;&gt;<br>
&gt;&gt; Michael<br>
&gt;&gt;<br>
&gt;&gt;&gt; 2011/12/8 Alexander Broekhuis &lt;<a href="mailto:a.broekhuis@gmail.com">a.broekhuis@gmail.com</a>&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Hi all,<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; In my project, some top level targets depend on simple text files. These<br>
&gt;&gt;&gt;&gt; targets produce a zip file as output, this is done using a custom<br>
&gt;&gt; command<br>
&gt;&gt;&gt;&gt; with a post-build to a library target.<br>
&gt;&gt;&gt;&gt; Part of the zip file are some simple text files, which are included<br>
&gt;&gt; using<br>
&gt;&gt;&gt;&gt; some custom CPack handling inside the custom command.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; How can I let the top level target depend on these text files as well?<br>
&gt;&gt; In<br>
&gt;&gt;&gt;&gt; other words, if a text files changes, the zip file has to be<br>
&gt;&gt; regenerated.<br>
&gt;&gt;&gt;&gt; These text files are not generated or copied etc. So a simple DEPENDS<br>
&gt;&gt; would<br>
&gt;&gt;&gt;&gt; suffice. I know add_custom_command(OUTPUT has support for this, but am<br>
&gt;&gt;&gt;&gt; wondering how to do this with add_custom_command(TARGET.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; TiA!<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; --<br>
&gt;&gt;&gt;&gt; Met vriendelijke groet,<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Alexander Broekhuis<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Met vriendelijke groet,<br><br>Alexander Broekhuis<br>
</div>