Sfoglia il codice sorgente

ENH: only 5 failing tests for VS 10

Bill Hoffman 16 anni fa
parent
commit
5c4208f50e

+ 8 - 0
Modules/CMakeVS10FindMake.cmake

@@ -5,6 +5,13 @@ IF(NOT CMAKE_CROSSCOMPILING)
   SET( _CMAKE_MAKE_PROGRAM_NAMES ${_CMAKE_MAKE_PROGRAM_NAMES} VCExpress)
 ENDIF(NOT CMAKE_CROSSCOMPILING)
 
+FIND_PROGRAM(CMAKE_MAKE_PROGRAM
+  NAMES MSBuild
+  HINTS 
+  "$ENV{SYSTEMROOT}/Microsoft.NET/Framework/v4.0.20506/"
+  c:/WINDOWS/Microsoft.NET/Framework/v4.0.20506/
+  )
+
 FIND_PROGRAM(CMAKE_MAKE_PROGRAM
   NAMES ${_CMAKE_MAKE_PROGRAM_NAMES}
   HINTS
@@ -25,6 +32,7 @@ FIND_PROGRAM(CMAKE_MAKE_PROGRAM
   "$ENV{ProgramFiles}/Microsoft Visual Studio .NET/Common7/IDE"
   
   )
+
 MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM)
 SET(MSVC10 1)
 SET(MSVC_VERSION 1600)

+ 4 - 1
Source/cmCTest.cxx

@@ -2767,7 +2767,10 @@ double cmCTest::GetRemainingTimeAllowed()
 void cmCTest::OutputTestErrors(std::vector<char> const &process_output)
 {
   std::string test_outputs("\n*** Test Failed:\n");
-  test_outputs.append(&*process_output.begin(), process_output.size());
+  if(process_output.size())
+    {
+    test_outputs.append(&*process_output.begin(), process_output.size());
+    }
   cmCTestLog(this, HANDLER_OUTPUT, test_outputs << std::endl << std::flush);
 }
 

+ 61 - 0
Source/cmGlobalVisualStudio10Generator.cxx

@@ -96,3 +96,64 @@ std::string cmGlobalVisualStudio10Generator::GetUserMacrosRegKeyBase()
 {
   return "Software\\Microsoft\\VisualStudio\\10.0\\vsmacros";
 }
+
+
+std::string cmGlobalVisualStudio10Generator
+::GenerateBuildCommand(const char* makeProgram,
+                       const char *projectName, 
+                       const char* additionalOptions, const char *targetName,
+                       const char* config, bool ignoreErrors, bool)
+{
+  // Ingoring errors is not implemented in visual studio 6
+  (void) ignoreErrors;
+
+  
+  // now build the test
+  std::string makeCommand 
+    = cmSystemTools::ConvertToOutputPath(makeProgram);
+  std::string lowerCaseCommand = makeCommand;
+  cmSystemTools::LowerCase(lowerCaseCommand);
+
+  // if there are spaces in the makeCommand, assume a full path
+  // and convert it to a path with no spaces in it as the
+  // RunSingleCommand does not like spaces
+  if(makeCommand.find(' ') != std::string::npos)
+    {
+    cmSystemTools::GetShortPath(makeCommand.c_str(), makeCommand);
+    }
+  // msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD
+  if(!targetName || strlen(targetName) == 0)
+    {
+    targetName = "ALL_BUILD";
+    }    
+  bool clean = false;
+  if ( targetName && strcmp(targetName, "clean") == 0 )
+    {
+    clean = true;
+    makeCommand += " ";
+    makeCommand += projectName;
+    makeCommand += ".sln ";
+    makeCommand += "/t:Clean ";
+    }
+  else
+    {
+    makeCommand += " ";
+    makeCommand += targetName;
+    makeCommand += ".vcxproj ";
+    }
+  makeCommand += "/p:Configuration=";
+  if(config && strlen(config))
+    {
+    makeCommand += config;
+    }
+  else
+    {
+    makeCommand += "Debug";
+    }
+  if ( additionalOptions )
+    {
+    makeCommand += " ";
+    makeCommand += additionalOptions;
+    }
+  return makeCommand;
+}

