Allow a package to enforce a minimum cmake_minimum_required call for the subdirectory scope where the package is looked up
This issue can be considered a more general rephrasing of #22800 (closed) I figured it would merit a separate issue.
Currently a package can not enforce that a project specifies a recent enough minimum cmake version in
the project's cmake_minimum_required(VERSION <min>)
call.
At most, the package can call cmake_minimum_required(VERSION <min>)
in its own cmake files, for its own cmake commands, but that doesn't propagate up to the directory scope or the whole project, because most find_package()
calls don't specify NO_POLICY_SCOPE
.
It would be useful to have a way for a package to enforce a minimum policy baseline.
This would eliminate ambiguities when implementing code that relies on policy values, like: does the policy get recorded / evaluated at command call time or at target creation time or at generation time? Is this policy enabled just for this subdirectory scope, or all of them, or some of them?
I would suggest a new signature addition like
cmake_policy(VERSION <min>[...<max>] DIRECTORY_SCOPE)
cmake_policy(VERSION <min>[...<max>] GLOBAL_SCOPE)