[CMake] How to create and execute new configuration like debug/release.

Philip Lowman philip at yhbt.com
Tue May 13 00:55:27 EDT 2008


On Mon, May 12, 2008 at 5:44 AM, no name <niezgod at gmail.com> wrote:

> Hello.
>
> 1. Actually my first question is simpler. How can I generate makefiles for
> debug/release configurations (which as far as I can understand should be
> possible in default)
> I am generating makefiles with a command :
>
> cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug .
>
> then when I execute mingw32-make with created makefile and it seems to
> ignore enything regarding debug configuration. If I generate makefiles with
> -DCMAKE_BUILD_TYPE=Release genereted makefiles are exactly the same.


That is surprising.  What you did should work.  I would verify the compiler
flags are the same by typing "mingw32-make VERBOSE=1" at the command line.

Seems to generate the proper flags for me (on CMake 2.6.0), perhaps it's
something you're doing in your CMakeLists?

Trivial CMakeLists.txt:
PROJECT(foo)
ADD_EXECUTABLE(foo foo.cc)

Running Cmake with -DCMAKE_BUILD_TYPE=Debug compiles like this:
C:\MinGW\bin\g++.exe    -g   -o CMakeFiles\foo.dir\foo.cc.obj -c
"C:\Documents and Settings\Philip Lowman\test\foo.cc"

Running Cmake with -DCMAKE_BUILD_TYPE=Release compiles like this:
C:\MinGW\bin\g++.exe    -O3 -DNDEBUG   -o CMakeFiles\foo.dir\foo.cc.obj -c
"C:\Documents and Settings\Philip Lowman\test\foo.cc"


>
> 2. How to create new build type? For now I have this
> http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_extend_the_build_modes_with_a_custom_made_one_.3Ffrom cmake faq which should solve the problem when I'll be able to generate
> DIFFERENT makefiles for those configurations.


That guide should work fine if you need a custom build solution using a
single release configuration generator (aka the Makefile generator).

3. Is it possible to generate one makefile with separate targets for
> debug/release/myconfiguration ? The one that I could use like:
>
> make debug
> make release
> make my_configuration
>
> I am using cmake version 2.6.


Oddly enough I came across a feature request for this on the bugtracker a
few days ago when I was investigating a rather interesting looking hot-pink
colored bug.
http://public.kitware.com/Bug/view.php?id=5946

I'm not sure if this is even a feature that the CMake developers would be
willing to add.  It has been said on this mailing list plenty of times that
it's very easy to work around the problem with out-of-source build
directories.  You can even use a shell script to automate stuff:

#!/bin/sh
# A shell script in the root of your source tree.
mkdir build.debug
cd build.debug
cmake -DCMAKE_BUILD_TYPE=Debug ..
cd ..
mkdir build.release
cd build.release
cmake -DCMAKE_BUILD_TYPE=Release ..
cd ..

-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080513/81012b52/attachment.htm>


More information about the CMake mailing list