CMake II

Last part was about installing, this part is all about command line options. First take a look at the output from regular cmake, building RSIBreak:

[img_assist|fid=44|thumb=0|alt=default cmake]

Not quite what we used to have with unsermake ;-).

First the important stuff. Colors. We can add a parameter to CMake that is responsible for that. Try something like:


cmake -DCMAKE_INSTALL_PREFIX=/opt/kde -DCMAKE_COLOR_MAKEFILE:BOOL=true ../rsibreak

You can also see, I also included a prefix now. This command will result in colors, but remember that when there is a cache file, some changes to the command line won’t take effect. You need to clean the cache first. rm CMakeCache.txt in the build dir.

The result like this:

[img_assist|fid=47|thumb=0|alt=color cmake]

But you can hardly see the colors due to those horrible “Foo has virtual functions but non-virtual destructor”. Well, they have a purpose of course, but I’m not really keen on seeing the same warning everytime I compile it.

So I want to turn that off. For that I would actually want to pass “-Wno-non-virtual-dtor”. I combined that with selecting the debug level. So my syntax would be:


cmake -DCMAKE_INSTALL_PREFIX=/opt/kde -DCMAKE_COLOR_MAKEFILE:BOOL=true -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="${CMAKE_CXX_FLAGS_RELWITHDEBINFO}-Wno-non-virtual-dtor" -DCMAKE_BUILD_TYPE=relwithdebinfo ../rsibreak

Here I choose relwithdebinfo as build type. Other types are described in the wiki, which can help you even more btw.

The output with this command is:

[img_assist|fid=50|thumb=0|alt=good cmake]

That is something I can live with! There is one more build scenario which I use, that is –enable-final. If you want that, add “-DKDE3_ENABLE_FINAL:BOOL=true” to the command line.

As that is not nice to type in each time, I made two aliasses in my .bashrc:


alias cm='cmake -DCMAKE_INSTALL_PREFIX=/opt/kde -DCMAKE_COLOR_MAKEFILE:BOOL=true -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="${CMAKE_CXX_FLAGS_RELWITHDEBINFO}-Wno-non-virtual-dtor" -DCMAKE_BUILD_TYPE=relwithdebinfo'
alias cm2='cmake -DCMAKE_INSTALL_PREFIX=/opt/kde -DCMAKE_COLOR_MAKEFILE:BOOL=true -DKDE3_ENABLE_FINAL:BOOL=true'

Then you can build stuff with “cm ../rsibreak”.

Comments are closed.