+ 6 - 0
Source/cmGlobalVisualStudio10Generator.h

@@ -33,6 +33,12 @@ public:
   static cmGlobalGenerator* New() { 
     return new cmGlobalVisualStudio10Generator; }
   
+  virtual std::string 
+  GenerateBuildCommand(const char* makeProgram,
+                       const char *projectName, 
+                       const char* additionalOptions, const char *targetName,
+                       const char* config, bool ignoreErrors, bool);
+  
   ///! Get the name for the generator.
   virtual const char* GetName() const {
     return cmGlobalVisualStudio10Generator::GetActualName();}

+ 1 - 3
Source/cmGlobalVisualStudio71Generator.cxx

@@ -116,8 +116,7 @@ void cmGlobalVisualStudio71Generator
                       originalTargets,
                       root, generators);
   OrderedTargetDependSet orderedProjectTargets(projectTargets);
-  this->WriteTargetsToSolution(fout, root, orderedProjectTargets,
-                               originalTargets);
+  this->WriteTargetsToSolution(fout, root, orderedProjectTargets);
   // Write out the configurations information for the solution
   fout << "Global\n";
   // Write out the configurations for the solution
@@ -257,7 +256,6 @@ void cmGlobalVisualStudio71Generator
                        const char* location,
                        const std::vector<std::string>& depends)
 { 
-  std::cout << "WriteExternalProject vs71\n";
   fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" 
        << name << "\", \""
        << this->ConvertToSolutionPath(location) << "\", \"{"

+ 2 - 33
Source/cmGlobalVisualStudio7Generator.cxx

@@ -194,7 +194,6 @@ void cmGlobalVisualStudio7Generator::Generate()
 
   // Now write out the DSW
   this->OutputSLNFile();
-
   // If any solution or project files changed during the generation,
   // tell Visual Studio to reload them...
   if(!cmSystemTools::GetErrorOccuredFlag())
@@ -240,24 +239,6 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile()
 }
 
 
-void cmGlobalVisualStudio7Generator::AddAllBuildDepends(
-  cmLocalGenerator* root,
-  cmTarget* target,
-  cmGlobalGenerator::TargetDependSet& originalTargets)
-{
-  // if this is the special ALL_BUILD utility, then
-  // make it depend on every other non UTILITY project.
-  for(cmGlobalGenerator::TargetDependSet::iterator ot =
-        originalTargets.begin(); ot != originalTargets.end(); ++ot)
-    {
-    cmTarget* t = const_cast<cmTarget*>(*ot);
-    if(!this->IsExcluded(root, *t))
-      {
-      target->AddUtility(t->GetName());
-      }
-    }
-}
-
 void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
   std::ostream& fout, 
   cmLocalGenerator* root,
@@ -296,9 +277,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
 void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
     std::ostream& fout,
     cmLocalGenerator* root,
