Boost logo

Boost :

Subject: Re: [boost] CMake Modularization
From: elzairthesorcerermailinglist (elzairthesorcerermailinglist_at_[hidden])
Date: 2016-09-27 16:23:29


> It is always beneficial to give a detail account of what you are actually
doing. Otherwise your chances of interesting
> people in what you have done will be less than it could be despite the
examples you have given below.

Alright, I want to make boost more modular and easier to use. Many modules
are header-only, so they are quite easy to
use: you can just copy the headers from their repository and drop them into
your project. However, a lot of interesting
functionality (i.e. the filesystem module, the fibers module, the regexp
module, etc.) requires building libraries. AFAIK this
requires having/learning about JAM, BJAM, Boost.Build and other
non-standard tools. It also requires downloading the
whole main boost repository. I guess the only way around that would be
including .dlls, .dylibs or .sos you got from your package manager into
your project.

Suppose we have a project named foo that wants to use Boost.Filesystem. It
has the following file structure.

foo/
  CMakeLists.txt
  3rdpartylibs/
    CMakeLists.txt
  bar.cpp

I want to make using Boost.Filesystem (or any other boost module) as simple
as dropping the module and all of its dependent modules into the
3rdpartylibs folder and updating 3rdpartylibs/CMakeLists.txt with the
following code.

    add_subdirectory(config)
    add_subdirectory(assert)
    add_subdirectory(core)
    add_subdirectory(system)
    add_subdirectory(filesystem)

Then the user only needs to add the following to the main CMakeLists.txt

add_subdirectory(3rdpartylibs)
project(foo)
include_directories(${BOOST_INCLUDE_DIRS})
add_executable(foo bar.cpp)
target_link_libraries(foo ${BOOST_LIBRARIES})

Then, the modules can be built along with the rest of your code.

On Tue, Sep 27, 2016 at 2:26 PM, Edward Diener <eldiener_at_[hidden]>
wrote:

> On 9/27/2016 11:04 AM, Philip Woods wrote:
>
>> CMake is a widely used build system and has become for many the de facto
>> standard. Boost is a
>> widely used collection of modules and has become for many part of the de
>> facto standard.
>> However, the two do not play very well together. I know there is another
>> port of boost to CMake, but
>> it has lain dormant for years and uses an old version of boost; plus I
>> chose to take a different route.
>> The old project attempted to completely replace Boost.Build with CMake. My
>> example port simply
>> allows people to more easily use boost modules in their projects.
>>
>
> It is always beneficial to give a detail account of what you are actually
> doing. Otherwise your chances of interesting people in what you have done
> will be less than it could be despite the examples you have given below.
>
>
>> I created an example project
>> https://github.com/Elzair/cmake-boost-filesystem-test to demonstrate
>> my ideas. I added CMake build support to the minimum number of modules
>> needed to support this
>> demo: https://github.com/Elzair/assert https://github.com/Elzair/config
>> https://github.com/Elzair/core
>> https://github.com/Elzair/filesystem/tree/master and
>> https://github.com/Elzair/system
>>
>> I even added CMake build support to the header only boost libraries. I did
>> this for two reasons.
>> First, I did not want users to have to fool with CMake's find_package().
>> Second, I wanted to add
>> helpful error messages in case a user has not included all of a module's
>> dependencies (or added
>> them in the wrong order).
>>
>> Would the community be interested in modular CMake support for more
>> modules? Any comments, questions, critiques or suggestions are welcome.
>>
>
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman
> /listinfo.cgi/boost
>


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