How to write a variable to the parents' parent

2019-08-29 09:35发布

问题:

I know that when I am in a function, I can set the variable in the calling scope by using:

set(MYVAR 1 PARENT_SCOPE)

What I want is to be able to set a variable in the grandparent scope (if it exists).

I know that if I redefine my function as a macro, then set(MYVAR 1 PARENT_SCOPE) effectively does what I need. But unfortunately, I cannot do that for unrelated reasons.

A solution would work for me as a walkaround for the problem in How to check if the variable is set in the parent scope, (as opposed to being inherited from grandparents) in CMake? .

标签: cmake scope