[cmake-developers] CMake API for warnings

Brad King brad.king at kitware.com
Tue Mar 29 10:24:20 EDT 2016


On 03/29/2016 09:09 AM, Ruslan Baratov wrote:
> As a general note obviously I've used another approach because I decide 
> to create CMake module which can be used with regular CMake versions :) 
> Of course implementing this in CMake "from the box" is best.
> 
> Are we talking about levels only or about control of exact kind of 
> warnings too (like `-Wswitch`/`-wswitch`/`-Werror=switch`)?

At a minimum we should support levels (e.g. all, default, none) that
are generic enough to have mappings to flags on every compiler.  Later
one could consider more granular switches with enumerated options that
may not all have flags on every compiler.  OTOH many such switches are
so specific that they should not be abstracted and can instead be
added to COMPILE_OPTIONS with a $<C_COMPILER_ID:...> genex guard.

I think these warning properties should perhaps be done as usage
requirements with propagation through INTERFACE_* properties.  I'd
need to see some example use cases spelled out though.

Once such directory/target properties are available then we could look
at making them take over the role of providing default warning flags
instead of putting them in the CMAKE_<LANG>_FLAGS* variables.  That may
need a policy as you pointed out earlier.

-Brad


More information about the cmake-developers mailing list