<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 04-Sep-14 16:48, Chuck Atkins wrote:<br>
</div>
<blockquote
cite="mid:CAOXZzG7Y2ZSZb8Rf5HSkkoUVaff5+CRriHR68zCcnhkVfy=OQQ@mail.gmail.com"
type="cite">
<div dir="ltr"><br>
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"> Command `if(a
MATCHES ...)` has the same flaw:
`if(<variable|string> MATCHES regex)`:<br>
..<br>
set(MYSTRING "B")<br>
set(A "MYSTRING")<br>
if("${A}" MATCHES "^MYSTRING$")<br>
# do *not* go here even A is MYSTRING (use *variable*
MYSTRING)<br>
endif()<br>
</div>
</blockquote>
<div> <br>
This should work without dereferencing A, i.e.:<br>
</div>
<br>
<span style="font-family:courier new,monospace">if(A MATCHES
"^MYSTRING$")<br>
</span></div>
<div class="gmail_quote">
<span style="font-family:courier new,monospace"> # Bingo<br>
</span></div>
<div class="gmail_quote"><span style="font-family:courier
new,monospace">endif()</span><br>
</div>
</div>
</div>
</blockquote>
Yes, but what if you need to combine some values, like:
`if("${A}-${B}" MATCHES ...)`?<br>
Note that `if(A MATCHES "first-part" AND B MATCHES "second-part")`
is not the solutions in some cases, for example:<br>
<br>
if("${A}${B}" MATCHES "/home/my/dir-A/")<br>
<br>
should work for both A,B = {"/home/", "my/dir-A/"} and {"/home/my/",
"dir-A/"}<br>
<br>
Also you always need keep in mind that it's not a string, but a
regular expression, example:<br>
<br>
set(A "path/to/test/project")<br>
set(B "path/to/test.project")<br>
<br>
message("A and B same dir?")<br>
if(A MATCHES "^${B}$")<br>
message("surprise")<br>
endif()<br>
</body>
</html>