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'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'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'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'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>
> 2011/12/13 Michael Hertling <<a href="mailto:mhertling@online.de">mhertling@online.de</a>><br>
><br>
>> On 12/12/2011 11:40 AM, Alexander Broekhuis wrote:<br>
>>> Hi,<br>
>>><br>
>>> Can anyone help me with this? I haven't found a proper solution myself<br>
>> yet..<br>
>><br>
>> Does the following examplary project do what you intend?<br>
>><br>
>> CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR)<br>
>> PROJECT(P C)<br>
>> SET(CMAKE_VERBOSE_MAKEFILE ON)<br>
>> # The library target:<br>
>> FILE(WRITE ${CMAKE_BINARY_DIR}/f.c "void f(void){}\n")<br>
>> ADD_LIBRARY(f SHARED f.c)<br>
>> # The README file:<br>
>> FILE(WRITE ${CMAKE_BINARY_DIR}/README "Very important information!\n")<br>
>> # The ZIP file command:<br>
>> ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/f.zip<br>
>> COMMAND zip -j ${CMAKE_BINARY_DIR}/f.zip<br>
>> ${CMAKE_BINARY_DIR}/README<br>
>> $<TARGET_FILE:f><br>
>> DEPENDS ${CMAKE_BINARY_DIR}/README)<br>
>> # The ZIP file target:<br>
>> ADD_CUSTOM_TARGET(zip ALL DEPENDS ${CMAKE_BINARY_DIR}/f.zip)<br>
>> # Trigger ZIP file target after library target:<br>
>> ADD_CUSTOM_COMMAND(TARGET f POST_BUILD<br>
>> COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/f.zip<br>
>> COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}<br>
>> --config $<CONFIGURATION><br>
>> --target zip)<br>
>><br>
>> The basic idea is the decomposition of the ZIP file's generation into a<br>
>> custom target, an OUTPUT-style custom command and a TARGET-style custom<br>
>> command, the latter in conjunction with CMake's --build switch.<br>
>><br>
>> Regards,<br>
>><br>
>> Michael<br>
>><br>
>>> 2011/12/8 Alexander Broekhuis <<a href="mailto:a.broekhuis@gmail.com">a.broekhuis@gmail.com</a>><br>
>>><br>
>>>> Hi all,<br>
>>>><br>
>>>> In my project, some top level targets depend on simple text files. These<br>
>>>> targets produce a zip file as output, this is done using a custom<br>
>> command<br>
>>>> with a post-build to a library target.<br>
>>>> Part of the zip file are some simple text files, which are included<br>
>> using<br>
>>>> some custom CPack handling inside the custom command.<br>
>>>><br>
>>>> How can I let the top level target depend on these text files as well?<br>
>> In<br>
>>>> other words, if a text files changes, the zip file has to be<br>
>> regenerated.<br>
>>>> These text files are not generated or copied etc. So a simple DEPENDS<br>
>> would<br>
>>>> suffice. I know add_custom_command(OUTPUT has support for this, but am<br>
>>>> wondering how to do this with add_custom_command(TARGET.<br>
>>>><br>
>>>> TiA!<br>
>>>><br>
>>>> --<br>
>>>> Met vriendelijke groet,<br>
>>>><br>
>>>> 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>