[CMake] CMake single-configuration makefiles

Eric Noulard eric.noulard at gmail.com
Sun Nov 13 17:30:00 EST 2011


2011/11/13 Robert Dailey <rcdailey at gmail.com>:
> I understand that currently Makefiles generated by CMake are
> single-configuration by-design. In other words, you can't issue a "debug" or
> "release" command to make, you have to regenerate for a different
> configuration.

For this purpose you can use 2 build trees that use the same source tree

cd /path/to/source
mkdir dbuild
cd dbuild
cmake -DCMAKE_BUILD_TYPE=Debug ..
cd ..
mkdir rbuild
cd rbuild
cmake -DCMAKE_BUILD_TYPE=Release ..

now to build debug
cd dbuild; make

and to build release
cd rbuild; make

> Can someone explain the reason for this design?

Don't know in the past I used makefile that can deal with multiple config,
everytime it was a "re-entrant" makefile scheme. May be this should be
avoided in order to produce 'portable' makefiles?

> Are there any plans to  change it?

Don't know.
But may be it would be nice to have a way to create
"several build trees" at one time for that and produce a unifying
top level makefile that drive them all.

> I'm new to Makefiles so I'm curious to learn as much as possible
> about it.

If you are new to makefile may be you can have a look at
the chapter 4 of this book
http://www.informit.com/store/product.aspx?isbn=0130091154

it is about GNU make but it contains valuable introduction to "makefile"
and the book may downloaded:
http://ptgmedia.pearsoncmg.com/images/0130091154/downloads/0130091154.zip

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org


More information about the CMake mailing list