-    OrderedTargetDependSet const& projectTargets,
-    cmGlobalGenerator::TargetDependSet& originalTargets
-    )
+    OrderedTargetDependSet const& projectTargets)
 {
   std::string rootdir = root->GetMakefile()->GetStartOutputDirectory();
   rootdir += "/";
@@ -306,14 +285,6 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
         projectTargets.begin(); tt != projectTargets.end(); ++tt)
     {
     cmTarget* target = *tt;
-    cmMakefile* mf = target->GetMakefile();
-    // look for the all_build rule and add depends to all
-    // of the original targets (none that were "pulled" into this project)
-    if(mf == root->GetMakefile() &&
-       strcmp(target->GetName(), "ALL_BUILD") == 0)
-      {
-      this->AddAllBuildDepends(root, target, originalTargets);
-      }
     // handle external vc project files
     if (strncmp(target->GetName(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
       { 
@@ -427,8 +398,7 @@ void cmGlobalVisualStudio7Generator
                       originalTargets,
                       root, generators);
   OrderedTargetDependSet orderedProjectTargets(projectTargets);
-  this->WriteTargetsToSolution(fout, root, orderedProjectTargets,
-                               originalTargets);
+  this->WriteTargetsToSolution(fout, root, orderedProjectTargets);
   // Write out the configurations information for the solution
   fout << "Global\n"
        << "\tGlobalSection(SolutionConfiguration) = preSolution\n";
@@ -594,7 +564,6 @@ void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout,
                                const char* location,
                                const std::vector<std::string>&)
 { 
-  std::cout << "WriteExternalProject vs7\n";
   std::string d = cmSystemTools::ConvertToOutputPath(location);
   fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" 
        << name << "\", \""

+ 1 - 6
Source/cmGlobalVisualStudio7Generator.h

@@ -128,8 +128,7 @@ protected:
   virtual void WriteTargetsToSolution(
     std::ostream& fout,
     cmLocalGenerator* root,
-    OrderedTargetDependSet const& projectTargets,
-    cmGlobalGenerator::TargetDependSet& originalTargets);
+    OrderedTargetDependSet const& projectTargets);
   virtual void WriteTargetDepends(
     std::ostream& fout,
     OrderedTargetDependSet const& projectTargets);
@@ -138,10 +137,6 @@ protected:
     cmLocalGenerator* root,
     OrderedTargetDependSet const& projectTargets);
   
-  void AddAllBuildDepends(cmLocalGenerator* root,
-                          cmTarget* target,
-                          cmGlobalGenerator::TargetDependSet& targets);
-                                       
   void GenerateConfigurations(cmMakefile* mf);
 
   virtual void WriteExternalProject(std::ostream& fout, 

+ 17 - 1
Source/cmGlobalVisualStudioGenerator.cxx

@@ -48,10 +48,26 @@ void cmGlobalVisualStudioGenerator::Generate()
       {
       // Use no actual command lines so that the target itself is not
       // considered always out of date.
-      gen[0]->GetMakefile()->
+      cmTarget* allBuild = 
+        gen[0]->GetMakefile()->
         AddUtilityCommand("ALL_BUILD", true, no_working_dir,
                           no_depends, no_commands, false,
                           "Build all projects");
+      // Now make all targets depend on the ALL_BUILD target
+      cmTargets targets;
+      for(std::vector<cmLocalGenerator*>::iterator i = gen.begin();
+          i != gen.end(); ++i)
+        {
+        cmTargets& targets = (*i)->GetMakefile()->GetTargets();
+        for(cmTargets::iterator t = targets.begin();
+            t != targets.end(); ++t)
+          {
+          if(!this->IsExcluded(gen[0], t->second))
+            {
+            allBuild->AddUtility(t->second.GetName());
+            }
+          }
+        }
       }
     }
 

+ 1 - 1
Source/cmLocalVisualStudio10Generator.cxx

@@ -23,7 +23,7 @@
 //----------------------------------------------------------------------------
 cmLocalVisualStudio10Generator::cmLocalVisualStudio10Generator()
 {
-
+  this->NeedXMLEscape = true;
 }
 
 cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator()

+ 33 - 17
Source/cmLocalVisualStudio7Generator.cxx

@@ -1405,6 +1405,38 @@ cmLocalVisualStudio7GeneratorFCInfo
     }
 }
 
+
+void cmLocalVisualStudio7Generator
+::ComputeMaxDirectoryLength(std::string& maxdir,
+  cmTarget& target)
+{  
+  std::vector<std::string> *configs =
+    static_cast<cmGlobalVisualStudio7Generator *>
+    (this->GlobalGenerator)->GetConfigurations();
+  // Compute the maximum length configuration name.
+  std::string config_max;
+  for(std::vector<std::string>::iterator i = configs->begin();
+      i != configs->end(); ++i)
+    {
+    if(i->size() > config_max.size())
+      {
+      config_max = *i;
+      }
+    }
+
+  // Compute the maximum length full path to the intermediate
+  // files directory for any configuration.  This is used to construct
+  // object file names that do not produce paths that are too long.
+  std::string dir_max;
+  dir_max += this->Makefile->GetCurrentOutputDirectory();
+  dir_max += "/";
+  dir_max += this->GetTargetDirectory(target);
+  dir_max += "/";
+  dir_max += config_max;
+  dir_max += "/";
+  maxdir = dir_max;
+}
+
 void cmLocalVisualStudio7Generator
 ::WriteGroup(const cmSourceGroup *sg, cmTarget& target,
              std::ostream &fout, const char *libName, 
@@ -1425,27 +1457,11 @@ void cmLocalVisualStudio7Generator
     this->WriteVCProjBeginGroup(fout, name.c_str(), "");
     }
 
-  // Compute the maximum length configuration name.
-  std::string config_max;
-  for(std::vector<std::string>::iterator i = configs->begin();
-      i != configs->end(); ++i)
-    {
-    if(i->size() > config_max.size())
-      {
-      config_max = *i;
-      }
-    }
-
   // Compute the maximum length full path to the intermediate
   // files directory for any configuration.  This is used to construct
   // object file names that do not produce paths that are too long.
   std::string dir_max;
-  dir_max += this->Makefile->GetCurrentOutputDirectory();
-  dir_max += "/";
-  dir_max += this->GetTargetDirectory(target);
-  dir_max += "/";
-  dir_max += config_max;
-  dir_max += "/";
+  this->ComputeMaxDirectoryLength(dir_max, target);
 
   // Loop through each source in the source group.
   std::string objectName;

+ 5 - 0
Source/cmLocalVisualStudio7Generator.h

@@ -72,10 +72,15 @@ public:
   virtual std::string GetTargetDirectory(cmTarget const&) const;
   cmSourceFile* CreateVCProjBuildRule();
   void WriteStampFiles();
+  void ComputeMaxDirectoryLength(std::string& maxdir,
+                                 cmTarget& target);
 
 private:
   typedef cmLocalVisualStudio7GeneratorOptions Options;
   typedef cmLocalVisualStudio7GeneratorFCInfo FCInfo;
+  // Compute the maximum length full path to the intermediate
+  // files directory for any configuration.  This is used to construct
+  // object file names that do not produce paths that are too long.
   void ReadAndStoreExternalGUID(const char* name,
                                 const char* path);
   std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags,

+ 20 - 1
Source/cmLocalVisualStudioGenerator.cxx

@@ -26,6 +26,7 @@ cmLocalVisualStudioGenerator::cmLocalVisualStudioGenerator()
 {
   this->WindowsShell = true;
   this->WindowsVSIDE = true;
+  this->NeedXMLEscape = false;
 }
 
 //----------------------------------------------------------------------------
@@ -231,8 +232,26 @@ cmLocalVisualStudioGenerator
         }
       else
         {
-        script += this->EscapeForShell(commandLine[j].c_str(),
+        if(this->NeedXMLEscape)
+          {
+          std::string arg = commandLine[j];
+          cmSystemTools::ReplaceString(arg, "&", "&amp;");
+          cmSystemTools::ReplaceString(arg, "<", "&lt;");
+          cmSystemTools::ReplaceString(arg, ">", "&gt;");
+          if(arg.find(" ") != arg.npos)
+            {
+            std::string q("\"");
+            arg = q + arg +q;
+            }
+          script += arg;
+          //script += this->EscapeForShell(arg.c_str(),
+          //escapeAllowMakeVars);
+          }
+        else
+          {
+          script += this->EscapeForShell(commandLine[j].c_str(),
                                        escapeAllowMakeVars);
+          }
         }
       }
     }

+ 2 - 1
Source/cmLocalVisualStudioGenerator.h

@@ -56,8 +56,9 @@ protected:
                         std::map<cmStdString, int>& count);
   void InsertNeedObjectNames(const std::vector<cmSourceGroup>& groups,
                              std::map<cmStdString, int>& count);
-
+  bool NeedXMLEscape;
   std::set<const cmSourceFile*> NeedObjectName;
+  friend class cmVisualStudio10TargetGenerator;
 };
 
 #endif

+ 1 - 0
Source/cmTarget.cxx

@@ -1992,6 +1992,7 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config)
     msg += " which has type ";
     msg += cmTarget::TargetTypeNames[this->GetType()];
     this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg);
+    abort();
     return 0;
     }
 

+ 173 - 45
Source/cmVisualStudio10TargetGenerator.cxx

@@ -43,10 +43,16 @@ cmVisualStudio10TargetGenerator(cmTarget* target,
     (cmLocalVisualStudio7Generator*)
     this->Makefile->GetLocalGenerator();
   this->Platform = "|Win32";
+  this->ComputeObjectNames();
 }
 
 cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator()
 {
+  if (this->BuildFileStream->Close())
+    {
+    this->GlobalGenerator
+      ->FileReplacedDuringGenerate(this->PathToVcxproj);
+    }
   delete this->BuildFileStream;
 }
 
@@ -104,6 +110,7 @@ void cmVisualStudio10TargetGenerator::Generate()
   path += ".vcxproj";
   this->BuildFileStream =
     new cmGeneratedFileStream(path.c_str());
+  this->PathToVcxproj = path;
   this->BuildFileStream->SetCopyIfDifferent(true);
   
   // Write the encoding header into the file
