It is difficult for the build system to enforce adding the Boost headers include directory only for targets that actually need it. In CMake this is handled via the Boost::headers target. However, the issue is not specific to CMake.
The underlying problem is that any dependency of a given build target brings its own include directories, which often coincide with include paths used by Boost. As a result, dependencies such as libevent or sqlite can mask the fact that a target is missing an explicit dependency on Boost::headers.
While we cannot influence the installation layout of system packages, we can control the layout of packages built by the depends build subsystem.
This PR therefore changes the layout of the boost package in depends from a “system” layout to a “versioned” one. The Boost include directory becomes more specific by incorporating the boost-<version> component in its path.
Applying this change alone to the master branch exposes a latent bug in the build system. This bug is potentially dangerous because, when building with depends, Boost headers from the system include directory may be used instead of the headers provided by depends, as the compiler may implicitly search system include paths.
The exposed bug is addressed in the first commit of this PR.