[CMake] External projects and imported targets

Alexander Neundorf a.neundorf-work at gmx.net
Mon May 24 05:06:39 EDT 2010


On Monday 17 May 2010, Timothy M. Shead wrote:
> On 05/16/2010 01:01 PM, Marcus D. Hanwell wrote:
> > OK, may be others on the list may have other experiences they will
> > share. After having spent quite a bit of time working on packaging for a
> > Linux distro, and using CMake's external projects I see many parallels.
> >
> > The external project allows us to establish inter-package dependencies,
> > and from there build order. Traditional targets assume that project is
> > building everything, or that it was already built and found. So two
> > levels are necessary, and external projects allow us to do cross
> > platform packaging for our particular projects.
> >
> > I would certainly be interested in what others who have been using
> > external project have found, but it seems to me that mixing external
> > projects and traditional targets is unlikely to work well, at least with
> > what is available to us right now.
>
> I can think of several reasons to use External Projects: to target a
> platform that doesn't have package management at all (Windows, OSX), to
> target a platform that's missing a required package (Ubuntu doesn't have
> package X), or to target a platform where a required package exists, but
> isn't configured the way you want (Ubuntu has package X, but it was
> built without feature Y that your package requires). 

..or you want to build a static version of a library and link against this 
one.

What I'm doing with the external projects is to install them all into the same 
directory in the binary tree (so the include dir is the same for all and the 
libs of all EPs end up in the same lib/ dir), and then use 
include_directories() with that one include dir and also use the (unloved) 
link_directories() call with that one lib directory, and for 
target_link_libraries() just use the short name of the libraries, 
e.g. "log4cplus", which will be translated by cmake to "-llog4cplus", which 
together with the link_directories() call will work.

Alex


More information about the CMake mailing list