[CMake] How to guarntee the sequence of build if no target can be used

Dong Tiger idlecat511 at gmail.com
Thu May 28 10:22:16 EDT 2009


Thanks for answering my question.

2009/5/27 Tyler Roscoe <tyler at cryptio.net>

> On Wed, May 27, 2009 at 11:01:51PM +0000, idlecat511 at gmail.com wrote:
> > 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.
>
> CMake knows how to resolve these header dependencies. So any file that
> #includes (or #includes something that #includes) foo.h will be
> recompiled if foo.h changes. You don't need to do anything else for this
> part.


The problem I ran into when using add_custom_command is that C files will be
compiled before foo.h is generated and the compilation will fail.

Oh, maybe it's because the foo.h is actually named as foo_blahblah_h. I'll
give it a try.

>
>
> > 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.
>
> If your custom_target() has correct OUTPUT and DEPENDS parameters, this
> should not happen. Are you specifying ALL in your add_custom_target()?


The manual doesn't mention OUTPUT can be specified in add_custom_target. And
it reads that "(The target) is ALWAYS CONSIDERED OUT OF DATE even if the
commands try to create a file with the name of the target.".

>
>
> tyler
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090528/c66b98c0/attachment.htm>


More information about the CMake mailing list