Can a parent detect what a function has changed with
My use case is that I have multiple layer of function. Previously,
func1() simply called
func2() but now
func1_a() which calls
func1_a() I want to transparently pass everything that
func2() changes up to
Note that I cannot make
func1_a() simply a macro, it has to be a function. And I using cached/internal variables is also not really an option, as this would expose some internals that should not be exposed actually.
You can use the property
VARIABLES to retrieve the list of all variables accessible in the current scope (this includes cache variables). You could store the values of all variables of intereset before calling
func2(), then compare their values after the call, and propagate upwards whatever changed. I can’t say I would recommend this solution (and it will have its performance costs), but it is a solution.
Thanks, that would be a technical solution indeed.
I wonder, if I should raise a feature request, that CMake should set a variable that contains the list of modified variables? The other solution would work by cooperation, the called function should provide such a list
I’ve usually had such functions take variable names as parameters rather than using hard-coded variable names (if you can change the inner function signature).