[cmake-developers] [CMake 0013523]: Function defined in a subdiretory can't see its global variables when called from outside
Mantis Bug Tracker
mantis at public.kitware.com
Thu Sep 6 20:20:45 EDT 2012
The following issue has been SUBMITTED.
======================================================================
http://cmake.org/Bug/view.php?id=13523
======================================================================
Reported By: quaker
Assigned To:
======================================================================
Project: CMake
Issue ID: 13523
Category: CMake
Reproducibility: always
Severity: minor
Priority: normal
Status: new
======================================================================
Date Submitted: 2012-09-06 20:20 EDT
Last Modified: 2012-09-06 20:20 EDT
======================================================================
Summary: Function defined in a subdiretory can't see its
global variables when called from outside
Description:
Usually functions can read global variables that are set in the same directory.
But this doesn't work when a function that is defined in a subdirectory is
called from its parent directory.
Steps to Reproduce:
1. Create CMakeLists.txt with the following text:
cmake_minimum_required(VERSION 2.8)
set(FOO "bar")
function(test)
message("test(): FOO=${FOO}")
endfunction()
test()
add_subdirectory(sub)
sub_test()
2. Create a subdirectory called "sub" and another CMakeLists.txt in it:
set(SUB_FOO "sub_bar")
function(sub_test)
message("sub_test(): SUB_FOO=${SUB_FOO}")
endfunction()
3. Run cmake against the root directory
Exptected output:
test(): FOO=bar
sub_test(): SUB_FOO=sub_bar
Actual result:
test(): FOO=bar
sub_test(): SUB_FOO=
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2012-09-06 20:20 quaker New Issue
2012-09-06 20:20 quaker File Added: test.zip
======================================================================
More information about the cmake-developers
mailing list