Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake policy CMP0167 #2088

Open
jongbongan opened this issue Oct 8, 2024 · 7 comments
Open

cmake policy CMP0167 #2088

jongbongan opened this issue Oct 8, 2024 · 7 comments

Comments

@jongbongan
Copy link
Contributor

Actually, it may not be a big deal.

I am currently using CMake >= 3.30 to build the project. It outputs a warning :

CMake Warning (dev) at CMakeLists.txt:164 (find_package):Policy CMP0167 is not set: The FindBoost module is removed.  Run "cmake --help-policy CMP0167" for policy details.  Use the cmake_policy command to set the policy and suppress this warning.

In CMake document, (cmake --help-policy CMP0167) it says

.. versionadded:: 3.30

The ``FindBoost`` module is removed.

CMake 3.29 and below provide a ``FindBoost`` module, but it needs constant
updates to keep up with upstream Boost releases.  Upstream Boost 1.70
and above provide a ``BoostConfig.cmake`` package configuration file.
``find_package(Boost CONFIG)`` finds the upstream package directly,
without the find module.

CMake 3.30 and above prefer to not provide the ``FindBoost`` module
so that ``find_package(Boost)`` calls, without the ``CONFIG`` or
``NO_MODULE`` options, find the upstream ``BoostConfig.cmake`` directly.
This policy provides compatibility for projects that have not been ported
to use the upstream Boost package.

The ``OLD`` behavior of this policy is for ``find_package(Boost)`` to
load CMake's ``FindBoost`` module.  The ``NEW`` behavior is for
``find_package(Boost)`` to search for the upstream ``BoostConfig.cmake``.

This policy was introduced in CMake version 3.30.
It may be set by ``cmake_policy()`` or ``cmake_minimum_required()``.
If it is not set, CMake warns, and uses ``OLD`` behavior.

.. note::
  The ``OLD`` behavior of a policy is
  ``deprecated by definition``
  and may be removed in a future version of CMake.

I think it is better to suppress such a warning until we require the minimum version of Boost >= 1.70.

Copy link

boring-cyborg bot commented Oct 8, 2024

Thanks for posting! It might take a while before we look at your issue, so don't worry if there seems to be no feedback. We'll get to it.

@sweemer
Copy link
Contributor

sweemer commented Oct 9, 2024

I think we should use the config based find_package when the CMake version >= 3.30 and FindBoost when < 3.30. If users can use the newest versions of CMake then they can probably upgrade to the newest versions of boost as well.

@jongbongan
Copy link
Contributor Author

jongbongan commented Oct 9, 2024

Because boost supports its cmake configuration for version >= 1.70, I will add a config argument in find_package(boost ... ) as soon as the minimum required version of boost changes to >= 1.70.

(now, {QL_BOOST_VERSION} would be 1.58.0)

@sweemer
Copy link
Contributor

sweemer commented Oct 10, 2024

I was thinking more like the following:

if (CMAKE_VERSION GREATER_EQUAL "3.30")
    set(QL_BOOST_VERSION 1.70.0)
    find_package(Boost ${QL_BOOST_VERSION} CONFIG REQUIRED)
else()
    find_package(Boost ${QL_BOOST_VERSION} REQUIRED)
endif()

@jongbongan
Copy link
Contributor Author

I will make a PR for config based find_package(boost... ) asap then.

@ralfkonrad
Copy link
Contributor

ralfkonrad commented Oct 10, 2024

Another possibility would be to check if the POLICY CMP0167 is available

if (POLICY CMP0167)
    set(QL_BOOST_VERSION 1.70.0)
    # The FindBoost module is removed in cmake 3.30, finding the upstream BoostConfig.cmake
    find_package(Boost ${QL_BOOST_VERSION} CONFIG REQUIRED)
else()
    find_package(Boost ${QL_BOOST_VERSION} REQUIRED)
endif()

It gives a clearer picture why we distinguish between the two find_package(Boost ...) methods and where to find information about it.


However, be aware that (almost?) all GitHub runners have updated to cmake v3.30 already.

For the macos and ubuntu runners it doesn't make a difference as the new CONFIG file BoostConfig.cmake is found automatically using the default methods (like apt and brew) to setup boost.

For the windows runners it is different when you download and extract the boost binaries. You need to provide the environment variable Boost_DIR with the path to the BoostConfig.cmake file. Have a look here how this can be solved.

@jongbongan
Copy link
Contributor Author

I will check it. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants