[cmake-developers] CMake API for warnings

Brad King brad.king at kitware.com
Tue Apr 5 10:03:16 EDT 2016


On 03/31/2016 12:47 PM, Ruslan Baratov wrote:
> What about 3 properties containing list of <warning-id>'s (groups 
> unexpanded):
> 
> * COMPILE_WARNINGS_DISABLE # e.g. "shift-sign-overflow;unused"
> * COMPILE_WARNINGS_ENABLE # e.g. "ALL"
> * COMPILE_WARNINGS_TREAT_AS_ERROR # e.g. group + specific: "inline;undef"

We would need to define behavior when a warning appears in more than
one list.  Perhaps we need to define some kind of `=on/off/error/no-error`
syntax for each list entry.

The name "ALL" may not be representative.  Even -Wall does not really enable
all possible warnings on some compilers.  I'd like to find another name that
captures the idea of enabling most warnings.  Or we could try to subsume it
into an interface for the warning level, with -Wall considered "high".

> I'm not sure about mixing more languages. I think it will be similar to 
> COMPILE_OPTIONS (?), see no language specification in 
> `add_compile_options` command.

Right.  We do have the COMPILE_LANGUAGE genex for some limited use cases.
Its documentation even includes a COMPILE_OPTIONS example.  However, it
also documents that it is not possible to implement fully on VS IDE
generators.  For example, VS does not distinguish between C and C++
flags.  The same set is always used for both.

Another option is to have the warning names themselves have a language
in them, similar to the COMPILE_FEATURES names.

-Brad



More information about the cmake-developers mailing list