[CMake] ADD_CUSTOM_TARGET(target ALL) and Visual Studio

Sahn Lam sahn at pobox.com
Thu Jan 24 16:39:02 EST 2008


I don't trust myself to be able to specify the dependencies correctly - now
or in the future.  It is not as simple as it seems.  For example, let's say
I have this structure:

libA has gen.h which is generated
libB has header1.h which includes libA/gen.h
libC has header2.h which includes libB/header1.h

If I understand how cmake works correctly, in order for things to get built
in the right order, I have to use ADD_DEPENDENCIES to tell cmake that to
build libA before libB and libC.

This works fine.  But I just don't trust myself to remember this.  One day
I'll add a new lib that has a source that includes libC/header2.h and I'll
forget to tell cmake that it depends on libA (or more precisely,
libA/gen.h).  The kicker is - my private build will likely work because
there is likely to be a previously existed gen.h in my tree - but it might
fail when a clean nightly build starts, or when some does a parallel build.
I can claim to have tested the build, but the fact is, it could still fail.

This is what I want to prevent - intermittent build failure.  I figure it's
so fast to build the generated headers if I could force it be the first
thing to start in the build it will solve my problem.

If anyone has some best practices on this, I'd love to hear it.

Thanks,

Sahn

On Jan 24, 2008 12:32 PM, Hendrik Sattler <post at hendrik-sattler.de> wrote:

> Am Donnerstag 24 Januar 2008 schrieb Sahn Lam:
> > I have a top level custom target that depends on a header file generated
> by
> > a custom command.  I want this custom target to be invoked first so the
> > generated header is built before any other targets needing the header
> are
> > built.
> >
> > Adding the ALL keyword to ADD_CUSTOM_TARGET does what I want in make,
> but
> > it doesn't seem to work in Visual Studio.  The build order dialog shows
> > that the custom target is close to last and none of the other target
> > depends on it.
> >
> > Is this expected? How do I get it to work without using ADD_DEPENDENCIES
> on
> > every single target that needs the generated header?
> >
> > I tried it on both 2.4.8 and cvs.
>
> You want a solution without properly specifying dependencies? That's not
> going

to work reliably. OTOH, cmake's scanning for include files should
> automatically generate the header before using any file that uses it. Even
> if
> you do not add that to ALL.
>
> HS
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20080124/ba10e548/attachment.htm


More information about the CMake mailing list