[CMake] Function variable name question
James Bigler
jamesbigler at gmail.com
Tue Jan 27 12:32:54 EST 2009
I have the following code in a script:
function(set_var var)
message("var = ${var}")
message("${var} = ${${var}}")
set(${var} "new_val")
message("${var} = ${${var}}\n")
endfunction()
set(myvar 10)
set_var(myvar)
# Empty variable
set_var(myvar2)
set_var(var)
# Set variable
set(var 11)
set_var(var)
When I run it I get the following output:
var = myvar
myvar = 10
myvar = new_val
var = myvar2
myvar2 =
myvar2 = new_val
var = var
var = var
new_val =
var = var
var = var
new_val =
I get expected output when the name of the variable I pass in isn't the same
as the one used in the function parameter list.
Is this the desired behavior of the language? I would argue that it isn't,
because you get different behavior based on the name of the variable passed
in.
I'm using CMake 2.6.3R8 on WinXP 64.
Thanks,
James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090127/0c124ff7/attachment.htm>
More information about the CMake
mailing list