Boost logo

Boost :

Subject: Re: [boost] Boost CMake support - Request for Comment
From: Roger Leigh (rleigh_at_[hidden])
Date: 2018-10-10 08:44:58

On 09/10/2018 23:42, Edward Diener via Boost wrote:
> On 10/9/2018 7:09 PM, mike via Boost wrote:

>> As Richard pointed out, such features exist in cmake too and have been in
>> common use for years. E.g. It has a built-in mechanism that lets you
>> directly query for most of the post c++03 compiler features:
>> (
>> and as a more general feature, you can always check if a particular
>> source
>> file using some feature or type compiles or not:
>> (
>> Could you maybe point me to some examples where this feature is used
>> so one
>> could estimate how difficult a conversion is?
> The feature is essentially programmed by config and predef to provide
> build-time testing of compiler support and testing of such things like
> the OS versions and compiler versions etc. See
> for the explanation in config and
> for checking predef values at build time. The basics of the feature are
> offered by Boost Build as explained at
> in reference to the check-target-builds rule. Plenty of libraries use
> the feature during testing and I imagine that some of them may use the
> feature during building. Asking individual libraries to convert their
> tests or build to use some CMake equivalent, for every possible setting
> in config and predef which they use, is not realistic. I understand that
> CMake may have an equivalent technique, but who is going to program that
> technique to offer all the equivalents which config and predef currently
> offer ?

This is all supported by CMake for years as mike said, and it's utterly
trivial to write such feature tests. If you would like some examples,
here's some I wrote for Xerces-C++:

For example, here's a simple test for const [it's a port of Autoconf
logic] with CheckCXXSourceCompiles:
this could be adapted for any feature you care to check, from constexpr
to user-defined literals, or any other feature which can be checked by
running the compiler.

This is a set of checks for integer type sizes:

This is a more complex set of checks for SSE intrinsics:

Here's some checks to verify Boost is working properly:

Testing of linker version scripts:

Checking include presence:

Checking compiler keyword presence and fallbacks:

Checking structure presence:

Checking library symbol exports:

I don't think any of this is difficult. If anything, you can likely
reuse the existing source code used by the Boost.Build checks, maybe
even sourced directly without any changes--just wrap it with
check_cxx_source_compiles or other feature test macros.


Boost list run by bdawes at, gregod at, cpdaniel at, john at