Skip to content

Find Boost in config mode with CMake 3.30 and newer - #1499

Open
aeron-gh wants to merge 2 commits into
p4lang:mainfrom
aeron-gh:cmake-boost-policy
Open

aeron-gh wants to merge 2 commits into
p4lang:mainfrom
aeron-gh:cmake-boost-policy

Conversation

@aeron-gh

@aeron-gh aeron-gh commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

With CMake 3.30 and newer, every configure prints the CMP0167 warning ("The FindBoost module is removed"). It also shows in both test-cmake jobs on main, e.g. https://github.com/p4lang/behavioral-model/actions/runs/47344195452. Nothing fails today; cmake --help-policy CMP0167 says the old FindBoost behavior "may be removed in a future version of CMake".

With CMake 3.30 and newer, this calls find_package(Boost CONFIG ...), which loads Boost's own BoostConfig.cmake directly. Older CMake keeps the current call. FindBoost already hands off to BoostConfig.cmake when it exists ("If found, the package configuration file is loaded and this module returns with no further action", cmake --help-module FindBoost), so on those systems only that extra step goes away.

BOOST_ROOT is passed as a hint, because config mode does not read it with this project's cmake_minimum_required(VERSION 3.10) (CMP0144 is not set). CMAKE_PREFIX_PATH and Boost_DIR work as before. FindBoost-only settings such as Boost_NO_BOOST_CMAKE no longer apply with CMake 3.30+; nothing in the repo uses them.

Testing

Fresh configure of main and of main with this change, Arch Linux, Boost 1.92:

  • CMake 4.4.4 and 3.30.9: 1 warning on main, 0 with this change. Boost_DIR is the same. The generated build.ninja differs only in the rule that re-runs CMake (FindBoost.cmake is no longer an input). Same with -DENABLE_PACKET_TRACE=ON -DENABLE_WERROR=ON on CMake 4.4.4.
  • CMake 3.29.6: build.ninja is identical to main.
  • With a fake Boost package whose BoostConfig.cmake stops configure, -DBOOST_ROOT=..., BOOST_ROOT in the environment and -DCMAKE_PREFIX_PATH=... all pick it up, as on main.
  • BoostConfig.cmake and the thread and program_options config files ship with CI's Boost 1.83 (see the log above), Ubuntu's Boost 1.90 packages (used by Dockerfile.ubuntu-26.04) and Fedora's boost-devel (43, 45 and rawhide).

Signed-off-by: Abhishek Agarwal <agab0323@gmail.com>
Comment thread CMakeLists.txt Outdated

cmake_minimum_required(VERSION 3.10)

# Find Boost through its BoostConfig.cmake; CMake 3.30+ drops FindBoost

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big fan of cmake policy setting, what is the actual fix here?

We can have different behavior for different cmake versions if necessary.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeahh right fair point. There's no functional bug. It only removes the CMP0167 deprecation warning that CMake 3.30+ prints on every configure, CI included.
I switched to your suggestion in 1df177d: CONFIG mode for CMake 3.30+, the old call otherwise. BOOST_ROOT is passed as a hint because config mode ignores it here. Does this look better?

Signed-off-by: Abhishek Agarwal <agab0323@gmail.com>
@aeron-gh aeron-gh changed the title Set CMP0167 to find Boost through BoostConfig.cmake Find Boost in config mode with CMake 3.30 and newer Dec 5, 2026
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

Successfully merging this pull request may close these issues.

2 participants