[CMake] How to set compiler flags?

David Aldrich David.Aldrich at EU.NEC.COM
Tue Sep 28 11:35:50 EDT 2010


Hi

I am writing CMakeLists.txt files for my C++ application. Initially I set the C++ compiler flags by setting CMAKE_CXX_FLAGS:

set( CMAKE_CXX_FLAGS "-Wall -m64 -O3 " )

Then I realised that those flags get passed to the linker as well, which seemed a bit untidy. So I now use add_definitions instead:

add_definitions( "-Wall -m64 -O3" )

Is there a better way of doing this?

My CMakeLists.txt files only handle a release build currently. If you could give me a hint for how to go on to add a debug build option, I would be grateful.

Best regards
David

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100928/4dbf83f0/attachment.htm>


More information about the CMake mailing list