Thanks, I will be using this method:<br><br>if (myvar MATCHES &quot;^somestring$&quot;)<br>endif()<br><br>Do NOT use &quot;${myvar}&quot; because that forces CMake to treat the value of myvar as a variable name if it exists.  That will give you accidentally indirection that may point to the value of another string.<br>
<br><br><div class="gmail_quote">On Fri, Feb 15, 2013 at 12:13 PM, Alexander Neundorf <span dir="ltr">&lt;<a href="mailto:a.neundorf-work@gmx.net" target="_blank">a.neundorf-work@gmx.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Thursday 14 February 2013, Shaun Williams wrote:<br>
&gt; I&#39;m slowly realizing the gravity of this behavior:<br>
&gt;<br>
&gt; if(build_system STREQUAL &quot;windows&quot;)<br>
&gt; ...<br>
&gt; endif()<br>
&gt;<br>
&gt; If someone creates a variable named &quot;windows&quot;, then this code will not work<br>
&gt; as intended.<br>
&gt;<br>
&gt; I&#39;m starting to convert our scripts to use this hopefully foolproof<br>
&gt; alternative:<br>
&gt;<br>
&gt; string(COMPARE EQUAL &quot;${build_system}&quot; windows _cmp)<br>
&gt; if (_cmp)<br>
&gt; ...<br>
&gt; endif()<br>
&gt;<br>
&gt; It will make it ugly to create a nested if else block, but it&#39;ll work.<br>
<br>
</div>You can do<br>
if(&quot;${myvar}&quot; MATCHES &quot;somestring&quot;)<br>
or more strict<br>
<br>
if(&quot;${myvar}&quot; MATCHES &quot;^somestring$&quot;)<br>
<br>
Alex<br>
</blockquote></div><br>