Boost logo

Boost :

From: Deniz Bahadir (deniz.bahadir_at_[hidden])
Date: 2021-07-15 11:52:07


Am 15.07.21 um 09:17 schrieb Dennis Luehring via Boost:
> 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)
>
One remark:

Here you are explicitly depending on CMake's `FindBoost` script, because
you neither use the `CONFIG` nor `NO_MODULE` argument (or any other
argument not specified in the basic signature) for `find_package`. [1]
Unless you explicitly set the `CMAKE_FIND_PACKAGE_PREFER_CONFIG`
variable `find_package` always tries the "Module" mode first. And if it
finds a suitable `Find*` script it will not try the "Config" mode (even
if the `Find*` script is unable to find the package).
That your `find_package(Boost ...)` call still tries the "Config" mode
(if you again remove the `Boost_NO_BOOST_CMAKE` variable or set it to
`FALSE`)is only due to the fact that the `FindBoost` script explicitly
tries the `Config` mode first (unless you set the `Boost_NO_BOOST_CMAKE`
variable to `TRUE`).

So, in general I always recommend to explicitly use `find_package` in
"Config" mode if one knows that the searched package was installed with
a config-file for importing.
For Boost this should be true since Boost 1.70.0. (Installing it without
the config-file is not very sensible.)

Happy cmaking,
Deniz

[1]
https://cmake.org/cmake/help/latest/command/find_package.html#full-signature-and-config-mode

> 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)?
>
>
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost

-- 
BENOCS GmbH
Dipl.-Inform. Deniz Bahadir
Reuchlinstr. 10 D
10553 Berlin
Germany
Phone: +49 - 30 / 577 0004-22
Email: deniz.bahadir_at_[hidden]
www.benocs.com
Board of Management: Stephan Schroeder, Dr.-Ing. Ingmar Poese
Commercial Register: Amtsgericht Bonn HRB 19378

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