From 5c4208f50e30a601b0cddd238232ca3f0db833af Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Fri, 10 Jul 2009 09:12:39 -0400 Subject: [PATCH] ENH: only 5 failing tests for VS 10 --- Modules/CMakeVS10FindMake.cmake | 8 + Source/cmCTest.cxx | 5 +- Source/cmGlobalVisualStudio10Generator.cxx | 61 +++++ Source/cmGlobalVisualStudio10Generator.h | 6 + Source/cmGlobalVisualStudio71Generator.cxx | 4 +- Source/cmGlobalVisualStudio7Generator.cxx | 35 +-- Source/cmGlobalVisualStudio7Generator.h | 7 +- Source/cmGlobalVisualStudioGenerator.cxx | 18 +- Source/cmLocalVisualStudio10Generator.cxx | 2 +- Source/cmLocalVisualStudio7Generator.cxx | 54 +++-- Source/cmLocalVisualStudio7Generator.h | 5 + Source/cmLocalVisualStudioGenerator.cxx | 21 +- Source/cmLocalVisualStudioGenerator.h | 3 +- Source/cmTarget.cxx | 1 + Source/cmVisualStudio10TargetGenerator.cxx | 218 ++++++++++++++---- Source/cmVisualStudio10TargetGenerator.h | 6 + Tests/Complex/Library/CMakeLists.txt | 4 +- Tests/ComplexOneConfig/Library/CMakeLists.txt | 4 +- .../Library/CMakeLists.txt | 4 +- 19 files changed, 349 insertions(+), 117 deletions(-) diff --git a/Modules/CMakeVS10FindMake.cmake b/Modules/CMakeVS10FindMake.cmake index 04d5e8116..ce7964170 100644 --- a/Modules/CMakeVS10FindMake.cmake +++ b/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) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 0cd5d5637..85aac755c 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2767,7 +2767,10 @@ double cmCTest::GetRemainingTimeAllowed() void cmCTest::OutputTestErrors(std::vector 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); } diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index a0af05cd1..4127a6c46 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/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; +} diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 27332893e..562b5465e 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/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();} diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 157176d24..7c2752cbf 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/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& depends) { - std::cout << "WriteExternalProject vs71\n"; fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" << name << "\", \"" << this->ConvertToSolutionPath(location) << "\", \"{" diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index e43afc017..1a5a5b80c 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/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(*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::cout << "WriteExternalProject vs7\n"; std::string d = cmSystemTools::ConvertToOutputPath(location); fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" << name << "\", \"" diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index a116fe955..c2930db51 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/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, diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 4e1b8510a..e2046811f 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/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::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()); + } + } + } } } diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx index cdcf7e10b..8106e7eb6 100644 --- a/Source/cmLocalVisualStudio10Generator.cxx +++ b/Source/cmLocalVisualStudio10Generator.cxx @@ -23,7 +23,7 @@ //---------------------------------------------------------------------------- cmLocalVisualStudio10Generator::cmLocalVisualStudio10Generator() { - + this->NeedXMLEscape = true; } cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator() diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 7fb04b108..e0baa1814 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1405,26 +1405,14 @@ cmLocalVisualStudio7GeneratorFCInfo } } + void cmLocalVisualStudio7Generator -::WriteGroup(const cmSourceGroup *sg, cmTarget& target, - std::ostream &fout, const char *libName, - std::vector *configs) -{ - const std::vector &sourceFiles = - sg->GetSourceFiles(); - // If the group is empty, don't write it at all. - if(sourceFiles.empty() && sg->GetGroupChildren().empty()) - { - return; - } - - // If the group has a name, write the header. - std::string name = sg->GetName(); - if(name != "") - { - this->WriteVCProjBeginGroup(fout, name.c_str(), ""); - } - +::ComputeMaxDirectoryLength(std::string& maxdir, + cmTarget& target) +{ + std::vector *configs = + static_cast + (this->GlobalGenerator)->GetConfigurations(); // Compute the maximum length configuration name. std::string config_max; for(std::vector::iterator i = configs->begin(); @@ -1446,6 +1434,34 @@ void cmLocalVisualStudio7Generator 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, + std::vector *configs) +{ + const std::vector &sourceFiles = + sg->GetSourceFiles(); + // If the group is empty, don't write it at all. + if(sourceFiles.empty() && sg->GetGroupChildren().empty()) + { + return; + } + + // If the group has a name, write the header. + std::string name = sg->GetName(); + if(name != "") + { + this->WriteVCProjBeginGroup(fout, name.c_str(), ""); + } + + // 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; + this->ComputeMaxDirectoryLength(dir_max, target); // Loop through each source in the source group. std::string objectName; diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index 70f25e866..2d951ecb9 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/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, diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx index 4706a966b..da214cf65 100644 --- a/Source/cmLocalVisualStudioGenerator.cxx +++ b/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, "&", "&"); + cmSystemTools::ReplaceString(arg, "<", "<"); + cmSystemTools::ReplaceString(arg, ">", ">"); + 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); + } } } } diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h index 0bb630b2b..4b31599bf 100644 --- a/Source/cmLocalVisualStudioGenerator.h +++ b/Source/cmLocalVisualStudioGenerator.h @@ -56,8 +56,9 @@ protected: std::map& count); void InsertNeedObjectNames(const std::vector& groups, std::map& count); - + bool NeedXMLEscape; std::set NeedObjectName; + friend class cmVisualStudio10TargetGenerator; }; #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 6c9197c1a..5f2217d1a 100644 --- a/Source/cmTarget.cxx +++ b/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; } diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 065f454e1..05196fff1 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/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("\n", 1); if(this->Target->GetType() > cmTarget::MODULE_LIBRARY) { - this->WriteString("BuildFileStream ) << this->Target->GetDirectory() - << "\\" << this->Target->GetName() - << "\" />\n"; + return; } - else + this->WriteString("\n", 1); + std::vectorconst& sources = this->Target->GetSourceFiles(); + for(std::vector::const_iterator source = sources.begin(); + source != sources.end(); ++source) { - std::vectorconst& sources = this->Target->GetSourceFiles(); - for(std::vector::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("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("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("\n", 2); - } - else - { - (*this->BuildFileStream ) << " />\n"; - } + // if the source file has specific flags the tag + // is ended on a new line + this->WriteString("\n", 2); + } + else + { + (*this->BuildFileStream ) << " />\n"; } } } @@ -428,10 +429,48 @@ void cmVisualStudio10TargetGenerator::WriteCLSources() this->WriteString("\n", 1); } +void cmVisualStudio10TargetGenerator::ComputeObjectNames() +{ + // We may be modifying the source groups temporarily, so make a copy. + std::vector sourceGroups = this->Makefile->GetSourceGroups(); + + // get the classes from the source lists then add them to the groups + std::vectorconst & classes = this->Target->GetSourceFiles(); + for(std::vector::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("", 3); + (*this->BuildFileStream ) + << "$(Configuration)/" << objectName << "\n"; + } std::vector *configs = static_cast (this->GlobalGenerator)->GetConfigurations(); - bool hasFlags = false; for( std::vector::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("\n", 2); this->WriteString("<_ProjectFileVersion>10.0.20506.1" "\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::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 this->WriteMidlOptions(*i, includes); + // write events + this->WriteEvents(*i); // output link flags this->WriteLinkOptions(*i); // output lib flags @@ -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 & 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::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("",3); + (*this->BuildFileStream ) << comment << "\n"; + this->WriteString("", 3); + (*this->BuildFileStream ) << script; + (*this->BuildFileStream ) << "" << "\n"; + this->WriteString("BuildFileStream ) << name << ">\n"; +} + void cmVisualStudio10TargetGenerator::WriteProjectReferences() { - // TODO - // This should have dependent targets listed like this: - /* - - - {2f1e4f3c-0a51-46c3-aaf9-e486599604f2} - - - */ + cmGlobalGenerator::TargetDependSet& depends + = this->GlobalGenerator->GetTargetDirectDepends(*this->Target); + this->WriteString("\n", 1); + for( cmGlobalGenerator::TargetDependSet::const_iterator i = depends.begin(); + i != depends.end(); ++i) + { + cmTarget* dt = *i; + this->WriteString("GetMakefile(); + std::string path = mf->GetStartOutputDirectory(); + path += "/"; + path += dt->GetName(); + path += ".vcxproj"; + (*this->BuildFileStream) << path << "\">\n"; + this->WriteString("", 3); + (*this->BuildFileStream) + << this->GlobalGenerator->GetGUID(dt->GetName()) + << "\n"; + this->WriteString("\n", 2); + } + this->WriteString("\n", 1); } diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 77f5b9101..7564a86c5 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/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 & commands, + std::string const& configName); + void ComputeObjectNames(); private: + std::string ModuleDefinitionFile; + std::string PathToVcxproj; cmTarget* Target; cmMakefile* Makefile; std::string Platform; diff --git a/Tests/Complex/Library/CMakeLists.txt b/Tests/Complex/Library/CMakeLists.txt index d21e959eb..281e48a55 100644 --- a/Tests/Complex/Library/CMakeLists.txt +++ b/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") diff --git a/Tests/ComplexOneConfig/Library/CMakeLists.txt b/Tests/ComplexOneConfig/Library/CMakeLists.txt index d21e959eb..281e48a55 100644 --- a/Tests/ComplexOneConfig/Library/CMakeLists.txt +++ b/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") diff --git a/Tests/ComplexRelativePaths/Library/CMakeLists.txt b/Tests/ComplexRelativePaths/Library/CMakeLists.txt index d21e959eb..281e48a55 100644 --- a/Tests/ComplexRelativePaths/Library/CMakeLists.txt +++ b/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")