[cmake-developers] [CMake 0015709]: variables defined state is not reset after using it for iteration in foreach
Mantis Bug Tracker
mantis at public.kitware.com
Mon Aug 24 08:39:50 EDT 2015
The following issue has been SUBMITTED.
======================================================================
http://public.kitware.com/Bug/view.php?id=15709
======================================================================
Reported By: Jan Christoph Uhde
Assigned To:
======================================================================
Project: CMake
Issue ID: 15709
Category: CMake
Reproducibility: always
Severity: minor
Priority: normal
Status: new
======================================================================
Date Submitted: 2015-08-24 08:39 EDT
Last Modified: 2015-08-24 08:39 EDT
======================================================================
Summary: variables defined state is not reset after using it
for iteration in foreach
Description:
When using a prior undefined variable in a foreach(x ${foo}) loop it is still
defined after the loop.
We noticed it due to the following warning:
/usr/share/cmake-3.2/Modules/CheckSymbolExists.cmake:
53 macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE)
54 if(NOT DEFINED "${VARIABLE}" OR "x${${VARIABLE}}" STREQUAL "x${VARIABLE}")
-- Looking for include file pthread.h - found
CMake Warning (dev) at /usr/share/cmake-3.2/Modules/CheckSymbolExists.cmake:54
(if):
Policy CMP0054 is not set: Only interpret if() arguments as variables or
keywords when unquoted. Run "cmake --help-policy CMP0054" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.
Quoted variables like "x" will no longer be dereferenced when the policy is
set to NEW. Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
/usr/share/cmake-3.2/Modules/CheckSymbolExists.cmake:50 (_CHECK_SYMBOL_EXISTS)
/usr/share/cmake-3.2/Modules/FindThreads.cmake:133 (CHECK_SYMBOL_EXISTS)
5axis/test/exactoutputBTOneFile/CMakeLists.txt:13 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
The name "x" was not a good choice. But the behavior is really unintuitive.
Cheers
Jan
Steps to Reproduce:
cmake_minimum_required(VERSION 3.2)
set(FOO "this" "is" "borken")
foreach(x ${FOO})
message(mesage: ${x})
endforeach()
if(DEFINED x)
message("x is still defined")
endif()
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2015-08-24 08:39 Jan Christoph UhdeNew Issue
======================================================================
More information about the cmake-developers
mailing list