Boost logo

Boost :

From: Dennis Luehring (dl.soluz_at_[hidden])
Date: 2021-07-15 07:17:54


in short: CMake does need to change (i'll need to wait for updates) to
support newer released boost versions

i've heard that Boost supports cmake now directly but i don't get the
direct cmake support of boost working with

my CMakeLists.txt

i know that CMake supports 1.75 in the lastest releases directly but
1.76 and 1.77 are still not on the list and i don't want

to wait for CMake release to test new features/betas etc.

my system:

Ubuntu 21.04/x64, CMake 3.19.4/3.21.0, GCC 10.x

Boost 1.75 (want to upgrade to 1.76 soon)

my boost build:
   mkdir ~/dev/3rdparty-liux-gcc
   cd ~/dev/3rdparty-linux-gcc
   wget
https://dl.bintray.com/boostorg/release/1.75.0/source/boost_1_75_0.tar.bz2
   tar -xf boost_1_75_0.tar.bz2
   ln -s boost_1_75_0 ./boost
   cd boost_1_75_0
   ./bootstrap.sh
   ./b2 --toolset=gcc cxxflags=-fPIC --build-dir=./_build
address-model=64 architecture=x86 link=static threading=multi
--with-graph --with-nowide --with-test --width-config --with-system
--with-filesystem --stagedir=./_x64
   ln -s _x64/lib lib

my simple test hierarchy:

boost_using_cmake_tests
boost_using_cmake_tests\_build
boost_using_cmake_tests\boost_using_cmake
boost_using_cmake_tests\boost_using_cmake\CMakeLists.txt
       cmake_minimum_required (VERSION 3.16)
       set(Boost_NO_BOOST_CMAKE TRUE)
       set(Boost_NO_SYSTEM_PATHS TRUE)
       project (using_boost_with_cmake)
       set( MY_THIRD_PARTY_LIBS "~/dev/3rdparty-linux-gcc" )
       set( BOOST_ROOT ${MY_THIRD_PARTY_LIBS}/boost )
       set( BOOST_INCLUDEDIR ${BOOST_ROOT}/boost)
       set( BOOST_LIBRARYDIR ${BOOST_ROOT}/lib)
       find_package(Boost REQUIRED COMPONENTS unit_test_framework
filesystem system)

cmake run:

using 3.19.4 cmake without 1.75 support

~/dev/boost_using_cmake/_build$
../../cmake-3.19.4-linux-x86_64/bin/cmake ../boost_using_cmake/
-- The C compiler identification is GNU 10.3.0
-- The CXX compiler identification is GNU 10.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at
/home/linux/dev/cmake-3.19.4-Linux-x86_64/share/cmake-3.19/Modules/FindBoost.cmake:1204
(message):
   New Boost version may have incorrect or missing dependencies and imported
   targets
Call Stack (most recent call first):
/home/linux/dev/cmake-3.19.4-Linux-x86_64/share/cmake-3.19/Modules/FindBoost.cmake:1326
(_Boost_COMPONENT_DEPENDENCIES)
/home/linux/dev/cmake-3.19.4-Linux-x86_64/share/cmake-3.19/Modules/FindBoost.cmake:1935
(_Boost_MISSING_DEPENDENCIES)
   CMakeLists.txt:14 (find_package)

CMake Warning at
/home/linux/dev/cmake-3.19.4-Linux-x86_64/share/cmake-3.19/Modules/FindBoost.cmake:1204
(message):
   New Boost version may have incorrect or missing dependencies and imported
   targets
Call Stack (most recent call first):
/home/linux/dev/cmake-3.19.4-Linux-x86_64/share/cmake-3.19/Modules/FindBoost.cmake:1326
(_Boost_COMPONENT_DEPENDENCIES)
/home/linux/dev/cmake-3.19.4-Linux-x86_64/share/cmake-3.19/Modules/FindBoost.cmake:1935
(_Boost_MISSING_DEPENDENCIES)
   CMakeLists.txt:14 (find_package)

CMake Warning at
/home/linux/dev/cmake-3.19.4-Linux-x86_64/share/cmake-3.19/Modules/FindBoost.cmake:1204
(message):
   New Boost version may have incorrect or missing dependencies and imported
   targets
Call Stack (most recent call first):
/home/linux/dev/cmake-3.19.4-Linux-x86_64/share/cmake-3.19/Modules/FindBoost.cmake:1326
(_Boost_COMPONENT_DEPENDENCIES)
/home/linux/dev/cmake-3.19.4-Linux-x86_64/share/cmake-3.19/Modules/FindBoost.cmake:1935
(_Boost_MISSING_DEPENDENCIES)
   CMakeLists.txt:14 (find_package)

-- Found Boost: /home/linux/dev/3rdparty-linux-gcc/boost (found version
"1.75.0") found components: unit_test_framework filesystem system
-- Configuring done
-- Generating done
-- Build files have been written to:
/home/linux/dev/boost_using_cmake_tests/_build

it works but cmake 3.19.4 is missing direct support for 1.75 so its some
way "unsupported", cmake does not detect the correct lib names
automaticly, only some styles are working etc.

i've talked about the problem on the cmake forum and the answer was

https://discourse.cmake.org/t/fail-to-use-self-build-boost-1-75-under-ubuntu-linux-20-04-x64-with-cmake-default-and-3-19-4/2750/5

Brad King: "...However, Boost upstream now provides a proper CMake
package file BoostConfig.cmake which should work for using Boost in any
layout..."

1.75 is now directly supported by cmake - but now i want to use 1.76 and
the problem re-occures

i've tried serveral things to force cmake to use the boost own package
findings stuff without any success
i hope its possible to use 1.75 and 1.76 in the future without always
wait for cmake to support it directly

any hints what changes are needed with my CMakeLists.txt to support
boost own cmake package finding (and get rid of these problems)?


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