2009/5/29 Alexander Neundorf <[email protected]> > On Thursday 28 May 2009, [email protected] wrote: > > Hi, > > > > This situation is: > > > > foo.h is generated from foo.x. And foo.h is included by bar.h. And then > > bar.h is included by a lot of c files. So actually every c files > including > > bar.h depends on foo.h. > > But the file number is so big that I don't want to add dependency for > each > > one. > > > > How can I specify foo.x is generated before all the c files being > compiled? > > It seems add_custom_target works but it will regenerate foo.h every time > > even the foo.x is not modified. > > You should use > add_custom_command(OUTPUT <fullpath>/foo.h > ... ) > > and then list that generated file as a source file for your target: > > add_library(blub <fullpath>/foo.h foo.c bar.c ...)
I know by this way, if foo.h is changed, blub will be rebuilt. But what I need is foo.h is guaranteed to be up to date before foo.o is built. I am not sure if this command is relevant to this. Will cmake try to make sure all the src files are up to date before compiling any .c files? > > > This should make sure that everything is up to date. > > The header-file dependency scanning does in general not work for generated > files, you need to list the generated file as source file for the targets > which need it. Another problem is that I am trying to avoid adding dependencies for these generated files manually because in my project, there are many generated head files and quite a few .c files including them. I just want to make sure the head files are generated before any .c compilation. ADD_CUSTOM_TARGET can do this but it will regenerate the head files even they are up-to-date. > > Alex >
_______________________________________________ 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
