Wednesday, September 8, 2010

CMake tips

CMake is a cool tool to perform cross-platform system for build automation. But sometime you want a better control through the command line. For example you are on a linux 64 bit machine and by default you will compile 64 bits binaries. So if you want to compile 32 bits binaries on a 64 bits machine you have to use some parameters to configure CFLAGS, CXXFLAGS:

How to control compiler flags :

If you want to specify your own compiler flags, you can
Set environent variable CFLAGS, CXXFLAG


When providing own compiler flags, you might want to specify CMAKE_BUILD_TYPE as well.

 For example if you want to do release build for 32 bit on 64 bit Linux machine ,you do cmake -DCMAKE_C_FLAGS=-m32 --DCMAKE_CXX_FLAGS=-m32

Additionally you could use the -DCMAKE_BUILD_TYPE keyword.

Tips found here

No comments:

Post a Comment