Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2024-12-17 16:26:04


Chuanqi Xu wrote:
> For authors of libraries, after boost introduce modules, you only need to do 2
> extra things:
> - In headers, add a macro (assume its name as BOOST_MODULE_EXPORT,
> which will be ‘export’ conditionally) to the entities that need to be exported.
> - In headers, include standard headers and other dependent headers
> conditionally so that we don’t include anything if the headers are in a module
> unit. e.g.,
> https://github.com/boostorg/pfr/blob/f09e6aeae9d050897fff72b93d5f5e866cc5e11a/include/boost/pfr/detail/for_each_field.hpp#L12-L16

For a header-only library with no dependencies, you can basically do whatever
you like, but in the general case you'd have something like

#ifdef BOOST_USE_MODULE_CORE
import boost.core;
#else
#include <boost/core/this.hpp>
#include <boost/core/that.hpp>
#endif

repeated for every library you #include things from.

And the end user will have to do this too.

I'm also not quite clear on how things will work on the CMake side. I can
envisage the add_subdirectory case working, more or less, but what would
(or needs to) happen when Boost is _installed_ via CMake, with module
support enabled?

And how will it then be consumed on the user side, after find_package?

Also, we're basically talking Clang-only here, right? GCC doesn't work and
MSVC... may or may not work?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk