Boost logo

Boost :

Subject: Re: [boost] Proposal for moving Boost to CMake
From: Thomas Heller (thom.heller_at_[hidden])
Date: 2017-06-22 08:31:30


On Thu, Jun 22, 2017 at 3:48 AM, Peter Dimov via Boost <
boost_at_[hidden]> wrote:

> Louis Dionne wrote:
>
> And here's a minimal XYZConfig.cmake file for a library with compiled
>> sources (I added source files to Hana and turned it into a static library
>> to check this):
>>
>> https://gist.github.com/ldionne/df7b6888752097e25bfc2333f6d8
>> 97ca#file-minimal-handwritten-config-static-cmake
>>
>
> To get back to this... it ain't so easy. On Linux, where the default is
> --layout=system, you indeed can only have libhana.a and libhana.so (a link
> to libhana.so.1.65.0 or something like that).
>
> But on Windows, `b2 --build-type=complete --with-system toolset=msvc-14.1`
> gives you this:
>
> boost_system-vc141-mt-1_65.dll
> boost_system-vc141-mt-1_65.lib
> boost_system-vc141-mt-gd-1_65.dll
> boost_system-vc141-mt-gd-1_65.lib
> libboost_system-vc141-mt-1_65.lib
> libboost_system-vc141-mt-gd-1_65.lib
> libboost_system-vc141-mt-s-1_65.lib
> libboost_system-vc141-mt-sgd-1_65.lib
> libboost_system-vc141-s-1_65.lib
> libboost_system-vc141-sgd-1_65.lib
>
> and of course compiling with a different toolset would give you the
> appropriate, different, names. You can have all of these installed
> simultaneously.
>
> So boost_system-config.cmake needs to be slightly more elaborate.
>

One way to go here is to have one Config.cmake for each build type. For
example structured like this:
lib/cmake/boost-vc141-mt-1_65-dynamic/boost_system-config.cmake
lib/cmake/boost-vc141-mt-1_65-static/boost_system-config.cmake
lib/cmake/boost-vc141-mt-gd-1_65-dynamic/boost_system-config.cmake
lib/cmake/boost-vc141-mt-gd-1_65-static/boost_system-config.cmake
lib/cmake/boost-vc141-mt-s-1_65-dynamic/boost_system-config.cmake
lib/cmake/boost-vc141-mt-s-1_65-static/boost_system-config.cmake
lib/cmake/boost-vc141-mt-sgd-1_65-dynamic/boost_system-config.cmake
lib/cmake/boost-vc141-mt-sgd-1_65-static/boost_system-config.cmake

The user could then point BOOST_ROOT to the directory of her choice (or
other choices as described here:
https://cmake.org/cmake/help/v3.9/command/find_package.html#command:find_package
).
An alternative to this would be to play a guessing game based on
CMAKE_CXX_COMPILER_ID and friends. And, in addition, let the user choose
which variant (gd, s or sgd) to choose (with a sensible default) under:

lib/cmake/boost/boost_system-config.cmake

with a content similar to this (pseudo code from the top of my head):

if(USER_VARIANT)
  include(../boost-${USER_VARIANT}/boost_system-config.cmake)
elseif(MSCV_VERSION EQUALS 1900)
  include(../boost-vc141-${VARIANT}/boost_system-config.cmake)
elseif(... more compiler checks ....)
  ....
else()
 message(FATAL_ERROR "could not guess version and no user specified one
set")
endif()

This should give maximal flexibility for power users with an easy and
convenient entry point that most of the time works.

>
> _______________________________________________
> 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