[cmake-developers] policies in CMake builtin modules
Brad King
brad.king at kitware.com
Thu Sep 18 13:39:30 EDT 2014
On 09/18/2014 01:00 PM, Adam Strzelecki wrote:
> If I understand correctly all modules included via
> include/find_package have implicit POLICY PUSH and POP
Yes.
> at the EOF. Wouldn't it be reasonable to require all
> internal .cmake files to begin with:
>
> cmake_policy(VERSION 3.1) # or whatever version the module was tested against
>
> Then before next release all of these should be checked
> against new policies and upgraded to:
>
> cmake_policy(VERSION 3.2) # next release version
Like Nils' proposal, this will not be reliable without full coverage
of module functionality in the test suite (which is very hard to do
because every find module depends on another external package). It
could be done manually on a per-module basis.
> Then we can safely drop all these fancy
> if("x${var}" STREQUAL "xVALUE") in favor of if(var STREQUAL "VALUE")
This can be done with just
cmake_policy(SET CMP0054 NEW)
at the top of any module that has been ported accordingly.
Most policies do not affect CMake syntax, but several have come
before this one and there are very few modules that make any
explicit mention of cmake_policy. In most cases the module
code can be written to work with any policy settings.
On 09/17/2014 08:37 AM, Rolf Eike Beer wrote:
> Wait, what? This is actually the opposite of what that policy is for,
This is true, but will only affect modules that come with CMake
that must work regardless of the cmake_minimum_required(VERSION)
used in the project. Once a release of CMake contains this policy,
project code can require that version of CMake when it is ready
and then use the nicer if() tests.
-Brad
More information about the cmake-developers
mailing list