[cmake-commits] martink committed cmCommands.cxx 1.114 1.115 cmGetCMakePropertyCommand.cxx 1.6 1.7 cmMakefile.cxx 1.399 1.400 cmSetDirectoryPropertiesCommand.cxx 1.5 1.6 cmSetPropertiesCommand.cxx 1.7 1.8 cmake.cxx 1.301 1.302

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Jun 25 09:51:39 EDT 2007


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv19620/Source

Modified Files:
	cmCommands.cxx cmGetCMakePropertyCommand.cxx cmMakefile.cxx 
	cmSetDirectoryPropertiesCommand.cxx cmSetPropertiesCommand.cxx 
	cmake.cxx 
Log Message:
ENH: some property cleanup and added GetProperty


Index: cmCommands.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCommands.cxx,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -d -r1.114 -r1.115
--- cmCommands.cxx	18 Jun 2007 15:59:23 -0000	1.114
+++ cmCommands.cxx	25 Jun 2007 13:51:37 -0000	1.115
@@ -28,6 +28,7 @@
 #include "cmExportLibraryDependencies.cxx"
 #include "cmFLTKWrapUICommand.cxx"
 #include "cmGetDirectoryPropertyCommand.cxx"
+#include "cmGetPropertyCommand.cxx"
 #include "cmGetTestPropertyCommand.cxx"
 #include "cmIncludeExternalMSProjectCommand.cxx"
 #include "cmInstallCommand.cxx"
@@ -81,6 +82,7 @@
   commands.push_back(new cmExportLibraryDependenciesCommand);
   commands.push_back(new cmFLTKWrapUICommand);
   commands.push_back(new cmGetDirectoryPropertyCommand);
+  commands.push_back(new cmGetPropertyCommand);
   commands.push_back(new cmGetTestPropertyCommand);
   commands.push_back(new cmIncludeExternalMSProjectCommand);
   commands.push_back(new cmInstallCommand);

Index: cmSetPropertiesCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSetPropertiesCommand.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- cmSetPropertiesCommand.cxx	12 Dec 2006 15:07:20 -0000	1.7
+++ cmSetPropertiesCommand.cxx	25 Jun 2007 13:51:37 -0000	1.8
@@ -80,9 +80,13 @@
     {
     scope = cmProperty::GLOBAL;
     }
-  else if (args[0] == "DIRECTORY" && numFiles == 1)
+  else if (args[0] == "DIRECTORY" && numFiles >= 1)
     {
     scope = cmProperty::DIRECTORY;
+    if (numFiles == 2)
+      {
+      scopeName = args[1].c_str();
+      }
     }
   else if (args[0] == "TARGET" && numFiles == 2)
     {
@@ -122,16 +126,39 @@
       break;
     case cmProperty::DIRECTORY:
       {
-      std::string errors;
-      bool ret = 
-        cmSetDirectoryPropertiesCommand::RunCommand(this->Makefile,
-                                                    args.begin() + 2,
-                                                    args.end(),
-                                                    errors);
-      if (!ret)
+      // lookup the makefile from the directory name
+      cmLocalGenerator *lg = this->Makefile->GetLocalGenerator();
+      if (numFiles == 2)
         {
-        this->SetError(errors.c_str());
-        return ret;
+        std::string sd = scopeName;
+        // make sure the start dir is a full path
+        if (!cmSystemTools::FileIsFullPath(sd.c_str()))
+          {
+          sd = this->Makefile->GetStartDirectory();
+          sd += "/";
+          sd += scopeName;
+          }
+        
+        // The local generators are associated with collapsed paths.
+        sd = cmSystemTools::CollapseFullPath(sd.c_str());
+        
+        lg = this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->
+          FindLocalGenerator(sd.c_str());
+        }
+      if (!lg)
+        {
+        this->SetError
+          ("DIRECTORY argument provided but requested directory not found. "
+           "This could be because the directory argument was invalid or, "
+           "it is valid but has not been processed yet.");
+        return false;
+        }
+      
+      for(j= propertyPairs.begin(); j != propertyPairs.end(); ++j)
+        {
+        const char *pn = j->c_str();
+        ++j;
+        lg->GetMakefile()->SetProperty(pn,j->c_str());
         }
       }
       break;
@@ -139,8 +166,9 @@
       {
       for(j= propertyPairs.begin(); j != propertyPairs.end(); ++j)
         {
-        this->Makefile->GetCMakeInstance()->SetProperty(j->c_str(),
-                                                        (++j)->c_str());
+        const char *pn = j->c_str();
+        ++j;
+        this->Makefile->GetCMakeInstance()->SetProperty(pn, j->c_str());
         }
       }
       break;

Index: cmake.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.cxx,v
retrieving revision 1.301
retrieving revision 1.302
diff -u -d -r1.301 -r1.302
--- cmake.cxx	22 Jun 2007 12:44:51 -0000	1.301
+++ cmake.cxx	25 Jun 2007 13:51:37 -0000	1.302
@@ -3028,6 +3028,40 @@
 const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope)
 {
   bool chain = false;
+
+  // watch for special properties
+  std::string propname = prop;
+  std::string output = "";
+  if ( propname == "CACHE_VARIABLES" )
+    {
+    cmCacheManager::CacheIterator cit =
+      this->GetCacheManager()->GetCacheIterator();
+    for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() )
+      {
+      if ( output.size() )
+        {
+        output += ";";
+        }
+      output += cit.GetName();
+      }
+    this->SetProperty("CACHE_VARIABLES", output.c_str());
+    }
+  else if ( propname == "COMMANDS" )
+    {
+    cmake::RegisteredCommandsMap::iterator cmds 
+        = this->GetCommands()->begin();
+    for (unsigned int cc=0 ; cmds != this->GetCommands()->end(); ++ cmds )
+      {
+      if ( cc > 0 )
+        {
+        output += ";";
+        }
+      output += cmds->first.c_str();
+      cc++;
+      }
+    this->SetProperty("COMMANDS",output.c_str());
+    }
+  
   return this->Properties.GetPropertyValue(prop, scope, chain);
 }
 

