Hi,
> CMake takes great care regarding dependencies on files which are needed > to build targets, i.e. usually, it's not necessary to specify any extra > dependencies of a target on a file. In my exemplary project, the README > file is actually not needed to build the library target, so CMake does > not add an appropriate dependency. However, the README file is needed > to generate the ZIP file, so the latter must be a separate target with > dependencies on its own, whereas the approach to generate the ZIP file > by a TARGET-style custom command for the library target is wrong, IMO; > one can just trigger the ZIP file target in this way. In other words: > You have two targets with different dependencies - don't mix them up. > 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. 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. > > PS: Please don't drop the ML. > I am used to mailing lists having the reply-to set, will try to keep it in mind. > > > 2011/12/13 Michael Hertling <mhertl...@online.de> > > > >> On 12/12/2011 11:40 AM, Alexander Broekhuis wrote: > >>> Hi, > >>> > >>> Can anyone help me with this? I haven't found a proper solution myself > >> yet.. > >> > >> Does the following examplary project do what you intend? > >> > >> CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) > >> PROJECT(P C) > >> SET(CMAKE_VERBOSE_MAKEFILE ON) > >> # The library target: > >> FILE(WRITE ${CMAKE_BINARY_DIR}/f.c "void f(void){}\n") > >> ADD_LIBRARY(f SHARED f.c) > >> # The README file: > >> FILE(WRITE ${CMAKE_BINARY_DIR}/README "Very important information!\n") > >> # The ZIP file command: > >> ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/f.zip > >> COMMAND zip -j ${CMAKE_BINARY_DIR}/f.zip > >> ${CMAKE_BINARY_DIR}/README > >> $<TARGET_FILE:f> > >> DEPENDS ${CMAKE_BINARY_DIR}/README) > >> # The ZIP file target: > >> ADD_CUSTOM_TARGET(zip ALL DEPENDS ${CMAKE_BINARY_DIR}/f.zip) > >> # Trigger ZIP file target after library target: > >> ADD_CUSTOM_COMMAND(TARGET f POST_BUILD > >> COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/f.zip > >> COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} > >> --config $<CONFIGURATION> > >> --target zip) > >> > >> The basic idea is the decomposition of the ZIP file's generation into a > >> custom target, an OUTPUT-style custom command and a TARGET-style custom > >> command, the latter in conjunction with CMake's --build switch. > >> > >> Regards, > >> > >> Michael > >> > >>> 2011/12/8 Alexander Broekhuis <a.broekh...@gmail.com> > >>> > >>>> Hi all, > >>>> > >>>> In my project, some top level targets depend on simple text files. > These > >>>> targets produce a zip file as output, this is done using a custom > >> command > >>>> with a post-build to a library target. > >>>> Part of the zip file are some simple text files, which are included > >> using > >>>> some custom CPack handling inside the custom command. > >>>> > >>>> How can I let the top level target depend on these text files as well? > >> In > >>>> other words, if a text files changes, the zip file has to be > >> regenerated. > >>>> These text files are not generated or copied etc. So a simple DEPENDS > >> would > >>>> suffice. I know add_custom_command(OUTPUT has support for this, but am > >>>> wondering how to do this with add_custom_command(TARGET. > >>>> > >>>> TiA! > >>>> > >>>> -- > >>>> Met vriendelijke groet, > >>>> > >>>> Alexander Broekhuis > -- > > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake > -- Met vriendelijke groet, Alexander Broekhuis
-- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake