Boost logo

Boost :

Subject: Re: [boost] [cmake] Pull request announcement
From: Alexander Grund (alexander.grund_at_[hidden])
Date: 2018-09-20 08:42:59

> Easiest thing to do here is in each project's CMakeLists.txt file, use a
> standard naming
> convention to hoist the public include directory up to the superproject. I
> would macro-ize
> the dependency definition and building of the dependency header list, like:
> in libs/uuid/CMakeLists.txt:
> boost_depends_on ( serialization throw_exception )
> Which would in turn set:
> (and if those had link libraries, which would be identified by another
> variable of some sort, it would add to the link library list needed)
> The project itself would set the variable BOOST_UUID_HEADERS as:
> This defines BOOST_UUID_HEADERS one level up - in the "libs" project. This
> variable now contains all of the include
> paths needed build anything that depends on uuid.
> In each dependent project, adding the following allows for access to the
> headers:
> boost_depends_on ( uuid )
> which as part of the macro would run:
> include_directories ( ${BOOST_UUID_HEADERS} )
Definitely NOT. What you describe here is already part of modern CMake:
You use targets:

add_library(boost_serialization INTERFACE)
target_include_directories(boost_serialization INTERFACE include) #

and in uuid:
add_library(boost_uuid src/mysrc.cpp)
target_include_directories(boost_uuid PUBLIC include)
target_link_libraries(boost_uuid PUBLIC boost_serialization)

This basically does the same as your macros and stuff but in the modern
CMake way where CMake resolves all dependencies. For cases where you may
not have e.g. the boost_serialization target yet one may assume to be
run as part of the super-boost project and do this instead:

add_library(boost_uuid src/mysrc.cpp)
target_include_directories(boost_uuid PUBLIC include

Or better: Define the target yourself: if(NOT TARGET
boost_serialization) add_library(boost_serialization IMPORTED) ...

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