[CMake] Functions inherit parent variables?

Johannes Zarl johannes.zarl at jku.at
Wed Mar 7 05:49:58 EST 2012


Drifting away from the original thread topic...

On Tuesday 06 March 2012, 08:09:27, Michael Hertling wrote:
> IMO, the documentation of the PARENT_SCOPE flag is sufficiently clear:
> 
> "If PARENT_SCOPE is present, the variable will be set in the scope
> *above* the current scope. Each new directory or function creates
> a new scope. This command will set the value of a variable into
> the *parent* directory or *calling* function (whichever is
> applicable to the case at hand)."
> 
> Not a word about setting anything in the current scope, 

Well, one could argue that not saying anything about the current scope means 
that it works in the current scope just as expected. 

I would have expected that when nothing is said about the current scope, the 
functionality in the current scope is unaffected by PARENT_SCOPE. Others might 
expect (correctly) that if nothing is said about the current scope, it doesn't 
apply to the current scope.

So: nothing _wrong_ with the documentation. It's just that people like me who 
have the wrong notion to begin with can read the documentation without 
realising that they are wrong.

> and as for me, the explanation of CACHE/INTERNAL/FORCE, e.g., is rather
> vague.

You're right. This assumes some knowledge about the cmake cache that is not 
really described anywhere in the docs.

Cheers,
  Johannes


More information about the CMake mailing list