@@ -382,45 +389,39 @@ void cmVisualStudio10TargetGenerator::WriteObjSources()
 
 void cmVisualStudio10TargetGenerator::WriteCLSources()
 {
-  this->WriteString("<ItemGroup>\n", 1);
   if(this->Target->GetType() > cmTarget::MODULE_LIBRARY)
     {
-    this->WriteString("<None Include=\"", 2);
-    (*this->BuildFileStream ) << this->Target->GetDirectory()
-                              << "\\" << this->Target->GetName() 
-                              << "\" />\n";
+    return;
     }
-  else
+  this->WriteString("<ItemGroup>\n", 1);
+  std::vector<cmSourceFile*>const& sources = this->Target->GetSourceFiles();
+  for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
+      source != sources.end(); ++source)
     {
-    std::vector<cmSourceFile*>const& sources = this->Target->GetSourceFiles();
-    for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
-        source != sources.end(); ++source)
+    // if it is not a custom command then add it as a c/c++ file,
+    // TODO: need to check for idl or rc
+    if(!(*source)->GetCustomCommand()
+       && !(*source)->GetPropertyAsBool("HEADER_FILE_ONLY")
+       && !this->GlobalGenerator->IgnoreFile
+       ((*source)->GetExtension().c_str()))
       {
-      // if it is not a custom command then add it as a c/c++ file,
-      // TODO: need to check for idl or rc
-      if(!(*source)->GetCustomCommand()
-         && !(*source)->GetPropertyAsBool("HEADER_FILE_ONLY")
-         && !this->GlobalGenerator->IgnoreFile
-         ((*source)->GetExtension().c_str()))
+      const char* lang = (*source)->GetLanguage();
+      if(lang && (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") ==0))
         {
-        const char* lang = (*source)->GetLanguage();
-        if(lang && (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") ==0))
+        std::string sourceFile = (*source)->GetFullPath();
+        // output the source file
+        this->WriteString("<ClCompile Include=\"", 2);
+        (*this->BuildFileStream ) << sourceFile << "\"";
+        // ouput any flags specific to this source file
+        if(this->OutputSourceSpecificFlags(*source))
           {
-          std::string sourceFile = (*source)->GetFullPath();
-          // output the source file
-          this->WriteString("<ClCompile Include=\"", 2);
-          (*this->BuildFileStream ) << sourceFile << "\"";
-          // ouput any flags specific to this source file
-          if(this->OutputSourceSpecificFlags(*source))
-            {
-            // if the source file has specific flags the tag
-            // is ended on a new line
-            this->WriteString("</ClCompile>\n", 2);
-            }
-          else
-            {
-            (*this->BuildFileStream ) << " />\n";
-            }
+          // if the source file has specific flags the tag
+          // is ended on a new line
+          this->WriteString("</ClCompile>\n", 2);
+          }
+        else
+          {
+          (*this->BuildFileStream ) << " />\n";
           }
         }
       }
@@ -428,10 +429,48 @@ void cmVisualStudio10TargetGenerator::WriteCLSources()
   this->WriteString("</ItemGroup>\n", 1);
 }
 
+void cmVisualStudio10TargetGenerator::ComputeObjectNames()
+{
+  // We may be modifying the source groups temporarily, so make a copy.
+  std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
+
+  // get the classes from the source lists then add them to the groups
+  std::vector<cmSourceFile*>const & classes = this->Target->GetSourceFiles();
+  for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
+      i != classes.end(); i++)
+    {
+    // Add the file to the list of sources.
+    std::string source = (*i)->GetFullPath();
+    if(cmSystemTools::UpperCase((*i)->GetExtension()) == "DEF")
+      {
+      this->ModuleDefinitionFile = (*i)->GetFullPath();
+      }
+    cmSourceGroup& sourceGroup =
+      this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
+    sourceGroup.AssignSource(*i);
+    }
+
+  // Compute which sources need unique object computation.
+  this->LocalGenerator->ComputeObjectNameRequirements(sourceGroups);
+}
+
 bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
   cmSourceFile* source)
-{
+{ 
   cmSourceFile& sf = *source;
+  cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
+
+  // Compute the maximum length full path to the intermediate
+  // files directory for any configuration.  This is used to construct
+  // object file names that do not produce paths that are too long.
+  std::string dir_max;
+  lg->ComputeMaxDirectoryLength(dir_max, *this->Target);
+
+  std::string objectName;
+  if(lg->NeedObjectName.find(&sf) != lg->NeedObjectName.end())
+    {
+    objectName = lg->GetObjectFileNameWithoutTarget(sf, dir_max);
+    }
   std::string flags;
   std::string defines;
   if(const char* cflags = sf.GetProperty("COMPILE_FLAGS"))
@@ -470,13 +509,22 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
       flags += " /TC ";
       }
     }
+  bool hasFlags = false;
   // for the first time we need a new line if there is something
   // produced here.
   const char* firstString = ">\n";
+  if(objectName.size())
+    {
+    (*this->BuildFileStream ) << firstString;
+    firstString = ""; 
+    hasFlags = true;
+    this->WriteString("<ObjectFileName>", 3);
+    (*this->BuildFileStream )
+      << "$(Configuration)/" << objectName << "</ObjectFileName>\n";
+    }
   std::vector<std::string> *configs =
     static_cast<cmGlobalVisualStudio7Generator *>
     (this->GlobalGenerator)->GetConfigurations();
-  bool hasFlags = false;
   for( std::vector<std::string>::iterator config = configs->begin();
        config != configs->end(); ++config)
     { 
@@ -519,6 +567,10 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
 
 void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
 {
+  if(this->Target->GetType() > cmTarget::MODULE_LIBRARY)
+    {
+    return;
+    }
   this->WriteString("<PropertyGroup>\n", 2);
   this->WriteString("<_ProjectFileVersion>10.0.20506.1"
                     "</_ProjectFileVersion>\n", 3);
@@ -672,6 +724,12 @@ WriteClOptions(std::string const& configName,
       flags += " /TP ";
       }
     }
+  // Add the target-specific flags.
+  if(const char* targetFlags = this->Target->GetProperty("COMPILE_FLAGS"))
+    {
+    flags += " ";
+    flags += targetFlags;
+    }
   std::string configUpper = cmSystemTools::UpperCase(configName);
   std::string defPropName = "COMPILE_DEFINITIONS_";
   defPropName += configUpper;
@@ -877,8 +935,13 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const&
   for(std::vector<std::string>::const_iterator d = ldirs.begin();
       d != ldirs.end(); ++d)
     {
+    // first just full path
+    linkDirs += sep;
+    linkDirs += *d;
     linkDirs += sep;
+    // next path with configuration type Debug, Release, etc
     linkDirs += *d;
+    linkDirs += "/$(Configuration)";
     sep = ";";
     }
   linkDirs += "%(AdditionalLibraryDirectories)";
@@ -910,9 +973,10 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const&
                                   targetNameImport, targetNamePDB, 
                                   config.c_str());
     }
