Forráskód Böngészése

cmGlobalGenerator: Port Find API to cmMakefile.

Stephen Kelly 10 éve
szülő
commit
5f66900e71

+ 2 - 5
Source/cmGetDirectoryPropertyCommand.cxx

@@ -51,10 +51,8 @@ bool cmGetDirectoryPropertyCommand
     sd = cmSystemTools::CollapseFullPath(sd);
 
     // lookup the makefile from the directory name
-    cmLocalGenerator *lg =
-      this->Makefile->GetGlobalGenerator()->
-      FindLocalGenerator(sd);
-    if (!lg)
+    dir = this->Makefile->GetGlobalGenerator()->FindMakefile(sd);
+    if (!dir)
       {
       this->SetError
         ("DIRECTORY argument provided but requested directory not found. "
@@ -62,7 +60,6 @@ bool cmGetDirectoryPropertyCommand
          "it is valid but has not been processed yet.");
       return false;
       }
-    dir = lg->GetMakefile();
     ++i;
     }
 

+ 2 - 7
Source/cmGetPropertyCommand.cxx

@@ -262,13 +262,8 @@ bool cmGetPropertyCommand::HandleDirectoryMode()
     dir = cmSystemTools::CollapseFullPath(dir);
 
     // Lookup the generator.
-    if(cmLocalGenerator* lg =
-       (this->Makefile->GetGlobalGenerator()->FindLocalGenerator(dir)))
-      {
-      // Use the makefile for the directory found.
-      mf = lg->GetMakefile();
-      }
-    else
+    mf = this->Makefile->GetGlobalGenerator()->FindMakefile(dir);
+    if (!mf)
       {
       // Could not find the directory.
       this->SetError

+ 14 - 0
Source/cmGlobalGenerator.cxx

@@ -2160,6 +2160,20 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap()
     }
 }
 
+cmMakefile*
+cmGlobalGenerator::FindMakefile(const std::string& start_dir) const
+{
+  for(std::vector<cmMakefile*>::const_iterator it =
+      this->Makefiles.begin(); it != this->Makefiles.end(); ++it)
+    {
+    std::string sd = (*it)->GetCurrentSourceDirectory();
+    if (sd == start_dir)
+      {
+      return *it;
+      }
+    }
+  return 0;
+}
 
 ///! Find a local generator by its startdirectory
 cmLocalGenerator*

+ 1 - 0
Source/cmGlobalGenerator.h

@@ -256,6 +256,7 @@ public:
       that is a framework. */
   bool NameResolvesToFramework(const std::string& libname) const;
 
+  cmMakefile* FindMakefile(const std::string& start_dir) const;
   ///! Find a local generator by its startdirectory
   cmLocalGenerator* FindLocalGenerator(const std::string& start_dir) const;
 

+ 2 - 8
Source/cmSetPropertyCommand.cxx

@@ -205,14 +205,8 @@ bool cmSetPropertyCommand::HandleDirectoryMode()
     // The local generators are associated with collapsed paths.
     dir = cmSystemTools::CollapseFullPath(dir);
 
-    // Lookup the generator.
-    if(cmLocalGenerator* lg =
-       this->Makefile->GetGlobalGenerator()->FindLocalGenerator(dir))
-      {
-      // Use the makefile for the directory found.
-      mf = lg->GetMakefile();
-      }
-    else
+    mf = this->Makefile->GetGlobalGenerator()->FindMakefile(dir);
+    if (!mf)
       {
       // Could not find the directory.
       this->SetError