Setting a policy range for CMAKE_POLICY_DEFAULT_CMPNNNN variables
!1864 (merged) adds the ability to specify a version range for policies to have NEW
behavior rather than just a specific version. That MR also raised the question of whether it would be good to implement a symmetrical capability equivalent to the CMAKE_POLICY_DEFAULT_CMPNNNN variable so that a policy range can effectively be set. One use case for this is when pulling in an externally defined project directly into the build and where you cannot modify that project, but you want to indicate that policies more recent than what that project is aware of can use the NEW
behavior. At the moment, each individual policy would have to be specified one by one.
Code in CMake (C++ and modules) and in user projects that test individual policies to decide whether or not to do something or to do it a particular way need to continue to work (without modification in the case of user projects). Any way that the state of a policy can be queried therefore needs to be able to understand whatever change we make. For user projects and CMake modules, I think that's just if(POLICY)
, but not sure about CMake internally (C++).