-  std::string dir = this->Target->GetDirectory(config.c_str());
+  std::string imLib = this->Target->GetDirectory(config.c_str(), true);
+  std::string dir = this->Target->GetDirectory(config.c_str(), true);
   dir += "/";
-  std::string imLib = dir;
+  imLib += "/";
   imLib += targetNameImport;
   std::string pdb = dir;
   pdb += targetNamePDB;
@@ -997,6 +1061,8 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
       }
     //    output midl flags       <Midl></Midl>
     this->WriteMidlOptions(*i, includes);
+    // write events
+    this->WriteEvents(*i);
     //    output link flags       <Link></Link> 
     this->WriteLinkOptions(*i);
     //    output lib flags       <Lib></Lib> 
@@ -1005,16 +1071,78 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
     }
 }
 
+void 
+cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName)
+{
+  this->WriteEvent("PreLinkEvent",
+                   this->Target->GetPreLinkCommands(), configName);
+  this->WriteEvent("PreBuildEvent",
+                   this->Target->GetPreBuildCommands(), configName);
+  this->WriteEvent("PostBuildEvent",
+                   this->Target->GetPostBuildCommands(), configName);
+}
+
+void cmVisualStudio10TargetGenerator::WriteEvent(
+  const char* name,
+  std::vector<cmCustomCommand> & commands,
+  std::string const& configName)
+{
+  if(commands.size() == 0)
+    {
+    return;
+    }
+  this->WriteString("<", 2);
+  (*this->BuildFileStream ) << name << ">\n";
+  cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
+  std::string script;
+  const char* pre = "";
+  std::string comment;
+  for(std::vector<cmCustomCommand>::iterator i = commands.begin();
+      i != commands.end(); ++i)
+    {  
+    cmCustomCommand& command = *i;
+    comment += pre;
+    comment += lg->ConstructComment(command);
+    script += pre;
+    pre = "\n";
+    script += 
+      lg->ConstructScript(command.GetCommandLines(),
+                          command.GetWorkingDirectory(),
+                          configName.c_str(),
+                          command.GetEscapeOldStyle(),
+                          command.GetEscapeAllowMakeVars());
+    }
+  this->WriteString("<Message>",3);
+  (*this->BuildFileStream ) << comment << "</Message>\n";
+  this->WriteString("<Command>", 3);
+  (*this->BuildFileStream ) << script;
+  (*this->BuildFileStream ) << "</Command>" << "\n";
+  this->WriteString("</", 2);
+  (*this->BuildFileStream ) << name << ">\n";
+}
+
 
 void cmVisualStudio10TargetGenerator::WriteProjectReferences()
 {
-  // TODO
-  // This should have dependent targets listed like this:
-  /*
- <ItemGroup>
-    <ProjectReference Include="ZERO_CHECK.vcxproj">
-      <Project>{2f1e4f3c-0a51-46c3-aaf9-e486599604f2}</Project>
-    </ProjectReference>
-  </ItemGroup>
-  */
+  cmGlobalGenerator::TargetDependSet& depends
+    = this->GlobalGenerator->GetTargetDirectDepends(*this->Target);
+  this->WriteString("<ItemGroup>\n", 1);
+  for( cmGlobalGenerator::TargetDependSet::const_iterator i = depends.begin();
+       i != depends.end(); ++i)
+    {
+    cmTarget* dt = *i;
+    this->WriteString("<ProjectReference Include=\"", 2);
+    cmMakefile* mf = dt->GetMakefile();
+    std::string path =  mf->GetStartOutputDirectory();
+    path += "/";
+    path += dt->GetName();
+    path += ".vcxproj";
+    (*this->BuildFileStream) << path << "\">\n";
+    this->WriteString("<Project>", 3);
+    (*this->BuildFileStream) 
+      << this->GlobalGenerator->GetGUID(dt->GetName())
+      << "</Project>\n";
+    this->WriteString("</ProjectReference>\n", 2);
+    }
+  this->WriteString("</ItemGroup>\n", 1);
 }

