瀏覽代碼

FIX: fix crashing test SubDir for xcode

Andy Cedilnik 20 年之前
父節點
當前提交
95d6107da2
共有 2 個文件被更改,包括 38 次插入20 次删除
  1. 37 20
      Source/cmGlobalXCodeGenerator.cxx
  2. 1 0
      Source/cmGlobalXCodeGenerator.h

+ 37 - 20
Source/cmGlobalXCodeGenerator.cxx

@@ -168,6 +168,7 @@ void cmGlobalXCodeGenerator::Generate()
   for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it)
   for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it)
     { 
     { 
     cmLocalGenerator* root = it->second[0];
     cmLocalGenerator* root = it->second[0];
+    m_CurrentProject = root->GetMakefile()->GetProjectName();
     this->SetCurrentLocalGenerator(root);
     this->SetCurrentLocalGenerator(root);
     m_OutputDir = m_CurrentMakefile->GetHomeOutputDirectory();
     m_OutputDir = m_CurrentMakefile->GetHomeOutputDirectory();
     m_OutputDir = cmSystemTools::CollapseFullPath(m_OutputDir.c_str());
     m_OutputDir = cmSystemTools::CollapseFullPath(m_OutputDir.c_str());
@@ -722,7 +723,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
       for(std::vector<std::string>::const_iterator d = cc.GetDepends().begin();
       for(std::vector<std::string>::const_iterator d = cc.GetDepends().begin();
           d != cc.GetDepends().end(); ++d)
           d != cc.GetDepends().end(); ++d)
         {
         {
-        if(!this->FindTarget(m_CurrentMakefile->GetProjectName(),
+        if(!this->FindTarget(m_CurrentProject.c_str(),
                              d->c_str()))
                              d->c_str()))
           {
           {
           makefileStream << "\\\n" << this
           makefileStream << "\\\n" << this
@@ -1216,7 +1217,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
   for(std::vector<cmStdString>::iterator lib = linkItems.begin();
   for(std::vector<cmStdString>::iterator lib = linkItems.begin();
       lib != linkItems.end(); ++lib)
       lib != linkItems.end(); ++lib)
     {
     {
-    cmTarget* t = this->FindTarget(m_CurrentMakefile->GetProjectName(),
+    cmTarget* t = this->FindTarget(m_CurrentProject.c_str(),
                                    lib->c_str());
                                    lib->c_str());
     cmXCodeObject* dptarget = this->FindXCodeTarget(t);
     cmXCodeObject* dptarget = this->FindXCodeTarget(t);
     if(dptarget)
     if(dptarget)
@@ -1241,30 +1242,46 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
         = cmtarget->GetUtilities().begin();
         = cmtarget->GetUtilities().begin();
       i != cmtarget->GetUtilities().end(); ++i)
       i != cmtarget->GetUtilities().end(); ++i)
     {
     {
-    cmTarget* t = this->FindTarget(m_CurrentMakefile->GetProjectName(),
+    cmTarget* t = this->FindTarget(m_CurrentProject.c_str(),
                                    i->c_str());
                                    i->c_str());
-    cmXCodeObject* dptarget = this->FindXCodeTarget(t);
-    if(dptarget)
-      {
-      this->AddDependTarget(target, dptarget);
-      }
-    else
+    if(!t)
       {
       {
       std::string m = "Error Utility: ";
       std::string m = "Error Utility: ";
-      m += i->c_str();
-      m += "\n";
-      m += "cmtarget ";
-      m += t->GetName();
-      m += "\n";
-      m += "Is on the target ";
+      m += *i;
+      m += " not found in project ";
+      m += m_CurrentProject.c_str();
+      m += " it is a utility of ";
       m += cmtarget->GetName();
       m += cmtarget->GetName();
-      m += "\n";
-      m += "But it has no xcode target created yet??\n";
-      m += "Current project is ";
-      m += m_CurrentMakefile->GetProjectName();
       cmSystemTools::Error(m.c_str());
       cmSystemTools::Error(m.c_str());
       }
       }
-    } 
+    else
+      {
+      cmXCodeObject* dptarget = this->FindXCodeTarget(t);
+      if(dptarget)
+        {
+        this->AddDependTarget(target, dptarget);
+        }
+      else
+        {
+        std::string m = "Error Utility: ";
+        m += i->c_str();
+        m += "\n";
+        m += "cmtarget ";
+        if(t)
+          {
+          m += t->GetName();
+          }
+        m += "\n";
+        m += "Is on the target ";
+        m += cmtarget->GetName();
+        m += "\n";
+        m += "But it has no xcode target created yet??\n";
+        m += "Current project is ";
+        m += m_CurrentProject.c_str();
+        cmSystemTools::Error(m.c_str());
+        }
+      } 
+    }
   std::vector<cmStdString> fullPathLibs;
   std::vector<cmStdString> fullPathLibs;
   orderLibs.GetFullPathLibraries(fullPathLibs);
   orderLibs.GetFullPathLibraries(fullPathLibs);
   for(std::vector<cmStdString>::iterator i = fullPathLibs.begin();
   for(std::vector<cmStdString>::iterator i = fullPathLibs.begin();

+ 1 - 0
Source/cmGlobalXCodeGenerator.h

@@ -143,6 +143,7 @@ private:
   bool m_DoneXCodeHack;
   bool m_DoneXCodeHack;
   std::string m_CurrentReRunCMakeMakefile;
   std::string m_CurrentReRunCMakeMakefile;
   std::string m_CurrentXCodeHackMakefile;
   std::string m_CurrentXCodeHackMakefile;
+  std::string m_CurrentProject;
   std::string m_OutputDir; 
   std::string m_OutputDir; 
   std::vector<std::string> m_CurrentOutputDirectoryComponents;
   std::vector<std::string> m_CurrentOutputDirectoryComponents;
   std::vector<std::string> m_ProjectOutputDirectoryComponents;
   std::vector<std::string> m_ProjectOutputDirectoryComponents;