Index: cmGetCMakePropertyCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGetCMakePropertyCommand.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- cmGetCMakePropertyCommand.cxx	15 Mar 2006 16:02:01 -0000	1.6
+++ cmGetCMakePropertyCommand.cxx	25 Jun 2007 13:51:37 -0000	1.7
@@ -30,15 +30,11 @@
   
   std::vector<std::string>::size_type cc;
   std::string variable = args[0];
-  std::string output = "";
+  std::string output = "NOTFOUND";
 
-  if ( args[1] == "VARIABLES" || args[1] == "CACHE_VARIABLES" )
+  if ( args[1] == "VARIABLES")
     {
     int cacheonly = 0;
-    if ( args[1] == "CACHE_VARIABLES" )
-      {
-      cacheonly = 1;
-      }
     std::vector<std::string> vars = this->Makefile->GetDefinitions(cacheonly);
     for ( cc = 0; cc < vars.size(); cc ++ )
       {
@@ -49,31 +45,18 @@
       output += vars[cc];
       }
     }
-  else if ( args[1] == "COMMANDS" )
-    {
-    cmake::RegisteredCommandsMap::iterator cmds 
-        = this->Makefile->GetCMakeInstance()->GetCommands()->begin();
-    for (cc=0 ; 
-      cmds != this->Makefile->GetCMakeInstance()->GetCommands()->end(); 
-      ++ cmds )
-      {
-      if ( cc > 0 )
-        {
-        output += ";";
-        }
-      output += cmds->first.c_str();
-      cc++;
-      }
-    }
   else if ( args[1] == "MACROS" )
     {
     this->Makefile->GetListOfMacros(output);
     }
   else
     {
-    std::string emsg = "Unknown CMake property: " + args[1];
-    this->SetError(emsg.c_str());
-    return false;
+    const char *prop = 
+      this->Makefile->GetCMakeInstance()->GetProperty(args[1].c_str());
+    if (prop)
+      {
+      output = prop;
+      }
     }
   this->Makefile->AddDefinition(variable.c_str(), output.c_str());
   

Index: cmSetDirectoryPropertiesCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSetDirectoryPropertiesCommand.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cmSetDirectoryPropertiesCommand.cxx	7 Dec 2006 14:44:45 -0000	1.5
+++ cmSetDirectoryPropertiesCommand.cxx	25 Jun 2007 13:51:37 -0000	1.6
@@ -67,35 +67,7 @@
         "Commands and macros cannot be set using SET_CMAKE_PROPERTIES";
       return false;
       }
-    else if ( prop == "INCLUDE_DIRECTORIES" )
-      {
-      std::vector<std::string> varArgsExpanded;
-      cmSystemTools::ExpandListArgument(value, varArgsExpanded);
-      mf->SetIncludeDirectories(varArgsExpanded);
-      }
-    else if ( prop == "LINK_DIRECTORIES" )
-      {
-      std::vector<std::string> varArgsExpanded;
-      cmSystemTools::ExpandListArgument(value, varArgsExpanded);
-      mf->SetLinkDirectories(varArgsExpanded);
-      }
-    else if ( prop == "INCLUDE_REGULAR_EXPRESSION" )
-      {
-      mf->SetIncludeRegularExpression(value.c_str());
-      }
-    else
-      {
-      if ( prop == "ADDITIONAL_MAKE_CLEAN_FILES" )
-        {
-        // This property is not inherrited
-        if ( strcmp(mf->GetCurrentDirectory(), 
-                    mf->GetStartDirectory()) != 0 )
-          {
-          continue;
-          }
-        }
-      mf->SetProperty(prop.c_str(), value.c_str());
-      }
+    mf->SetProperty(prop.c_str(), value.c_str());
     }
   
   return true;

Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.399
retrieving revision 1.400
diff -u -d -r1.399 -r1.400
--- cmMakefile.cxx	22 Jun 2007 13:58:10 -0000	1.399
+++ cmMakefile.cxx	25 Jun 2007 13:51:37 -0000	1.400
@@ -2534,6 +2534,41 @@
     {
     return;
     }
+  
+  // handle special props
+  std::string propname = prop;
+  if ( propname == "INCLUDE_DIRECTORIES" )
+    {
+    std::vector<std::string> varArgsExpanded;
+    cmSystemTools::ExpandListArgument(value, varArgsExpanded);
+    this->SetIncludeDirectories(varArgsExpanded);
+    return;
+    }
+
+  if ( propname == "LINK_DIRECTORIES" )
+    {
+    std::vector<std::string> varArgsExpanded;
+    cmSystemTools::ExpandListArgument(value, varArgsExpanded);
+    this->SetLinkDirectories(varArgsExpanded);
+    return;
+    }
+  
+  if ( propname == "INCLUDE_REGULAR_EXPRESSION" )
+    {
+    this->SetIncludeRegularExpression(value);
+    return;
+    }
+
+  if ( propname == "ADDITIONAL_MAKE_CLEAN_FILES" )
+    {
+    // This property is not inherrited
+    if ( strcmp(this->GetCurrentDirectory(), 
+                this->GetStartDirectory()) != 0 )
+      {
+      return;
+      }
+    }
+
   this->Properties.SetProperty(prop,value,cmProperty::DIRECTORY);
 }
 



More information about the Cmake-commits mailing list