[CMake] Why policy CMP0054 does not survive cmake_minimum_required?

Nils Gladitz nilsgladitz at gmail.com
Wed Mar 4 13:40:35 EST 2015


On 04.03.2015 19:20, Pere Mato Vila wrote:
> Hi,
>
> With version 3.1.3, I have to define policy CMP0054 to NEW to avoid 
> lots of warnings. My original approach was to define it at the top 
> level CMakeLists.txt file hoping this will be inherited by all 
> sub_directories of the project. Beware that some of the 
> sub_directories contain a cmake_minimum_required() command because 
> they can also be standalone projects with a project() command. To 
> my surprise this does not work for policy CMP0054 and it works for 
> others like for example CMP0005. Is there any reason for it?
>
> To test this behaviour is as simple cmaking the following 
> CMakeLists.txt file:
> cmake_policy(SET CMP0005 NEW)
> cmake_policy(SET CMP0054 NEW)
>
> cmake_policy(GET CMP0005 cmp0005)
> cmake_policy(GET CMP0054 cmp0054)
> message("Policy CMP0005 before version ${cmp0005}")
> message("Policy CMP0054 before version ${cmp0054}")
>
> cmake_minimum_required(VERSION 2.8.8 FATAL_ERROR)
>
> cmake_policy(GET CMP0005 _cmp0005)
> cmake_policy(GET CMP0054 _cmp0054)
> message("Policy CMP0005 after version ${_cmp0005}")
> message("Policy CMP0054 after version ${_cmp0054}")
>
>
> The output is:
>
> Policy CMP0005 before version NEW
> Policy CMP0054 before version NEW
> Policy CMP0005 after version NEW
> Policy CMP0054 after version
>
> so, CMP0054 is undefined after the  cmake_minimum_required()

cmake_minimum_required() resets all policies according to the given version.

CMP0005 was introduced in 2.6.0 so requiring 2.8.8 sets it to NEW.
CMP0054 was introduced in 3.1 so requiring 2.8.8 clears the policy 
(since it did not exist in 2.8.8).

Nils
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150304/af248c8d/attachment.html>


More information about the CMake mailing list