From f4af14add40d851f7c8ef92aad2d549dcbbacf1f Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 10 Apr 2017 14:50:53 -0400 Subject: VS: Simplify logic collecting object library files as sources Object library files are already included by `GetExternalObjects` and `GetConfigCommonSourceFiles` so we don't need to call `UseObjectLibraries` to get them. --- Source/cmLocalVisualStudio7Generator.cxx | 47 +++++++++++++----------------- Source/cmVisualStudio10TargetGenerator.cxx | 45 ---------------------------- 2 files changed, 21 insertions(+), 71 deletions(-) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 260a84b..9e83c77 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1306,14 +1306,21 @@ void cmLocalVisualStudio7GeneratorInternals::OutputObjects( // list object library content on the link line instead. cmLocalVisualStudio7Generator* lg = this->LocalGenerator; std::string currentBinDir = lg->GetCurrentBinaryDirectory(); - std::vector objs; - gt->UseObjectLibraries(objs, ""); + + std::vector sources; + if (!gt->GetConfigCommonSourceFiles(sources)) { + return; + } + const char* sep = isep ? isep : ""; - for (std::vector::const_iterator oi = objs.begin(); - oi != objs.end(); ++oi) { - std::string rel = lg->ConvertToRelativePath(currentBinDir, oi->c_str()); - fout << sep << lg->ConvertToXMLOutputPath(rel.c_str()); - sep = " "; + for (std::vector::const_iterator i = sources.begin(); + i != sources.end(); i++) { + if (!(*i)->GetObjectLibrary().empty()) { + std::string const& objFile = (*i)->GetFullPath(); + std::string rel = lg->ConvertToRelativePath(currentBinDir, objFile); + fout << sep << lg->ConvertToXMLOutputPath(rel.c_str()); + sep = " "; + } } } @@ -1370,7 +1377,13 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, for (std::vector::const_iterator i = classes.begin(); i != classes.end(); i++) { if (!(*i)->GetObjectLibrary().empty()) { - continue; + if (this->GetVersion() < cmGlobalVisualStudioGenerator::VS8 || + this->FortranProject) { + // VS < 8 does not support per-config source locations so we + // list object library content on the link line instead. + // See OutputObjects. + continue; + } } // Add the file to the list of sources. std::string source = (*i)->GetFullPath(); @@ -1392,24 +1405,6 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, this->WriteGroup(&sg, target, fout, libName, configs); } - if (this->GetVersion() >= cmGlobalVisualStudioGenerator::VS8 && - !this->FortranProject) { - // VS >= 8 support per-config source locations so we - // list object library content as external objects. - std::vector objs; - target->UseObjectLibraries(objs, ""); - if (!objs.empty()) { - // TODO: Separate sub-filter for each object library used? - fout << "\t\t\n"; - for (std::vector::const_iterator oi = objs.begin(); - oi != objs.end(); ++oi) { - std::string o = this->ConvertToXMLOutputPathSingle(oi->c_str()); - fout << "\t\t\t\n"; - } - fout << "\t\t\n"; - } - } - fout << "\t\n"; // Write the VCProj file's footer. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index a9ccc68..419989a 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1337,23 +1337,6 @@ void cmVisualStudio10TargetGenerator::WriteGroups() this->WriteString("\n", 1); } - // Add object library contents as external objects. - std::vector objs; - this->GeneratorTarget->UseObjectLibraries(objs, ""); - if (!objs.empty()) { - this->WriteString("\n", 1); - for (std::vector::const_iterator oi = objs.begin(); - oi != objs.end(); ++oi) { - std::string obj = *oi; - this->WriteString("ConvertToWindowsSlash(obj); - (*this->BuildFileStream) << cmVS10EscapeXML(obj) << "\">\n"; - this->WriteString("Object Libraries\n", 3); - this->WriteString("\n", 2); - } - this->WriteString("\n", 1); - } - this->WriteString("\n", 1); for (std::set::iterator g = groupsUsed.begin(); g != groupsUsed.end(); ++g) { @@ -1371,15 +1354,6 @@ void cmVisualStudio10TargetGenerator::WriteGroups() this->WriteString("\n", 2); } } - if (!objs.empty()) { - this->WriteString("\n", 2); - std::string guidName = "SG_Filter_Object Libraries"; - this->WriteString("", 3); - std::string guid = this->GlobalGenerator->GetGUID(guidName.c_str()); - (*this->BuildFileStream) << "{" << guid << "}" - << "\n"; - this->WriteString("\n", 2); - } if (!resxObjs.empty() || !this->AddedFiles.empty()) { this->WriteString("\n", 2); @@ -1824,14 +1798,6 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() std::vector externalObjects; this->GeneratorTarget->GetExternalObjects(externalObjects, ""); - for (std::vector::iterator si = externalObjects.begin(); - si != externalObjects.end();) { - if (!(*si)->GetObjectLibrary().empty()) { - si = externalObjects.erase(si); - } else { - ++si; - } - } if (this->LocalGenerator->GetVersion() > cmGlobalVisualStudioGenerator::VS10) { // For VS >= 11 we use LinkObjects to avoid linking custom command @@ -1857,17 +1823,6 @@ void cmVisualStudio10TargetGenerator::WriteAllSources() this->WriteExtraSource(*si); } - // Add object library contents as external objects. - std::vector objs; - this->GeneratorTarget->UseObjectLibraries(objs, ""); - for (std::vector::const_iterator oi = objs.begin(); - oi != objs.end(); ++oi) { - std::string obj = *oi; - this->WriteString("ConvertToWindowsSlash(obj); - (*this->BuildFileStream) << cmVS10EscapeXML(obj) << "\" />\n"; - } - std::vector defSources; this->GeneratorTarget->GetModuleDefinitionSources(defSources, ""); this->WriteSources("None", defSources); -- cgit v0.12