C++ Logo

sg10

Advanced search

Re: [SG10] A view from CMake

From: Stephen Kelly <steveire_at_[hidden]>
Date: Tue, 03 Jun 2014 10:01:46 +0200
Nelson, Clark wrote:

>> Regarding the note here:
>>
>> https://isocpp.org/files/papers/n4030.htm#detail.cpp14.n3323
>>
>> Clang fails to compile code relying on the described contextual
>> conversions unless invoked with -std=c++1y.
>>
>> CMake has an explicit feature listing for that to allow the 'fail
>> early'
>> use-case where that feature is relied upon. Other features not
>> listed in
>> SD6 may be used explicitly in the CMake functionality for the same
>> reason.
>
> It wasn't until I read this that I realized that CMake is actually trying
> to solve a very different problem than SG10 is trying to solve.
>
> CMake wants to quickly predict when a build is going to fail eventually,
> due to the lack of support for a new feature.

That is one of the three use-cases that I listed explicitly at the top of my
mail and linked to documentation about, yes.

The other two use-cases listed in my mail and in the linked documentation
are:

 * Use feature if available (ie, what SD6 is concerned with)
 * Define buildsystem (include directories, linked libraries etc differently
depending on feature availability.

All three use-cases depend on the existence of a single canonical list of
features available for a particular compiler. All three use-cases simply
process the list of available features slightly differently.

The list of features is generated by compiling a file which will in the
future use the __cpp_foo macros in order to get that information 'up a
layer' into the CMake logic, from where all three use-cases can be
implemented (including the SD6-concerned optional-feature-use-case).

> What SG10 is trying to do is enable people to write code that will work
> either with or without a new feature.

Yes. That is also one of the three separate goals of the CMake 'compile
features' functionality.

However, in order to implement it, we need to 'lift the list of features' up
to the context of CMake from the compiler. I think this doesn't have an
impact from a point of view of the content of SD6. I described it for
completeness and because it is a use-case of the SD6 recommendations which
may not be immediately obvious.

> The goal of CMake in this regard is a good one, but because it's not the
> same as that of SG10, there can very reasonably be cases in which
> different conclusions will be correct about whether a test for a specific
> change is justified. Contextual conversions may well be such a case.

Yes, that is all true. Still - I provide the input and feedback in case it
is useful, and even if it does not mutate the recommendations :). I'll leave
you to decide what to recommend after considering all the feedback.

Thanks,

Steve.

Received on 2014-06-03 10:01:52