<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.11.2016 12:04, Ruslan Baratov
wrote:<br>
</div>
<blockquote
cite="mid:1b2026f0-5192-9873-46ce-219dd9d74534@yahoo.com"
type="cite">
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
<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>
</blockquote>
<br>
There was no word play involved.<br>
You say cmake_minimum_required() is not about behaviour yet it
initializes all policies which are purely about behaviour.<br>
<br>
<blockquote
cite="mid:1b2026f0-5192-9873-46ce-219dd9d74534@yahoo.com"
type="cite"> <br>
<blockquote
cite="mid:dfb5cc2f-3961-de39-e1a5-209e267f00a5@gmail.com"
type="cite"> <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 moz-do-not-send="true"
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>
</blockquote>
<br>
No policies are still primarily about behaviour changes. That is
true for CMP0038 as well.<br>
<br>
The old behaviour is to ignore this issue in user code. The new
behaviour is to produce an error.<br>
When maintainers get this warning they are informed that their code
will break as soon as they increase their minimum required version.<br>
<br>
The same is true for CMP0054. The policy warning did find many
errors in user code but the warning is primarily about the change in
behaviour.<br>
<br>
<blockquote
cite="mid:1b2026f0-5192-9873-46ce-219dd9d74534@yahoo.com"
type="cite"> 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>
</blockquote>
<br>
Yes but I don't see what point you are trying to make ... they
didn't have to upgrade without the explicit policy set either.<br>
And the policy warnings aren't meant for users they are meant for
maintainers.<br>
<br>
<blockquote
cite="mid:1b2026f0-5192-9873-46ce-219dd9d74534@yahoo.com"
type="cite">
<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">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>
</blockquote>
<br>
You took this out of context. I was talking about your second
example about CMP0054 which was unset by
cmake_minimum_required(VERSION 2.8) and then explicitly set to OLD
by you.<br>
In this new case you have a policy that is initialized to NEW by
cmake_minimum_required(VERSION 3.0) and then set to OLD by you.<br>
<br>
Policies are not meant to be feature toggles. You are explicitly
asking CMake to use deprecated behaviour (that should no longer be
used and might be removed in the future) over new behaviour.<br>
<br>
<blockquote
cite="mid:1b2026f0-5192-9873-46ce-219dd9d74534@yahoo.com"
type="cite"> <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>
</blockquote>
<br>
Like I said policies are not primarily about fixing code. They are
about migrating to new behaviours introduced by new versions of
CMake.<br>
<br>
<blockquote
cite="mid:1b2026f0-5192-9873-46ce-219dd9d74534@yahoo.com"
type="cite"> <br>
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.
</blockquote>
<br>
Again I disagree. cmake_minimum_required(VERSION 3.1) tells CMake to
behave like 3.1. It does not indicate that you want to use any 3.1
specific features.<br>
<br>
<blockquote
cite="mid:1b2026f0-5192-9873-46ce-219dd9d74534@yahoo.com"
type="cite"> 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>
</blockquote>
<br>
Again policies are not meant to be feature toggles.<br>
You can do a lot of things and there may be valid use cases but in
general policies are not meant to be used this way.<br>
This is made explicit in CMake's documentation on policies.<br>
They exist to preserve backwards compatibility not to pick and
choose behaviours. <br>
<br>
Nils<br>
<br>
</body>
</html>