[CMake] How to set compiler flags?

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


On 1. Oct, 2010, at 11:17 , fatman at crackmonkey.us wrote:

> 
> On Fri, 1 Oct 2010 11:05:34 +0200
> Michael Wild <themiwi at gmail.com> wrote:
>>> 
>>> 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)
>> 
>> The problem with this is that the cache makes the promise to the user
>> that he can change the flags and you break it.
> 
> Sorry, I didn't understand that. I'm new to CMake. I'll go read up on
> the cache now.
> 
> If I'm the only user, is this a problem?
> 
> Regards,
> Adam J Richardson


If you're ever going to be the only user, then probably no.

The cache is where CMake stores its persistent data and where the user makes changes to the settings (e.g. installation prefix, location of a certain library, include directory for a certain library, location of an executable, compilation flags, build type etc.). It is located in the CMakeCache.txt file.

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/d61bb64c/attachment.pgp>


More information about the CMake mailing list