+ 6 - 0
Source/cmVisualStudio10TargetGenerator.h

@@ -70,7 +70,13 @@ private:
   bool OutputSourceSpecificFlags(cmSourceFile* source);
   void AddLibraries(cmComputeLinkInformation& cli, std::string& libstring);
   void WriteLibOptions(std::string const& config);
+  void WriteEvents(std::string const& configName);
+  void WriteEvent(const char* name, std::vector<cmCustomCommand> & commands,
+                  std::string const& configName);
+  void ComputeObjectNames();
 private:
+  std::string ModuleDefinitionFile;
+  std::string PathToVcxproj;
   cmTarget* Target;
   cmMakefile* Makefile;
   std::string Platform;

+ 2 - 2
Tests/Complex/Library/CMakeLists.txt

@@ -52,9 +52,9 @@ DEFINE_PROPERTY(
   FULL_DOCS "A simple etst proerty that means nothign and is used for nothing"
   )
 SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES FOO BAR)
-IF(NOT BEOS)  # No libm on BeOS.
+IF(NOT BEOS AND NOT WIN32)  # No libm on BeOS.
   SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES LINK_FLAGS "-lm")
-ENDIF(NOT BEOS)
+ENDIF(NOT BEOS AND NOT WIN32)
 GET_TARGET_PROPERTY(FOO_BAR_VAR CMakeTestCLibraryShared FOO)
 IF(${FOO_BAR_VAR} MATCHES "BAR")
 ELSE(${FOO_BAR_VAR} MATCHES "BAR")

+ 2 - 2
Tests/ComplexOneConfig/Library/CMakeLists.txt

@@ -52,9 +52,9 @@ DEFINE_PROPERTY(
   FULL_DOCS "A simple etst proerty that means nothign and is used for nothing"
   )
 SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES FOO BAR)
-IF(NOT BEOS)  # No libm on BeOS.
+IF(NOT BEOS AND NOT WIN32)  # No libm on BeOS.
   SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES LINK_FLAGS "-lm")
-ENDIF(NOT BEOS)
+ENDIF(NOT BEOS AND NOT WIN32)
 GET_TARGET_PROPERTY(FOO_BAR_VAR CMakeTestCLibraryShared FOO)
 IF(${FOO_BAR_VAR} MATCHES "BAR")
 ELSE(${FOO_BAR_VAR} MATCHES "BAR")

+ 2 - 2
Tests/ComplexRelativePaths/Library/CMakeLists.txt

@@ -52,9 +52,9 @@ DEFINE_PROPERTY(
   FULL_DOCS "A simple etst proerty that means nothign and is used for nothing"
   )
 SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES FOO BAR)
-IF(NOT BEOS)  # No libm on BeOS.
+IF(NOT BEOS AND NOT WIN32)  # No libm on BeOS.
   SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES LINK_FLAGS "-lm")
-ENDIF(NOT BEOS)
+ENDIF(NOT BEOS AND NOT WIN32)
 GET_TARGET_PROPERTY(FOO_BAR_VAR CMakeTestCLibraryShared FOO)
 IF(${FOO_BAR_VAR} MATCHES "BAR")
 ELSE(${FOO_BAR_VAR} MATCHES "BAR")