[CMake] make CFLAGS= support

Mathieu Malaterre mathieu.malaterre at gmail.com
Wed Mar 11 05:25:01 EDT 2009


On Wed, Mar 11, 2009 at 9:52 AM, Vladimir Prus <ghost at cs.msu.su> wrote:
>
> Hello,
> I have cmake version '2.6-patch 2', and after I generate makefiles,
> and build with
>
>        make CFLAGS=-O2
>
> I don't see -O2 being used in the compiler command line. Is this
> the expected behaviour?
>
> I realize that CFLAGS is a automake convention, so I am not saying cmake
> should support it, but I wanted to check if maybe I have old CMake version,
> or something.

This is the expected behavior. You need to run:

 $ CFLAGS=-02 CXXFLAGS=-03 cmake /path/to/src && make

cmake is doing system inspection so it is extremely important that
both compiler and compiler flags are set prior to the very first cmake
configuration step (it will deduce pointer size for instance which
could be changed using different compiler flags)

2cts
-- 
Mathieu


More information about the CMake mailing list