[CMake] How to set compiler flags?

Michael Wild themiwi at gmail.com
Fri Oct 1 05:05:34 EDT 2010


On 1. Oct, 2010, at 10:50 , fatman at crackmonkey.us wrote:

> 
>> Date: Wed, 29 Sep 2010 03:14:57 +0200
>> From: Michael Hertling <mhertling at online.de>
>> Subject: Re: [CMake] How to set compiler flags?
>> To: cmake at cmake.org
>> Message-ID: <4CA29311.1050909 at online.de>
>> Content-Type: text/plain; charset=ISO-8859-1
>> 
>>> [...] So I now use add_definitions instead:
>>> 
>>> add_definitions( "-Wall -m64 -O3" )
>>> 
>>> Is there a better way of doing this?
>> 
>> Don't do this at all, and adhere to the flags.
>> 
> 
> Interesting - I've been doing this:
> 
> if(CMAKE_BUILD_TYPE EQUAL Debug)
>   set(CMAKE_CXX_FLAGS -Wno-long-long -Wno-comment -Wwrite-strings
> -std=c++0x -pedantic-errors -pedantic -Wall -W -g -gdwarf-2 -Weffc++
> -Wmain -Wextra)
> else(CMAKE_BUILD_TYPE EQUAL Debug)
>   set(CMAKE_CXX_FLAGS -s etc)
> endif(CMAKE_BUILD_TYPE EQUAL Debug)
> 
> because it never occurred to me to do it another way.
> 
> Is this wrong too?
> 
> Regards,
> Adam J Richardson

The problem with this is that the cache makes the promise to the user that he can change the flags and you break it.

Michael

--
There is always a well-known solution to every human problem -- neat, plausible, and wrong.
H. L. Mencken

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
URL: <http://www.cmake.org/pipermail/cmake/attachments/20101001/0e72a821/attachment.pgp>


More information about the CMake mailing list