[CMake] Adding Cmake version in online documentation

Ruslan Baratov ruslan_baratov at yahoo.com
Tue Nov 8 22:29:01 EST 2016


On 08-Nov-16 23:33, Nils Gladitz wrote:
> On 11/08/2016 04:17 PM, Ruslan Baratov wrote:
>
>> On 08-Nov-16 22:22, Nils Gladitz wrote:
>>> Strictly speaking cmake_minimum_required(VERSION) is not about command
>>> availability but rather about behavior (cmake policies).
>> Except it's exactly opposite :) `cmake_minimum_required` is about new
>> features/commands, and policies is about behavior.
>
> I don't agree and you can not separate the two.
> cmake_minimum_required() initializes the policies based on the given
> version.
So what? From the user's perspective the "initialization of policies" is
like a syntactic sugar so you don't have to write endless
`cmake_policy(SET CMP00xx NEW)`. Nothing to do how to deal with them
further.

>
>>   If you have command
>> `if(IN_LIST)` since 3.3 you can't manipulate policies in such way that
>> it will work with CMake 2.8. However if you have warning about policy
>> CMP0054 (since CMake 3.2) you can set policy to old without changing
>> `cmake_minimum_required` (hence without forcing your CMake 2.8 users to
>> upgrade to CMake 3.2).
>
> Coincidentally I implemented both of those policies :)
>
> Given your second example you likely shouldn't be touching the policy
> at all.
I have to. If my code use features from CMake 2.8 I do set
`cmake_minimum_required(VERSION 2.8)`. But some users may have CMake 3.2
installed. Do they must downgrade CMake? Of course not. But if I'm not
touching policies there will be warnings around. If I'm good developer I
will investigate the root of the warnings and fix them. Actually most of
them will be about bugs in my code or dangerous behavior, so it does
improve 2.8 too.

>
> A policy warning does not force your users to use a new CMake version.
Well that's what I said.

> In fact all that setting it to OLD does is suppress the warning.
It's better than emitting zillion of warnings to the output, right? You
can suppress one type and fix another, set TODOs, etc.

> CMake will use the old behavior in either case.
>
> The warnings guide developers when they do bump their
> cmake_minimum_required(VERSION).
> By just suppressing it behavior changes might go unnoticed when the
> bump does happen.
There are 3 components in the equation: the **real** CMake version, the
version in `cmake_minimum_required` and the default policies for such
version. Can you provide an example of what you mean?

Ruslo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20161109/25b844d9/attachment-0001.html>


More information about the CMake mailing list