浏览代码

ENH: Generator now creates a separate intermediate files directory for each target. This is needed for MSVC 8 to support parallel builds.

Brad King 20 年之前
父节点
当前提交
f9aef0e422

+ 2 - 2
Source/cmGlobalVisualStudio7Generator.cxx

@@ -31,7 +31,7 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator()
 void cmGlobalVisualStudio7Generator::EnableLanguage(std::vector<std::string>const &  lang, 
                                                     cmMakefile *mf)
 {
-  mf->AddDefinition("CMAKE_CFG_INTDIR","$(IntDir)");
+  mf->AddDefinition("CMAKE_CFG_INTDIR","$(OutDir)");
   mf->AddDefinition("CMAKE_GENERATOR_CC", "cl");
   mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl");
   mf->AddDefinition("CMAKE_GENERATOR_RC", "rc");
@@ -200,7 +200,7 @@ void cmGlobalVisualStudio7Generator::Generate()
       gen[0]->GetMakefile()->
         AddUtilityCommand("INSTALL", false, no_output, no_depends,
                           cmake_command.c_str(),
-                          "-DBUILD_TYPE=$(IntDir)", "-P", "cmake_install.cmake");
+                          "-DBUILD_TYPE=$(OutDir)", "-P", "cmake_install.cmake");
 
       // Make the INSTALL target depend on ALL_BUILD unless the
       // project says to not do so.

+ 27 - 7
Source/cmLocalVisualStudio7Generator.cxx

@@ -421,8 +421,15 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
     programDatabase += libpath;
     programDatabase += "\"";
     }
-  
-  fout << "\t\t\tIntermediateDirectory=\".\\" << configName << "\"\n"
+
+  // The intermediate directory name consists of a directory for the
+  // target and a subdirectory for the configuration name.
+  std::string intermediateDir = this->GetTargetDirectory(target);
+  intermediateDir += "/";
+  intermediateDir += configName;
+  fout << "\t\t\tIntermediateDirectory=\""
+       << this->ConvertToXMLOutputPath(intermediateDir.c_str())
+       << "\"\n"
        << "\t\t\tConfigurationType=\"" << configType << "\"\n"
        << "\t\t\tUseOfMFC=\"" << mfcFlag << "\"\n"
        << "\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n";
@@ -505,7 +512,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
   this->OutputDefineFlags(defineFlags.c_str(), fout);
   fout << "\"\n";
   fout << "\t\t\t\tAssemblerListingLocation=\"" << configName << "\"\n";
-  fout << "\t\t\t\tObjectFile=\"" << configName << "\\\"\n";
+  fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n";
   if(m_Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"))
     {
     fout << "\t\t\t\tSuppressStartupBanner=\"FALSE\"\n";
@@ -822,7 +829,7 @@ void cmLocalVisualStudio7Generator::OutputLibraryDirectories(std::ostream& fout,
     {
     hasone = true;
     std::string temp = m_LibraryOutputPath;
-    temp += "$(INTDIR)";
+    temp += "$(OutDir)";
     
     fout << this->ConvertToXMLOutputPath(temp.c_str()) << "," << 
       this->ConvertToXMLOutputPath(m_LibraryOutputPath.c_str());
@@ -836,7 +843,7 @@ void cmLocalVisualStudio7Generator::OutputLibraryDirectories(std::ostream& fout,
       }
     hasone = true;
     std::string temp = m_ExecutableOutputPath;
-    temp += "$(INTDIR)"; 
+    temp += "$(OutDir)"; 
     fout << this->ConvertToXMLOutputPath(temp.c_str()) << "," << 
       this->ConvertToXMLOutputPath(m_ExecutableOutputPath.c_str());
     }
@@ -857,7 +864,7 @@ void cmLocalVisualStudio7Generator::OutputLibraryDirectories(std::ostream& fout,
         {
         fout << ",";
         }
-      std::string lpathi = lpath + "$(INTDIR)";
+      std::string lpathi = lpath + "$(OutDir)";
       fout << this->ConvertToXMLOutputPath(lpathi.c_str()) << "," << 
         this->ConvertToXMLOutputPath(lpath.c_str());
       hasone = true;
@@ -1204,7 +1211,7 @@ WriteCustomRule(std::ostream& fout,
           libPath = cacheValue;
           }
         libPath += "/";
-        libPath += "$(INTDIR)/";
+        libPath += "$(OutDir)/";
         libPath += dep;
         libPath += ".exe";
         fout << this->ConvertToXMLOutputPath(libPath.c_str())
@@ -1418,3 +1425,16 @@ void cmLocalVisualStudio7Generator::ConfigureFinalPass()
   
 }
 
+//----------------------------------------------------------------------------
+std::string cmLocalVisualStudio7Generator::GetTargetDirectory(cmTarget& target)
+{
+  std::string dir;
+  // Put a prefix on the name if one is given by the CMake code.
+  if(const char* prefix = m_Makefile->GetDefinition("CMAKE_TARGET_DIR_PREFIX"))
+    {
+    dir += prefix;
+    }
+  dir += target.GetName();
+  dir += ".dir";
+  return dir;
+}

+ 1 - 0
Source/cmLocalVisualStudio7Generator.h

@@ -112,6 +112,7 @@ private:
                        const char* extraFlags);
 
   void WriteGroup(const cmSourceGroup *sg, cmTarget target, std::ostream &fout, const char *libName, std::vector<std::string> *configs);
+  virtual std::string GetTargetDirectory(cmTarget&);
 
   std::vector<std::string> m_CreatedProjectNames;
   std::string m_LibraryOutputPath;