<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 09-Nov-16 16:22, Nils Gladitz wrote:<br>
</div>
<blockquote
cite="mid:dfb5cc2f-3961-de39-e1a5-209e267f00a5@gmail.com"
type="cite">
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
<div class="moz-cite-prefix">On 09.11.2016 04:29, Ruslan Baratov
wrote:<br>
</div>
<blockquote
cite="mid:98f9bbf7-0898-c249-3a1f-7b82b32d5912@yahoo.com"
type="cite">
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
<div class="moz-cite-prefix">On 08-Nov-16 23:33, Nils Gladitz
wrote:<br>
</div>
<blockquote
cite="mid:2a0e1f85-6129-abe1-12d1-e85f2b8d16ce@gmail.com"
type="cite">On 11/08/2016 04:17 PM, Ruslan Baratov wrote: <br>
<br>
<blockquote type="cite">Except it's exactly opposite :)
`cmake_minimum_required` is about new <br>
features/commands, and policies is about behavior. <br>
</blockquote>
<br>
I don't agree and you can not separate the two. <br>
cmake_minimum_required() initializes the policies based on the
given version.<br>
</blockquote>
<tt>So what? From the user's perspective the "initialization of
policies" is like a syntactic sugar so you don't have to write
endless `</tt><tt><span class="hll"><span class="nb">cmake_policy</span><span
class="p">(</span><span class="s">SET</span> <span
class="s">CMP00xx</span> NEW<span class="p">)`. Nothing to
do how to deal with them further.</span></span></tt><br>
</blockquote>
<br>
You can't simultaneously argue that cmake_minimum_required() isn't
about policies (behaviours) and at the same time syntactic sugar
for those very same policies.<br>
</blockquote>
You're playing with words instead of using arguments.<br>
<br>
<blockquote
cite="mid:dfb5cc2f-3961-de39-e1a5-209e267f00a5@gmail.com"
type="cite"> <br>
<blockquote
cite="mid:98f9bbf7-0898-c249-3a1f-7b82b32d5912@yahoo.com"
type="cite"> <br>
<blockquote
cite="mid:2a0e1f85-6129-abe1-12d1-e85f2b8d16ce@gmail.com"
type="cite"> <br>
<blockquote type="cite"> If you have command <br>
`if(IN_LIST)` since 3.3 you can't manipulate policies in
such way that <br>
it will work with CMake 2.8. However if you have warning
about policy <br>
CMP0054 (since CMake 3.2) you can set policy to old without
changing <br>
`cmake_minimum_required` (hence without forcing your CMake
2.8 users to <br>
upgrade to CMake 3.2). <br>
</blockquote>
<br>
Coincidentally I implemented both of those policies :) <br>
<br>
Given your second example you likely shouldn't be touching the
policy at all.<br>
</blockquote>
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.<br>
</blockquote>
<br>
Policy warnings aren't meant to indicate errors in your code but
changes in behaviour that will happen if you were to increase your
minimum required version.<br>
</blockquote>
Policy CMP0038 doesn't agree with you:
<a class="moz-txt-link-freetext" href="https://cmake.org/cmake/help/latest/policy/CMP0038.html">https://cmake.org/cmake/help/latest/policy/CMP0038.html</a><br>
<br>
<blockquote
cite="mid:dfb5cc2f-3961-de39-e1a5-209e267f00a5@gmail.com"
type="cite"> As such they can often be worked around by using
behaviour that is consistent between versions but they are not
meant to indicate errors to be fixed.<br>
<br>
Instead they are meant to encourage you to embrace the new
behaviours and abandon the old (which will require porting work)
since the old are by definition deprecated and may be removed in
the future (though so far CMake has been very conservative about
this).<br>
<br>
<blockquote
cite="mid:98f9bbf7-0898-c249-3a1f-7b82b32d5912@yahoo.com"
type="cite"> <br>
<blockquote
cite="mid:2a0e1f85-6129-abe1-12d1-e85f2b8d16ce@gmail.com"
type="cite"> <br>
A policy warning does not force your users to use a new CMake
version.<br>
</blockquote>
Well that's what I said.<br>
</blockquote>
<br>
You said you are not forcing your users to upgrade by setting a
policy to OLD.<br>
</blockquote>
Yes, like this:<br>
<br>
<blockquote>
<pre><span class="nb">cmake_minimum_required</span><span class="p">(</span><span class="s">VERSION</span> <span class="s">2.8</span><span class="p">)</span>
<span class="nb">project</span><span class="p">(</span><span class="s">foo</span><span class="p">)</span>
<span class="hll"><span class="nb">if</span><span class="p">(</span><span class="s">POLICY</span> <span class="s">CMP0038</span><span class="p">)</span></span><span class="hll"><span class="c"></span>
</span><span class="hll"> <span class="nb">cmake_policy</span><span class="p">(</span><span class="s">SET</span> <span class="s">CMP0038</span> <span class="s">OLD</span><span class="p">)</span>
</span><span class="hll"><span class="nb">endif</span><span class="p">()</span></span></pre>
</blockquote>
Now CMake 3.0 users will not see the warning and CMake 2.8 users
**don't have to upgrade**.<br>
<br>
<blockquote
cite="mid:dfb5cc2f-3961-de39-e1a5-209e267f00a5@gmail.com"
type="cite"> Which implied that not setting the policy to OLD
would force your users to upgrade ... which it doesn't.<br>
</blockquote>
No, it doesn't imply this :) Not setting policy to OLD in this case
produce warnings that I have to deal with.<br>
<br>
<blockquote
cite="mid:dfb5cc2f-3961-de39-e1a5-209e267f00a5@gmail.com"
type="cite"> <br>
<blockquote
cite="mid:98f9bbf7-0898-c249-3a1f-7b82b32d5912@yahoo.com"
type="cite"> <br>
<blockquote
cite="mid:2a0e1f85-6129-abe1-12d1-e85f2b8d16ce@gmail.com"
type="cite">In fact all that setting it to OLD does is
suppress the warning.<br>
</blockquote>
</blockquote>
</blockquote>
<tt>Actually this statement is wrong. Take a look at this example:</tt><tt><br>
</tt><tt><br>
</tt>
<blockquote><tt># CMakeLists.txt</tt><br>
<tt><span class="hll"><span class="nb">cmake_minimum_required</span><span
class="p">(</span><span class="s">VERSION</span> <span
class="s">3.0</span><span class="p">)</span></span></tt><br>
<tt><span class="hll"></span></tt><tt><span class="nb">project</span></tt><tt><span
class="p">(</span></tt><tt><span class="s">foo</span></tt><tt><span
class="p"> VERSION 1.2.3)</span></tt><br>
<tt><span class="hll"><span class="nb">cmake_policy</span><span
class="p">(</span><span class="s">SET</span> <span
class="s">CMP0038</span> <span class="s">OLD</span><span
class="p">) # Do not remove this!</span></span></tt><br>
<tt><span class="hll"></span></tt><tt><span class="nb">add_library</span></tt><tt><span
class="p">(</span></tt><tt><span class="s">foo</span></tt><tt>
</tt><tt><span class="s">foo.cpp</span></tt><tt><span class="p">)</span></tt><br>
<tt><span class="nb">target_link_libraries</span></tt><tt><span
class="p">(</span></tt><tt><span class="s">foo</span></tt><tt>
</tt><tt><span class="s">foo</span></tt><tt><span class="p">)</span></tt><br>
</blockquote>
if you remove `<tt><span class="hll"><span class="nb">cmake_policy</span><span
class="p">(</span><span class="s">SET</span> <span class="s">CMP0038</span>
<span class="s">OLD</span><span class="p">)` this example will
produce **error**. It may happens when you want to use new
**feature** `project(VERSION)` from 3.0, hence you set
`cmake_minimum_required(VERSION 3.0)` and simultaneously you
have code which produce warning about CMP0038. By setting `</span></span></tt><tt><span
class="hll"><span class="nb">cmake_policy</span><span class="p">(</span><span
class="s">SET</span> <span class="s">CMP0038</span> <span
class="s">OLD</span><span class="p">)` you suppress the error,
i.e. change **behaviour**.</span></span></tt><br>
<br>
<blockquote
cite="mid:dfb5cc2f-3961-de39-e1a5-209e267f00a5@gmail.com"
type="cite">
<blockquote
cite="mid:98f9bbf7-0898-c249-3a1f-7b82b32d5912@yahoo.com"
type="cite">
<blockquote
cite="mid:2a0e1f85-6129-abe1-12d1-e85f2b8d16ce@gmail.com"
type="cite"> </blockquote>
It's better than emitting zillion of warnings to the output,
right? You can suppress one type and fix another, set TODOs,
etc.<br>
</blockquote>
<br>
Policy warnings are intended to encourage you to switch to new
behaviours since the old ones are deprecated.<br>
In actively maintained projects they are not meant to be
suppressed.<br>
</blockquote>
Why not? If you're not planning to fix them right now? I'm not
saying you have to ignore them, you have to do fixes, but why not
suppress and say work on other fixes?<br>
<br>
<blockquote
cite="mid:dfb5cc2f-3961-de39-e1a5-209e267f00a5@gmail.com"
type="cite"> <br>
<blockquote
cite="mid:98f9bbf7-0898-c249-3a1f-7b82b32d5912@yahoo.com"
type="cite"> <br>
<blockquote
cite="mid:2a0e1f85-6129-abe1-12d1-e85f2b8d16ce@gmail.com"
type="cite">CMake will use the old behavior in either case. <br>
<br>
The warnings guide developers when they do bump their
cmake_minimum_required(VERSION). <br>
By just suppressing it behavior changes might go unnoticed
when the bump does happen.<br>
</blockquote>
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?<br>
</blockquote>
<br>
cmake_minimum_required(VERSION 3.0)<br>
<br>
set(ONE 1)<br>
<br>
if(1 STREQUAL "ONE")<br>
message("FOO")<br>
else()<br>
message("BAR")<br>
endif()<br>
<br>
This code was designed for 3.0 (as indicated by the
cmake_minimum_required(VERSION)) and is meant to output "FOO".<br>
When you use CMake 3.0 that is the behaviour you get (without
warnings).<br>
When you use CMake >= 3.1 the behaviour of the code itself is
still the same but you will get a CMP0054 warning telling you that
the behaviour that you currently depend on in if() has been
deprecated.<br>
<br>
Now you decide to bump your minimum required version from 3.0 to
3.1 and ignore or suppress the policy warning from before:<br>
<br>
cmake_minimum_required(VERSION 3.1)<br>
<br>
set(ONE 1)<br>
<br>
if(1 STREQUAL "ONE")<br>
message("FOO")<br>
else()<br>
message("BAR)<br>
endif()<br>
<br>
<p>Now when you use CMake >= 3.1 to run this code you will not
get any more warnings but it will also no longer behave like it
used to.</p>
<p>It will output "BAR" instead of "FOO".</p>
</blockquote>
And this code will produce "FOO":<br>
<br>
<blockquote>cmake_minimum_required(VERSION 3.1)<br>
<br>
cmake_policy(SET CMP0054 OLD) # behave like 3.0<br>
<br>
set(ONE 1)<br>
<br>
if(1 STREQUAL "ONE")<br>
message("FOO")<br>
else()<br>
message("BAR")<br>
endif()<br>
</blockquote>
In this example by `cmake_minimum_required(VERSION 3.1)` you telling
user that you're planning to use some **feature** from CMake 3.1.
This feature may be about interpreting differently `if(1 STREQUAL
"ONE")` and `if(1 STREQUAL ONE)` or may be about anything else. Note
that CMake 3.0 **has no such feature** and commands `if(1 STREQUAL
"ONE")` /`if(1 STREQUAL ONE)` is same for him always. Policy CMP0054
is about **behaviour**: "how we really should interpret `if(1
STREQUAL "ONE")`"? Yes, `cmake_minimum_required(VERSION 3.1)` set
the policy **implicitly** to NEW. But you can control it yourself,
like set it to NEW explicitly (which make no sense here but can be
done), or set it to OLD.<br>
<br>
Ruslo<br>
</body>
</html>