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
======================================================================
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers