[cmake-developers] CMake API for warnings
Brad King
brad.king at kitware.com
Thu Mar 31 09:37:57 EDT 2016
On 03/29/2016 11:24 AM, Ruslan Baratov wrote:
>> 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.
> What about generating nothing for such cases?
Yes, that makes sense. I was just discussing alternatives. Simon's
post contains an example of a granular flag that makes sense to try
to abstract.
>> 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.
> But not if target is installed. It will be quite inconvenient if 3rd
> party package add some flags to local targets. Is it possible to support
> it from the box?
Yes, let's skip propagation until a valid use case is raised in the
future, if any. Likely the directory properties can be used to specify
project-wide warning configurations without propagating across targets.
> What about this:
>
> compile_warnings # modify directory properties
> target_compile_warnings # modify target properties
> sources_compile_warnings # modify source properties
Let's start by getting the directory/target/source properties worked
out. First we need to figure out how to make the properties work with
language-specific warning flags and such. We can add command porcelain
for them later.
> Same API for all:
>
> *_compile_warnings(<global/target/source> DISABLE <warning-id>
> ENABLE <warning-id> TREAT_AS_ERROR <warning-id>) # may be plus 'APPEND'
> for extending instead of overwriting (?)
Somehow this needs to be encoded in a COMPILE_WARNINGS property or
group of properties. They should support generator expressions for
per-configuration warnings.
> General warning-id's:
>
> * ALL
> * DEFAULT
> * LEVEL<N>
And `NONE`.
> Group warnings-id's:
Yes, but either the warning names or the property names will need to
allow for language-specific warnings. We need to be able to control
warnings for C, C++, Fortran, etc. separately. OTOH it would also
be nice to be able to set C and C++ warnings together since many of
them are common.
Ideas?
-Brad
More information about the cmake-developers
mailing list