[CMake] Why policy CMP0054 does not survive cmake_minimum_required?

Nils Gladitz nilsgladitz at gmail.com
Thu Mar 5 13:04:37 EST 2015


On 05.03.2015 18:50, Pere Mato Vila wrote:
>
>> On 04 Mar 2015, at 19:40, Nils Gladitz <nilsgladitz at gmail.com 
>> <mailto:nilsgladitz at gmail.com>> wrote:
>>
>> 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).
>
>
> Thanks very much for the explanation. Nevertheless I do not understand 
> the logic. Running with 3.1 with the exactly the same code generates 
> warnings that were not there in 2.8.8. In order to switch them off I 
> need to set the policy to NEW, which gets cleared by requiring somehow 
> a less restrictive condition. 

Setting individual policies before a call to cmake_minimum_required() 
doesn't make sense given that it resets them all but you can set them after.

The warnings are there so you as a developer of a project that conforms 
to CMake 2.8.8 know that the behavior will change as soon as you convert 
your project to 3.1.
You can get rid of the warnings by working around the if() ambiguity so 
that behavior before and after CMake 3.1 is identical or by requiring 3.1.

If you do switch to requiring 3.1 make sure the new behavior works for you.

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


More information about the CMake mailing list