MantisBT - CMake
View Issue Details
0008823CMakeCMakepublic2009-03-31 12:202015-07-08 08:57
James Bigler 
Bill Hoffman 
normalminoralways
closedfixed 
CMake-2-6 
CMake 3.1 
0008823: if(variable STREQUAL string) can treak LHS as a variable name
Consider the following code snippet.

set(var "stuff")
set(stuff ON)
if(var STREQUAL "stuff")
  message("var STREQUAL stuff")
else()
  message("NOT var STREQUAL stuff")
endif()

According to the documentation, the LHS of STREQUAL should be treated as a string.

         if(variable STREQUAL string)
         if(string STREQUAL string)

However the behavior of the if statement changes depending on if 'stuff' is defined contrary to the documentation.

For comparison, MATCHES works as expected (results not dependent on the variable 'stuff' being defined).

No tags attached.
related to 0008226closed Bill Hoffman if expansion of quoted arguments as variables should be deprecated 
Issue History
2009-03-31 12:20James BiglerNew Issue
2009-05-05 14:58mwoehlkeNote Added: 0016297
2009-09-14 12:51Bill HoffmanStatusnew => assigned
2009-09-14 12:51Bill HoffmanAssigned To => Bill Hoffman
2009-09-14 13:26James BiglerNote Added: 0017447
2010-11-30 16:26James BiglerRelationship addedrelated to 0008226
2015-02-26 16:12Stephen KellyNote Added: 0038090
2015-02-26 16:12Stephen KellyStatusassigned => resolved
2015-02-26 16:12Stephen KellyFixed in Version => CMake 3.1
2015-02-26 16:12Stephen KellyResolutionopen => fixed
2015-07-08 08:57Robert MaynardNote Added: 0039079
2015-07-08 08:57Robert MaynardStatusresolved => closed

Notes
(0016297)
mwoehlke   
2009-05-05 14:58   
This thread from the mailing list addresses a similar topic:
http://thread.gmane.org/gmane.comp.programming.tools.cmake.user/17534 [^]

Also see related bug 0008226.
(0017447)
James Bigler   
2009-09-14 13:26   
I made a slight error in the description: LHS should probably be RHS.
(0038090)
Stephen Kelly   
2015-02-26 16:12   
Fixed in 3.1:

 If: Introduce policy CMP0054 - don't dereference quoted variables in if()
 http://www.cmake.org/gitweb?p=cmake.git;a=commitdiff;h=188a1f23 [^]
(0039079)
Robert Maynard   
2015-07-08 08:57   
Closing resolved issues that have not been updated in more than 4 months.