[CMake] Boost + CMake + Windows + Sanity -> Possible?

Wheeler, Gavin gavin.wheeler at kcl.ac.uk
Thu Jul 12 06:10:16 EDT 2018


Hello! First the short version...

Can anyone give me a set of instructions to download, build and setup the latest Boost (currently 1.67) on Windows 10 for VS 2017 64bit such that the following will work...

    find_package(Boost REQUIRED COMPONENTS system filesystem thread date_time iostreams)
    include_directories(${Boost_INCLUDE_DIRS})
    link_directories(${Boost_LIBRARY_DIRS})

Including...

- Steps to follow when building and installing Boost
- What environment variables to set and what to set them to, e.g. boost, boost library, boost include directories
- What to set in the CMake file so that Boost will be correctly included

I ask about building Boost as well as CMake because it seems to me that unless Boost is built in a way that matches CMake expectations it just won't work.

Some background...

I've inherited a project with the above in, along with depndencies on ITK, VTK and zlib - all of which I have set up in CMake OK. However, Boost appears to be immune to working with CMake. There are various suggestions on the web, but nothing consistent, and nothing I've found whcih will work.

I've spent 2 days building Boost (this isn't solely due to CMake, the Boost build instructions are all over the place and their latest installer contains a trojan according to Windows defender) and configuring CMake in various ways, getting frustrated setting various environmental variables, and the nebulous target that is a Boost source install.

I can fix this by manually setting all of the library paths and doing some fixing up in the resultant project files, but I shouldn't really have to.

Surely it shouldn't be this difficult! Hopefully if there is a clear set of instructions from start to finish it will save others future anguish.

For building Boost I ended up using b2 and the following steps install (based on https://www.boost.org/doc/libs/1_67_0/more/getting_started/windows.html) and having tried following the instructions to the letter I ended up with...

- Download Boost, e.g. from https://dl.bintray.com/boostorg/release/1.67.0/source/boost_1_67_0.7z
- Extract to e.g. C:\thirdparty\boost\boost_1_67_0
- Build the bootstrapper, as per section 5.2.1 in https://www.boost.org/doc/libs/1_67_0/more/getting_started/windows.html
- Build the binaries, simlar to section 5.2.2 in the above, but using
    - b2 --build-dir=C:\thirdparty\boost-install\boost_1_67_0 toolset=msvc --build-type=complete install
- Why the change?
    - Building the Boost build tools didn't seem to affect the building of the install
    - The inital install command in their instructions didn't seem to actually install the headers and libs
    - Using stage only seems to collect the lib files together, not the headers
    - So I end up with a libs folder and an include folder

I then try to set the following environment variables (as system ones, rather than as user ones)

- BOOST_ROOT - to the boost folder of the downloaded and extracted boost
- BOOST_INCLUDEDIR - to the include folder of the installed boost
- BOOST_LIBRARYDIR - the the lib folder of the installed boost

As well as lots of other directories which seemed like they might work.

Then in the CMake (based upon suggestions from the web) I've tried things like...

set(Boost_USE_STATIC_LIBS        ON)
set(Boost_USE_MULTITHREADED      ON)
set(Boost_USE_STATIC_RUNTIME    OFF)

...and...

SET(Boost_ADDITIONAL_VERSIONS "1.67" "1.67.0")

...and...

set (Boost_DETAILED_FAILURE_MSG ON)
set (BOOST_DEBUG ON)

... to no avail






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180712/80a6dd16/attachment.html>


More information about the CMake mailing list