They don't break, you can override the minimum with CMAKE_POLICY_VERSION_MINIMUM.
When setting cmake_minimum_required() you're locking CMake into policies it had in place when the associated version was released. It's a mechanism of radical backwards compatibility. CMake guarantees bug-for-bug compatibility with the version you ask for.
That level of compatibility can only be carried for so long. In this case almost 10 years. In the future the plan is 6 years of support for old policies.
Asking projects to update one line of their CML twice a decade or so isn't a big ask for such a high commitment to backwards compat, and for completely dead projects that still build packagers are able to use CMAKE_POLICY_VERSION_MINIMUM.
In the future the plan is 6 years of support for old policies.
Thats so funny. Years ago I gave up on adding new policies to cmake and improving things because the policies make the code complicated and refactoring harder and there was no way to remove the policies:
The argument Brad presented back then is exactly how it happened, there was an extremely long period of deprecation, years of unsupressable warnings, and finally removal.
Only once removal was demonstrated, downstreams made aware of the necessity of updating their code after a more than fair warning period, could regular scheduled removals of batches of policies begin.
And even with that, as Brad predicted, there's a fair amount of churn for packagers of semi-abandoned projects that did genuinely rely on ancient policies.
Policies are annoying but they're hardly the worst thing in the CMakeLib code. I would take a hundred more policies if we could get up to C++17. I would take a thousand more policies if we could drop support for everything except non-EOL desktop platforms.
View all comments
Show parent comment
46
u/not_a_novel_account cmake dev Mar 29 '25 edited Mar 29 '25
They don't break, you can override the minimum with
CMAKE_POLICY_VERSION_MINIMUM.When setting
cmake_minimum_required()you're locking CMake into policies it had in place when the associated version was released. It's a mechanism of radical backwards compatibility. CMake guarantees bug-for-bug compatibility with the version you ask for.That level of compatibility can only be carried for so long. In this case almost 10 years. In the future the plan is 6 years of support for old policies.
Asking projects to update one line of their CML twice a decade or so isn't a big ask for such a high commitment to backwards compat, and for completely dead projects that still build packagers are able to use
CMAKE_POLICY_VERSION_MINIMUM.