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

--
Glenn


On 12 May 2011 07:27, Rolf Eike Beer <e...@sf-mail.de> wrote:

> > This is funny:
> > FUNCTION(build var)
> >       MESSAGE(STATUS "var: " ${${var}})
> > ENDFUNCTION(build)
> >
> > SET(var red blue yellow green)
> > build(var)
> >
> > Output:
> > -- var: var
> >
> > SET(varX red blue yellow green)
> > build(varX)
> > Output:
> > -- var: redblueyellowgreen
>
> No, it must be that way. Inside build() var is defined as the variable
> that is defined in the interface. build() has no way to see the variable
> outside it because it can only find the inner name. It could reference
> it's value if you had passed the value or it could reference the variable
> by name if it would not be hidden by your interface variable.
>
> int a = 2;
>
> int build(int a)
> {
>  return a;
> }
>
> int b = build(42);
>
> b will be 42.
>
> Eike
> _______________________________________________
> 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