On 2010-05-03 15:00, Clinton Stimpson wrote:
On Monday 03 May 2010 12:42:58 pm Benoit Thomas wrote:
Hello,

Is it possible to do something like this (sorry if there are typos):

function (bar v scope)
      set (v 1 GRAND_PARENT_SCOPE)
endfunction()

function (foo v)
      bar (${v} PARENT_SCOPE)
endfunction()

foo (v)
message ("${v} == 1")

If it's not possible, I'll go with global variables. Currently, I do
global variables by doing:

set (v 1 CACHE INTERNAL "" FORCE)

But is there a better way ?

Did you mean like this?

function (bar v)
   set (${v} 1 PARENT_SCOPE)
endfunction()

function (foo v)
   bar(v1)
   set(${v} ${v1} PARENT_SCOPE)
endfunction()

foo (v)
message ("${v} == 1")

Clint
Thanks for the answer; I didn't really though of it that way.

--
Ben.
_______________________________________________
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