[CMake] ADD_SUBDIRECTORY

George Neill georgen at neillnet.com
Thu Dec 20 22:50:55 EST 2007


Hi Alan,

> Well, don't shut up.  :-)

ok.   :)

> However, if you have created targets lib1, lib2, lib3 with the
> EXCLUDE_FROM_ALL attribute, in various subdirectories and want one special
> make target that builds all of them, then use
>
> add_custom_target(libs)
> add_dependencies(libs lib1, lib2, lib3)

I actually ended up using ...

ADD_CUSTOM_TARGET(libs DEPENDS lib1 lib2 lib3)

Thanks ... I will test to see if the Makefiles get generated the same
the way you suggest.  My guess is they'll be identical.

For some reason I have it stuck in my head that CMake could
automatically generate the pseudo-target for me ... without having to
specify it.  That is the discussion I have started.

> Since there is no ALL attribute on libs, and you have used the
> EXCLUDE_FROM_ALL attribute when building lib1, etc., "make all" will not
> build lib1, etc. but "make libs" will.  If there are lots of such libraries
> that differ from one configuration to the next, the above procedure can
> easily be automated to use a list of libraries that is created by the
> configuration.

Sure.  I actually haven't had the need for EXCLUDE_FROM_ALL yet, I am
sure will need it in the future though.

> I haven't been paying that much attention to this thread, but since it's had
> a number of posts I assume you have been advised to do the above before.
> Usually, you will find the advice on this list is pretty good.  :-)

Oh geez, I hope I didn't come off as this list wasn't helpful ...
quite the other way around!  I have learned quite a bit from you guys
in my short time on this list ... and I absolutely love CMake.  Keep
up the good work.

I am just kicking up a discussion I suppose.

Thanks,
George.


More information about the CMake mailing list