diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 0abce6bf10..a5ed4c930b 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -109,43 +109,6 @@ void cmGlobalVisualStudio71Generator::WriteProject( fout << "\tEndProjectSection\n"; fout << "EndProject\n"; - - auto ui = this->UtilityDepends.find(t); - if (ui != this->UtilityDepends.end()) { - char const* uname = ui->second.c_str(); - /* clang-format off */ - fout << R"(Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = ")" - << uname << "\", \"" - << this->ConvertToSolutionPath(dir) << (dir[0]? "\\":"") - << uname << ".vcproj" << "\", \"{" - << this->GetGUID(uname) << "}\"\n" - << "\tProjectSection(ProjectDependencies) = postProject\n" - "\t\t{" << guid << "} = {" << guid << "}\n" - "\tEndProjectSection\n" - "EndProject\n"; - /* clang-format on */ - } -} - -// Write a dsp file into the SLN file, -// Note, that dependencies from executables to -// the libraries it uses are also done here -void cmGlobalVisualStudio71Generator::WriteProjectDepends( - std::ostream& fout, std::string const&, std::string const&, - cmGeneratorTarget const* target) const -{ - auto i = this->VSTargetDepends.find(target); - assert(i != this->VSTargetDepends.end()); - VSDependSet const& depends = i->second; - for (std::string const& name : depends) { - std::string guid = this->GetGUID(name); - if (guid.empty()) { - std::string m = cmStrCat("Target: ", target->GetName(), - " depends on unknown target: ", name); - cmSystemTools::Error(m); - } - fout << "\t\t{" << guid << "} = {" << guid << "}\n"; - } } // Write a dsp file into the SLN file, Note, that dependencies from diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h index 0d0e83881d..35d4378929 100644 --- a/Source/cmGlobalVisualStudio71Generator.h +++ b/Source/cmGlobalVisualStudio71Generator.h @@ -36,9 +36,6 @@ protected: void WriteProject(std::ostream& fout, std::string const& name, std::string const& path, cmGeneratorTarget const* t) const override; - void WriteProjectDepends(std::ostream& fout, std::string const& name, - std::string const& path, - cmGeneratorTarget const* t) const override; void WriteProjectConfigurations( std::ostream& fout, std::string const& name, cmGeneratorTarget const& target, std::vector const& configs, diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 9e4ead484e..fb59a007c0 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -600,69 +600,6 @@ void cmGlobalVisualStudio7Generator::WriteSLNFooter(std::ostream& fout) const fout << "EndGlobal\n"; } -std::string cmGlobalVisualStudio7Generator::WriteUtilityDepend( - cmGeneratorTarget const* target) -{ - std::vector configs = - target->Target->GetMakefile()->GetGeneratorConfigs( - cmMakefile::ExcludeEmptyConfig); - std::string pname = cmStrCat(target->GetName(), "_UTILITY"); - std::string fname = - cmStrCat(target->GetLocalGenerator()->GetCurrentBinaryDirectory(), '/', - pname, ".vcproj"); - cmGeneratedFileStream fout(fname); - fout.SetCopyIfDifferent(true); - std::string guid = this->GetGUID(pname); - - /* clang-format off */ - fout << - R"(Encoding() << "\"?>\n" - "GetIDEVersion() << "0\"\n" - "\tName=\"" << pname << "\"\n" - "\tProjectGUID=\"{" << guid << "}\"\n" - "\tKeyword=\"Win32Proj\">\n" - "\t\n" - "\t\n" - ; - /* clang-format on */ - std::string intDirPrefix = - target->GetLocalGenerator()->MaybeRelativeToCurBinDir( - cmStrCat(target->GetSupportDirectory(), '\\')); - for (std::string const& i : configs) { - std::string intDir = cmStrCat(intDirPrefix, i); - - /* clang-format off */ - fout << - "\t\t\n" - "\t\t\n" - ; - /* clang-format on */ - } - /* clang-format off */ - fout << - "\t\n" - "\t\n" - "\t\n" - "\n" - ; - /* clang-format on */ - - if (fout.Close()) { - this->FileReplacedDuringGenerate(fname); - } - return pname; -} - std::string cmGlobalVisualStudio7Generator::GetGUID( std::string const& name) const { diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index a63bc4c254..2a38aad2cf 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -160,7 +160,6 @@ protected: virtual void WriteSLNGlobalSections(std::ostream& fout, cmLocalGenerator* root) const; virtual void WriteSLNFooter(std::ostream& fout) const; - std::string WriteUtilityDepend(cmGeneratorTarget const* target) override; VSFolders CreateSolutionFolders( OrderedTargetDependSet const& orderedProjectTargets); diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index db7b1419e6..5642a03d56 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -450,14 +450,6 @@ bool cmGlobalVisualStudio8Generator::TargetSystemSupportsDeployment() const return this->TargetsWindowsCE(); } -bool cmGlobalVisualStudio8Generator::ComputeTargetDepends() -{ - // Skip over the cmGlobalVisualStudioGenerator implementation! - // We do not need the support that VS <= 7.1 needs. - // NOLINTNEXTLINE(bugprone-parent-virtual-call) - return this->cmGlobalGenerator::ComputeTargetDepends(); -} - void cmGlobalVisualStudio8Generator::WriteProjectDepends( std::ostream& fout, std::string const&, std::string const&, cmGeneratorTarget const* gt) const diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 23032d71aa..85e6ceb679 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -80,7 +80,6 @@ protected: cmGeneratorTarget const& target, std::vector const& configs, std::set const& configsPartOfDefaultBuild, std::string const& platformMapping = "") const override; - bool ComputeTargetDepends() override; void WriteProjectDepends(std::ostream& fout, std::string const& name, std::string const& path, cmGeneratorTarget const* t) const override; diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index c903f74f02..cee3fc27b6 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -321,148 +321,6 @@ std::string cmGlobalVisualStudioGenerator::GetUserMacrosRegKeyBase() return ""; } -void cmGlobalVisualStudioGenerator::FillLinkClosure( - cmGeneratorTarget const* target, TargetSet& linked) -{ - if (linked.insert(target).second) { - TargetDependSet const& depends = this->GetTargetDirectDepends(target); - for (cmTargetDepend const& di : depends) { - if (di.IsLink()) { - this->FillLinkClosure(di, linked); - } - } - } -} - -cmGlobalVisualStudioGenerator::TargetSet const& -cmGlobalVisualStudioGenerator::GetTargetLinkClosure(cmGeneratorTarget* target) -{ - auto i = this->TargetLinkClosure.find(target); - if (i == this->TargetLinkClosure.end()) { - TargetSetMap::value_type entry(target, TargetSet()); - i = this->TargetLinkClosure.insert(entry).first; - this->FillLinkClosure(target, i->second); - } - return i->second; -} - -void cmGlobalVisualStudioGenerator::FollowLinkDepends( - cmGeneratorTarget const* target, std::set& linked) -{ - if (!target->IsInBuildSystem()) { - return; - } - if (linked.insert(target).second && - target->GetType() == cmStateEnums::STATIC_LIBRARY) { - // Static library targets do not list their link dependencies so - // we must follow them transitively now. - TargetDependSet const& depends = this->GetTargetDirectDepends(target); - for (cmTargetDepend const& di : depends) { - if (di.IsLink()) { - this->FollowLinkDepends(di, linked); - } - } - } -} - -bool cmGlobalVisualStudioGenerator::ComputeTargetDepends() -{ - if (!this->cmGlobalGenerator::ComputeTargetDepends()) { - return false; - } - for (auto const& it : this->ProjectMap) { - for (cmLocalGenerator const* i : it.second) { - for (auto const& ti : i->GetGeneratorTargets()) { - this->ComputeVSTargetDepends(ti.get()); - } - } - } - return true; -} - -static bool VSLinkable(cmGeneratorTarget const* t) -{ - return t->IsLinkable() || t->GetType() == cmStateEnums::OBJECT_LIBRARY; -} - -void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends( - cmGeneratorTarget* target) -{ - if (this->VSTargetDepends.find(target) != this->VSTargetDepends.end()) { - return; - } - VSDependSet& vsTargetDepend = this->VSTargetDepends[target]; - // VS <= 7.1 has two behaviors that affect solution dependencies. - // - // (1) Solution-level dependencies between a linkable target and a - // library cause that library to be linked. We use an intermediate - // empty utility target to express the dependency. (VS 8 and above - // provide a project file "LinkLibraryDependencies" setting to - // choose whether to activate this behavior. We disable it except - // when linking external project files.) - // - // (2) We cannot let static libraries depend directly on targets to - // which they "link" because the librarian tool will copy the - // targets into the static library. While the work-around for - // behavior (1) would also avoid this, it would create a large - // number of extra utility targets for little gain. Instead, use - // the above work-around only for dependencies explicitly added by - // the add_dependencies() command. Approximate link dependencies by - // leaving them out for the static library itself but following them - // transitively for other targets. - - bool allowLinkable = (target->GetType() != cmStateEnums::STATIC_LIBRARY && - target->GetType() != cmStateEnums::SHARED_LIBRARY && - target->GetType() != cmStateEnums::MODULE_LIBRARY && - target->GetType() != cmStateEnums::EXECUTABLE); - - TargetDependSet const& depends = this->GetTargetDirectDepends(target); - - // Collect implicit link dependencies (target_link_libraries). - // Static libraries cannot depend on their link implementation - // due to behavior (2), but they do not really need to. - std::set linkDepends; - if (target->GetType() != cmStateEnums::STATIC_LIBRARY) { - for (cmTargetDepend const& di : depends) { - if (di.IsLink()) { - this->FollowLinkDepends(di, linkDepends); - } - } - } - - // Collect explicit util dependencies (add_dependencies). - std::set utilDepends; - for (cmTargetDepend const& di : depends) { - if (di.IsUtil()) { - this->FollowLinkDepends(di, utilDepends); - } - } - - // Collect all targets linked by this target so we can avoid - // intermediate targets below. - TargetSet linked; - if (target->GetType() != cmStateEnums::STATIC_LIBRARY) { - linked = this->GetTargetLinkClosure(target); - } - - // Emit link dependencies. - for (cmGeneratorTarget const* dep : linkDepends) { - vsTargetDepend.insert(dep->GetName()); - } - - // Emit util dependencies. Possibly use intermediate targets. - for (cmGeneratorTarget const* dgt : utilDepends) { - if (allowLinkable || !VSLinkable(dgt) || linked.count(dgt)) { - // Direct dependency allowed. - vsTargetDepend.insert(dgt->GetName()); - } else { - // Direct dependency on linkable target not allowed. - // Use an intermediate utility target. - vsTargetDepend.insert(this->GetUtilityDepend(dgt)); - } - } -} - bool cmGlobalVisualStudioGenerator::FindMakeProgram(cmMakefile* mf) { // Visual Studio generators know how to lookup their build tool @@ -474,18 +332,6 @@ bool cmGlobalVisualStudioGenerator::FindMakeProgram(cmMakefile* mf) return true; } -std::string cmGlobalVisualStudioGenerator::GetUtilityDepend( - cmGeneratorTarget const* target) -{ - auto i = this->UtilityDepends.find(target); - if (i == this->UtilityDepends.end()) { - std::string name = this->WriteUtilityDepend(target); - UtilityDependsMap::value_type entry(target, name); - i = this->UtilityDepends.insert(entry).first; - } - return i->second; -} - std::string cmGlobalVisualStudioGenerator::GetStartupProjectName( cmLocalGenerator const* root) const { diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 3a68ec655f..364ab3c6f4 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -174,21 +174,6 @@ protected: void WriteSLNHeader(std::ostream& fout) const; - bool ComputeTargetDepends() override; - class VSDependSet : public std::set - { - }; - class VSDependMap : public std::map - { - }; - VSDependMap VSTargetDepends; - void ComputeVSTargetDepends(cmGeneratorTarget*); - - virtual std::string WriteUtilityDepend(cmGeneratorTarget const*) = 0; - std::string GetUtilityDepend(cmGeneratorTarget const* target); - using UtilityDependsMap = std::map; - UtilityDependsMap UtilityDepends; - VSVersion Version; bool ExpressEdition; @@ -201,16 +186,6 @@ private: cmValue) const override { } - - void FollowLinkDepends(cmGeneratorTarget const* target, - std::set& linked); - - class TargetSetMap : public std::map - { - }; - TargetSetMap TargetLinkClosure; - void FillLinkClosure(cmGeneratorTarget const* target, TargetSet& linked); - TargetSet const& GetTargetLinkClosure(cmGeneratorTarget* target); }; class cmGlobalVisualStudioGenerator::OrderedTargetDependSet