[cmake-developers] [CMake 0011701]: Check condition evaluation for a passed variable

Mantis Bug Tracker mantis at public.kitware.com
Fri Jan 14 14:51:30 EST 2011


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=11701 
====================================================================== 
Reported By:                Markus Elfring
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   11701
Category:                   Documentation
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2011-01-14 20:51 CET
Last Modified:              2011-01-14 20:51 CET
====================================================================== 
Summary:                    Check condition evaluation for a passed variable
Description: 
The current documentation contains the following description.

"...
The convenience feature that sometimes throws new authors is how CMake handles
values that do not match the true or false list. Those values are treated as
variables and are dereferenced even though they do not have the required ${}
syntax. This means that if you write

  if (boobah)

CMake will treat it as if you wrote

  if (${boobah})
..."


I have written a small script to test the corresponding expectations.

cmake_minimum_required(VERSION 2.6)
project(my_condition_test1)
set(MY_TEXT "condition-test1.cxx")
if(MY_TEXT)
   message(STATUS "Good day.")
else() 
   message(FATAL_ERROR "Bad day!")
endif()
if(${MY_TEXT})
   message(STATUS "This result was expected.")
else() 
   message(FATAL_ERROR "Which result should be expected here?")
endif()


I get the following log for my configuration try.
"...
Good day.
CMake Error at CMakeLists.txt:12 (message):
  Which result should be expected here?


Configuring incomplete, errors occurred!"


I have got the impression that the mentioned "convenience feature" includes the
(undocumented?) condition application "if(DEFINED variable)" so far.

Which behaviour is correct in the demonstrated situation?
Are you going to update any information sources for this issue?
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2011-01-14 20:51 Markus Elfring New Issue                                    
======================================================================




More information about the cmake-developers mailing list