[CMake] Weird behaviour of mark_as_advanced(), find_program() and the cache

Alexander Neundorf a.neundorf-work at gmx.net
Wed Mar 3 12:28:01 EST 2010


On Wednesday 03 March 2010, Brad King wrote:
> Alexander Neundorf wrote:
> > This sees the variable is already in the cache, but without meta info and
> > adds it using AddCacheDefinition().
> > After this call, makefile->GetDefinition("FOO") returns an empty string,
> > before this call it still returns "foo".
>
> It's not the empty string in find_program()'s call to AddCacheDefinition
> that raises this problem.  It's the bottom of cmMakefile's implementation
> of the method:
>
>   // if there was a definition then remove it
>   this->Internal->VarStack.top().Set(name, 0);
>
> > I didn't figure out the correct way how to improve this.
>
> This is related to the open issue
>
>   http://www.cmake.org/Bug/view.php?id=9008
>
> discussed previously.

Yes.

> > I think it should end up in the cache as "foo" with the type "FILEPATH",
> > but I didn't figure out how to achieve this.
>
> Issue #9008 basically means you should never mix cache and non-cache
> variables with the same name.  There are all kinds of historical reasons
> behind their interaction and changing anything will lead to subtle breakage
> for someone. (The original attempt at CMP0015 for issue 9008 is evidence of
> this.)

Yes, I remember.
Still this issue here is really weird, the variable suddenly becomes empty, 
although the "normal" variable was set before to a value and the 
find_program() should have put something (either "foo" or its result) into 
the cache.
But afterwards, the normal variable is gone and the cache is empty.

Should I add this testcase to #9008 ?

Alex


More information about the CMake mailing list