[CMake] How to set compiler flags?

Michael Wild themiwi at gmail.com
Fri Oct 1 06:42:28 EDT 2010


On 1. Oct, 2010, at 11:23 , David Aldrich wrote:

> Hi
> 
>> 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)
> 
> As a total non-expert I don't see how this will work because if build type is "Debug" then CMake will use CMAKE_CXX_FLAGS_DEBUG not CMAKE_CXX_FLAGS.
> 
> Am I right?
> 
> Best regards 
> 
> David 

Wrong. CMAKE_CXX_FLAGS is always used, the configuration-specific values are appended to it.

Michael
-------------- 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/2e56b113/attachment.pgp>


More information about the CMake mailing list