Skip to content

FindBoost: Introduce CMP0093 to report Boost_VERSION in x.y.z format

Dennis Klein requested to merge dennisklein/cmake:find-boost-cmp0093 into master

This change was originally proposed as part of !3243 (merged) but it was decided to split it off into its own MR to not block the progress of the original MR.

Rationale: The variable <package>_VERSION has become a standard variable for reporting the found package version when invoking find_package(<package> ...) in config mode. In the case of the upstream Boost CMake package which is shipped with Boost 1.70.0+ the variable Boost_VERSION yields a version value in x.y.z format (e.g. 1.70.0).

Many find modules mimic this behaviour and so does the FindBoost module. Consequently, when invoking find_package(Boost ...) in module mode, this variable may currently yield different formats depending on which internal code path is successful. The module first searches a CMake package via find_package(Boost NO_MODULE) internally and only falls back to classic module mode if no CMake package is found. If a package is found Boost_VERSION is reported in x.y.z format, otherwise it is populated with the value of the BOOST_VERSION preprocessor macro defined in boost/version.hpp (e.g. 107000).

Former patches to this MR have introduced already new variables Boost_VERSION_STRING (19d92d5e) which always reports in x.y.z format and Boost_VERSION_MACRO (24342d5e) which always reports the value of the version macro from boost/version.hpp. To align module mode with config mode behaviour this MR introduces a new policy CMP0093 which allows changing the reported value in Boost_VERSION to always be in x.y.z format in module mode.

Edited by Dennis Klein

Merge request reports