On Friday 18 January 2008, Rodolfo Schulz de Lima wrote:
> Miguel A. Figueroa-Villanueva wrote:
> > Again, I think this behaviour is a quite unintuitive and should be
> > well documented, at least.
>
> I shall add that at first I expected 'raise_scope' to work like 'set'
> when the parameter <value> is a list. But, for instance:
>
> set(mylist item1 item2 item3)
>
> set(var1 ${mylist})
> raise_scope(var2 ${mylist})
>
> in this example, var1 gets the 3 items, whereas var2 gets only 'item1'.
> That's odd and also counterintuitive.
How about the attached patch ?
It adds an argument PARENT_SCOPE to the SET() command, which then replaces the
RAISE_SCOPE() command:
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 ?
Bye
Alex
Index: cmSetCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSetCommand.cxx,v
retrieving revision 1.30
diff -b -u -p -r1.30 cmSetCommand.cxx
--- cmSetCommand.cxx 1 Aug 2006 15:38:41 -0000 1.30
+++ cmSetCommand.cxx 18 Jan 2008 17:48:16 -0000
@@ -74,29 +74,42 @@ bool cmSetCommand::InitialPass(std::vect
std::string value; // optional
bool cache = false; // optional
bool force = false; // optional
+ bool parentScope = false;
cmCacheManager::CacheEntryType type
= cmCacheManager::STRING; // required if cache
const char* docstring = 0; // required if cache
std::string::size_type cacheStart = 0;
+ unsigned int ignoreLastArgs = 0;
+ // look for PARENT_SCOPE argument
+ if (args.size() > 1 && args[args.size()-1] == "PARENT_SCOPE")
+ {
+ parentScope = true;
+ ignoreLastArgs++;
+ }
+ else
+ {
// look for FORCE argument
if (args.size() > 4 && args[args.size()-1] == "FORCE")
{
force = true;
+ ignoreLastArgs++;
}
// check for cache signature
if (args.size() > 3 && args[args.size() - 3 - (force ? 1 : 0)] == "CACHE")
{
cache = true;
+ ignoreLastArgs+=3;
+ }
}
// collect any values into a single semi-colon seperated value list
if(static_cast<unsigned short>(args.size()) >
- static_cast<unsigned short>(1 + (cache ? 3 : 0) + (force ? 1 : 0)))
+ static_cast<unsigned short>(1 + ignoreLastArgs))
{
value = args[1];
- size_t endPos = args.size() - (cache ? 3 : 0) - (force ? 1 : 0);
+ size_t endPos = args.size() - ignoreLastArgs;
for(size_t i = 2; i < endPos; ++i)
{
value += ";";
@@ -104,6 +117,20 @@ bool cmSetCommand::InitialPass(std::vect
}
}
+ if (parentScope)
+ {
+ if (value.empty())
+ {
+ this->Makefile->RaiseScope(variable, 0);
+ }
+ else
+ {
+ this->Makefile->RaiseScope(variable, value.c_str());
+ }
+ return true;
+ }
+
+
// we should be nice and try to catch some simple screwups if the last or
// next to last args are CACHE then they screwed up. If they used FORCE
// without CACHE they screwed up
_______________________________________________
CMake mailing list
[email protected]
http://www.cmake.org/mailman/listinfo/cmake