If you really wanted to pass the name of the variable in rather than the
value, then as Rolf says the behaviour you get is as expected.  The only way
round that would be to rename var in the function to something guaranteed
not to be the name of a variable that you ever tried to pass in.

Or you could use a macro instead:

MACRO(buildm var)
       MESSAGE(STATUS "var: " ${${var}})
ENDMACRO()

SET(var red blue yellow green)
buildm(var)

-- var: redblueyellowgreen

--
Glenn


On 12 May 2011 13:21, Micha Renner <micha.ren...@t-online.de> wrote:

> Am Donnerstag, den 12.05.2011, 11:50 +0100 schrieb Glenn Coombs:
> > I think you probably wanted to write and call your function like this:
> >
> > FUNCTION(build var)
> >        MESSAGE(STATUS "var: ${var}")
> > ENDFUNCTION(build)
> >
> > SET(var red blue yellow green)
> > build("${var}")
> >
> > That prints out as you would expect:
> >
> > -- var: red;blue;yellow;green
> >
> Both versions are possible.
> My point was, that in the case I described, the name of the parameter of
> the function may not be the same as the name of variable the function is
> called.
>
> With your version you don't have this problem.
> Thanks.
>
> Micha
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to