View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008823CMakeCMakepublic2009-03-31 12:202015-07-08 08:57
ReporterJames Bigler 
Assigned ToBill Hoffman 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake-2-6 
Target VersionFixed in VersionCMake 3.1 
Summary0008823: if(variable STREQUAL string) can treak LHS as a variable name
DescriptionConsider 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).

TagsNo tags attached.
Attached Files

 Relationships
related to 0008226closedBill Hoffman if expansion of quoted arguments as variables should be deprecated 

  Notes
(0016297)
mwoehlke (developer)
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 (developer)
2009-09-14 13:26

I made a slight error in the description: LHS should probably be RHS.
(0038090)
Stephen Kelly (developer)
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 (manager)
2015-07-08 08:57

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2009-03-31 12:20 James Bigler New Issue
2009-05-05 14:58 mwoehlke Note Added: 0016297
2009-09-14 12:51 Bill Hoffman Status new => assigned
2009-09-14 12:51 Bill Hoffman Assigned To => Bill Hoffman
2009-09-14 13:26 James Bigler Note Added: 0017447
2010-11-30 16:26 James Bigler Relationship added related to 0008226
2015-02-26 16:12 Stephen Kelly Note Added: 0038090
2015-02-26 16:12 Stephen Kelly Status assigned => resolved
2015-02-26 16:12 Stephen Kelly Fixed in Version => CMake 3.1
2015-02-26 16:12 Stephen Kelly Resolution open => fixed
2015-07-08 08:57 Robert Maynard Note Added: 0039079
2015-07-08 08:57 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team