Boost logo

Boost :

From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2021-05-28 15:08:37


On 5/28/21 5:20 PM, Adam Wulkiewicz via Boost wrote:
>
> Should optional dependencies be listed?
> I'm asking because we provide optional files for adapting e.g. Polygon
> models to use them with Geometry. The same is or will be true for
> Variant, Variant2 and Any. R-tree support for serialization is optional
> as well and enabled with #ifdef. The extensions are optional and exists
> only in develop branch. Etc.

Peter already answered this, but I can add that you could conditionally
add optional dependencies in CMake by checking the environment and/or
user configuration options and call target_link_libraries only when
needed. You can see an example in Boost.Filesystem:

https://github.com/boostorg/filesystem/blob/develop/CMakeLists.txt

> Are these dependencies only for includes or also for tests, examples and
> sources from documentation?

The CMakeLists.txt that is in the root library directory is used when
the library is built or consumed by users. So, the PRIVATE dependencies
are those required to build the library (but not to consume it) and
PUBLIC - those required to consume it. IOW, the dependencies from source
files normally go in PRIVATE section and from headers - in PUBLIC. Tests
and examples are not described there.

For tests and examples there may be separate CMakeLists.txt (in test/
and example/) that would describe their respective dependencies,
including on the library itself. Those CMakeLists.txt are not required
to build or consume Boost, so currently are not mandatory.


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