[CMake] cmake and multiple projects, targets and versions

Alexander Neundorf a.neundorf-work at gmx.net
Fri Oct 14 14:34:45 EDT 2011


On Friday 14 October 2011, Gints Gailītis wrote:
> Hi cmake list!
> 
> I've been playing around with cmake for a couple of weeks now, and am
> loving (almost) every minute of it. A thing I really like about cmake
> and that I feel will add the greatest value for me, besides the
> cross-platform capabilities, is the "build products go outside the
> source tree" philosophy - that I can basically choose where I want the
> build products (and the OS-specific makefiles/project files) to go,
> just by choosing where I run the cmake command. I really want to not
> break this freedom while solving the problems that I have.
> 
> I'm working on making a suggestion at my company to move to cmake for
> our building needs, but I'm stuck on coming up with a cmake-way of
> handling some of the aspects of juggling more projects, targets and
> versions of them at the same time.
> 
> Bear with me, I can't say that I've dug through everything there is to
> know about cmake, so if I need to just RTFM, that is a suitable
> answer, just point me to some specific command man pages that will
> help me.
> 
> The scenario I wish to handle in an elegant way, is this:
> 
> Suppose a company is working on 4 projects: App_A, App_B, Lib_C and Lib_D.
> 
> The directory structure is very simple:
> 
> Top
> 
>  |-App_A
>  |-App_B
>  |-Lib_C
>  |-Lib_D
> 
> Every one of the App/Lib folders has the following structure inside them:
> 
> App_X/Lib_X
> 
>  |-include (for libs only, this is where the interface they expose to
> 
> the outside world goes)
> 
>  |-src
>  |-tests
>  |-CMakeLists.txt

Are App_A, App_B, Lib_C and Lib_D all together in one repository, so you 
always get the whole thing checked out from your version control system, or 
are they independent ?

If they are one big thing, then just make them work with a top level 
CMakeLists.txt.

But it seems they aren't.

So, I assume they are in 4 different repositories, right ?

Then, of course, each of them must build alone cleanly.
When App_A is built, it must do a find_package() for Lib_C, when App_B is 
built, it must do a find_package() for Lib_D, etc.
So they must be built and installed before.

To make building all 4 at once easier, you could set up a CMakeLists.txt which 
only consists of ExternalProject_Add() calls for the four projects.
This fetches the sources from cvs/svn/git, configures and builds them.
There you can also enter from which branch or tag it should fetch.

Did you have a look at this already ?

Alex


More information about the CMake mailing list