[CMake] ADD_SUBDIRECTORY

George Neill georgen at neillnet.com
Thu Dec 20 18:09:09 EST 2007


Hi Brandon,

> Having a subdirectory doesn't imply you want that stuff built as part
> of "make all."  In fact there are explicit options to avoid this.  A
> typical example is you've got some source code for sample projects,
> but you don't want the sample projects built by default.  Test cases
> are another example.

In this case you wouldn't have used ADD_SUBDIRECTORY() or you would
have specified EXCLUDE_FROM_ALL.  I get that.

I am not trying to build this target as part of 'make all' !  I guess
I am just trying to build a short-cut target to a sub-project which
may or may not have a number of sub-projects itself.

If you can't tell, I am still a CMake newbie ... please don't flame me
too bad :)

So lets throw out my premise of using ADD_SUBDIRECTORY() as a trigger
to do this.  (maybe a bad approach?)

With this simple example (a sub project of a larger CMake project
called 'example')

PROJECT(libs)
ADD_SUBDIRECTORY(first)        # builds a library
ADD_SUBDIRECTORY(second)  # builds a library
ADD_SUBDIRECTORY(third)      # builds an executable

I would like to be able to have a 'libs' psuedo-target auto-generated.
 What are some of the possible issues I would run into if I tried to
develop this functionality?

... thinking out loud ...

1.  'make all' shouldn't include this psuedo target (becuase it's
already covered with first,second and third)

2.  sub-project dependencies (might be painful?) ... maybe I wouldn't
have to mess with them?

Thoughts?


... or do I just shut up and continue using the dang
ADD_CUSTOM_TARGET() function :)

TIA,
George.


More information about the CMake mailing list