On Saturday 16 February 2008, Alexander Neundorf wrote:
> On Saturday 16 February 2008, Bill Hoffman wrote:
> > Alexander Neundorf wrote:
> > > On Friday 18 January 2008, Alexander Neundorf wrote:
>
> ...
>
> > >> set(foo a b c PARENT_SCOPE)
> > >>
> > >> I'm not sure it is a good idea that this also propagates to the parent
> > >> directory. What is a use case for this ?
> > >
> > > What do you think about this ?
> > > I think it's no good idea. Until now you can rely on that whatever
> > > happens in subdirectories doesn't modify variables in the parent
> > > directory (the only way is to force something through the cache, which
> > > is a bit ugly).
> > > If you need to get information from a subdir to some other place, with
> > > cmake 2.6 you can use a global property to do this, which will also
> > > work over multiple levels of subdirectories. Doing this using
> > > PARENT_SCOPE would require to build a chain of these calls through all
> > > directories, which I think is not very nice and can require relatively
> > > much code.
> > >
> > > Do you have objections to removing that feature (propagating to the
> > > parent directory) ?
> >
> > I am pretty sure raise_scope was removed in favor of this version of
> > set, so if you remove it, there will be no way to raise scope...
>
> I don't mean to remove the SET(PARENT_SCOPE) feature, where the main
> purpose is to set a global variable from within a function.
> But if SET( ... PARENT_SCOPE) is called outside a function, the effect is
> that the variable is set in the parent directory. This is the part where
> I'm not sure it's a good idea.

...this would be the patch, with the patch PARENT_SCOPE only raises the scope 
out of a function, but not to the parent directory anymore.

Alex
Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.437
diff -b -u -p -r1.437 cmMakefile.cxx
--- cmMakefile.cxx	14 Feb 2008 21:42:29 -0000	1.437
+++ cmMakefile.cxx	16 Feb 2008 19:09:00 -0000
@@ -3004,22 +3004,6 @@ void cmMakefile::RaiseScope(const char *
       this->DefinitionStack[this->DefinitionStack.size()-2].erase(var);
       }
     }
-  // otherwise do the parent (if one exists)
-  else if (this->LocalGenerator->GetParent())
-    {
-    cmMakefile *parent = this->LocalGenerator->GetParent()->GetMakefile();
-    if (parent)
-      {
-      if(varDef)
-        {
-        parent->AddDefinition(var,varDef);
-        }
-      else
-        {
-        parent->RemoveDefinition(var);
-        }
-      }
-    }
 }
 
 
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to