[CMake] getting "new/updated" variable from PARENT SCOPE

Doug Reiland dreiland at gmail.com
Thu Jun 3 11:19:07 EDT 2010


Is there a way to an updated variable from parent scope?

For example,
I am in a sub-directory

set(FOO 2 PARENT_SCOPE)

...

<still in sub-directory>
retrieve FOO from PARENT_SCOPE

I know sub-directory would get a copy of FOO, if it existed, when it
was entered.

I played with set/get_property() for this, but which worked ok until I
wanted to store a list

set(FOO a b c PARENT_SCOPE)
set_property(GLOBAL APPEND PROPERTY FOO-LIST FOO)
get_property(my-foo-list GLOBAL PROPERTY FOO-LIST)
foreach (e ${my-foo-list})
        message("TEST ${${e}}")
        message(TEST2="${e}")
endforeach()

This outputs:
TEST
TEST2="FOO"

Thanks


More information about the CMake mailing list