[CMake] Global compiler flags

Daniel Stonier d.stonier at gmail.com
Sun Mar 25 03:22:28 EDT 2012


What is the preferred way to set global compiler flags?

I'd usually set this in CMAKE_CXX_FLAGS, but I'm building a cmake project
that is not mine, so I don't have access to their CMakeLists.txt files. My
first thought was to configure it in an initial cache file, but that
disrupts the sequence of events that leads to platforms putting flags in
CMAKE_CXX_FLAGS (in this case /DWIN32 in Windows-cl.cmake).

The one workaround I have at the moment is to define
CMAKE_USER_MAKE_RULES_OVERRIDE and define CMAKE_CXX_FLAGS_INIT in there.
It's an awkward place to have to set something as common as some global
compiler flags though.

Regards,
Daniel.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120325/4ad67d99/attachment.htm>


More information about the CMake mailing list