Boost logo

Boost :

From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2021-06-03 13:54:57


Hi,

I've been having this problem with CMake in Boost.Filesystem, where I
need to have the Boost::library targets available before
Boost::filesystem target is defined. This is needed in order to perform
configuration checks that will affect how Boost::filesystem will be
defined. For example, see the check_cxx_source_compiles calls:

https://github.com/boostorg/filesystem/blob/af6ac28b5785820b93a2af7dd6e9b801232fec19/CMakeLists.txt#L23-L50

For the check_cxx_source_compiles calls, I would have liked to add
targets like Boost::config and Boost::winapi to CMAKE_REQUIRED_LIBRARIES
so that the checks are compiled with include directories of those
dependencies added in the command line. This doesn't work because these
targets may not be defined at the point when the configuration checks
are performed.

My current workaround, as you can see, is to add the Boost root to
CMAKE_REQUIRED_INCLUDES, where the boost directory with the common
headers tree is located. However, this will not work if we're going to
make that directory optional or remove it. Also, you can see that I'm
reusing checks implemented in Boost.Config, for which I also had to hard
code its relative location from Boost.Filesystem. If we're going to
allow different libraries located in separate directory trees, this will
also break.

My question is, can this be fixed and how?

I was wondering if it is possible to make the target generation
two-stage, where the first stage identifies library locations, including
directories with their headers, and the second stage would define build
targets. This way all library directories would be available to the
second stage. Although I can already see the problem with second order
dependencies with this approach...


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