[CMake] Build only what you need in third party libs

Alexander Neundorf a.neundorf-work at gmx.net
Wed Dec 16 22:23:41 CET 2009


On Wednesday 16 December 2009, Brian Davis wrote:
> Sorry for the late reply... it's finals week (school).
>
> See below
>
> 2009/12/9 Alexander Neundorf <a.neundorf-work at gmx.net>
>
> > On Saturday 05 December 2009, Brian Davis wrote:
> > > I have used boost jam before and there was a mechanism to build only
> > > what you need by specifying dependencies within the boost libraries. 
> > > bjam would
> > > then run off calculate deps and build only what I needed. In CMake is
> > > there
> > > such a feature to specify a third party library and specify only the
> > > targets you need to build as dependencies of my build target?
> > > i.e. can I use
> > >
> > > add_subdirectory( lib/3rdParty/Win32/boost-cmake-1_41_0 ./boost )
> > >
> > > then create a target that only uses say boost_filesystem and only have
> > > that built? Or do I need to build the world to get a handful of needed
> > > dll's that are actually used in my project?
> >
> > Maybe I'm missing the point, but let's say you have library A, B, C and D
> > (where B depends on A), and an executable foo, which links against B and
> > D. If you then just build the target "foo", the targets A, B and D will
> > be built
> > automatically (and not C, since foo does not depend on C).
> >
> > Is this what you mean ?
> >
> > Alex
>
> Yes this is it exactly.  The problem I have is how to specify these
> libraries in third party packages.  With boost there is BUILD_PROJECTS
> which is boost specific and seems kinda clunky.  i.e. I would like to set
> BUILD_PROJECTS=NONE and do as you suggest above.  Problem comes how do I

So you want to build just a part of boost, right ?

> specify this (or is it possible) in cmake.  I also made refrence to a
> namespace issue above which no one has answered.  If I make an uber project
> of multiple 3rd party libs then is'nt there a chance that (perhaps a bad
> example) that the third party lib will use the variable BUILD_PROJECTS as
> well.  If so what happens in cmake?  Each time I specify a new dependency
> then I have to run cmake again to build the MS VS project so I can compile.

You could add an add_custom_target(foo) and then use add_dependencies(foo lib1 
lib2), and then building foo will just build the libs it depends on.
But maybe this is what BUILD_PROJECTS does ?

Alex



More information about the Kde-buildsystem mailing list