mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-01 19:30:13 -06:00
cmGlobalVisualStudioGenerator: Remove unused code left from VS 7.1
Since commit c94f1bcf92 (Drop Visual Studio 7 .NET 2003 generator,
2017-04-19, v3.9.0-rc1~248^2) we no longer need special solution-level
target dependencies. We use `LinkLibraryDependencies` instead.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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<std::string> const& configs,
|
||||
|
||||
@@ -600,69 +600,6 @@ void cmGlobalVisualStudio7Generator::WriteSLNFooter(std::ostream& fout) const
|
||||
fout << "EndGlobal\n";
|
||||
}
|
||||
|
||||
std::string cmGlobalVisualStudio7Generator::WriteUtilityDepend(
|
||||
cmGeneratorTarget const* target)
|
||||
{
|
||||
std::vector<std::string> 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"(<?xml version="1.0" encoding = ")"
|
||||
<< this->Encoding() << "\"?>\n"
|
||||
"<VisualStudioProject\n"
|
||||
"\tProjectType=\"Visual C++\"\n"
|
||||
"\tVersion=\"" << this->GetIDEVersion() << "0\"\n"
|
||||
"\tName=\"" << pname << "\"\n"
|
||||
"\tProjectGUID=\"{" << guid << "}\"\n"
|
||||
"\tKeyword=\"Win32Proj\">\n"
|
||||
"\t<Platforms><Platform Name=\"Win32\"/></Platforms>\n"
|
||||
"\t<Configurations>\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<Configuration\n"
|
||||
"\t\t\tName=\"" << i << "|Win32\"\n"
|
||||
"\t\t\tOutputDirectory=\"" << i << "\"\n"
|
||||
"\t\t\tIntermediateDirectory=\"" << intDir << "\"\n"
|
||||
"\t\t\tConfigurationType=\"10\"\n"
|
||||
"\t\t\tUseOfMFC=\"0\"\n"
|
||||
"\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n"
|
||||
"\t\t\tCharacterSet=\"2\">\n"
|
||||
"\t\t</Configuration>\n"
|
||||
;
|
||||
/* clang-format on */
|
||||
}
|
||||
/* clang-format off */
|
||||
fout <<
|
||||
"\t</Configurations>\n"
|
||||
"\t<Files></Files>\n"
|
||||
"\t<Globals></Globals>\n"
|
||||
"</VisualStudioProject>\n"
|
||||
;
|
||||
/* clang-format on */
|
||||
|
||||
if (fout.Close()) {
|
||||
this->FileReplacedDuringGenerate(fname);
|
||||
}
|
||||
return pname;
|
||||
}
|
||||
|
||||
std::string cmGlobalVisualStudio7Generator::GetGUID(
|
||||
std::string const& name) const
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -80,7 +80,6 @@ protected:
|
||||
cmGeneratorTarget const& target, std::vector<std::string> const& configs,
|
||||
std::set<std::string> 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;
|
||||
|
||||
@@ -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<cmGeneratorTarget const*>& 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<cmGeneratorTarget const*> 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<cmGeneratorTarget const*> 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
|
||||
{
|
||||
|
||||
@@ -174,21 +174,6 @@ protected:
|
||||
|
||||
void WriteSLNHeader(std::ostream& fout) const;
|
||||
|
||||
bool ComputeTargetDepends() override;
|
||||
class VSDependSet : public std::set<std::string>
|
||||
{
|
||||
};
|
||||
class VSDependMap : public std::map<cmGeneratorTarget const*, VSDependSet>
|
||||
{
|
||||
};
|
||||
VSDependMap VSTargetDepends;
|
||||
void ComputeVSTargetDepends(cmGeneratorTarget*);
|
||||
|
||||
virtual std::string WriteUtilityDepend(cmGeneratorTarget const*) = 0;
|
||||
std::string GetUtilityDepend(cmGeneratorTarget const* target);
|
||||
using UtilityDependsMap = std::map<cmGeneratorTarget const*, std::string>;
|
||||
UtilityDependsMap UtilityDepends;
|
||||
|
||||
VSVersion Version;
|
||||
bool ExpressEdition;
|
||||
|
||||
@@ -201,16 +186,6 @@ private:
|
||||
cmValue) const override
|
||||
{
|
||||
}
|
||||
|
||||
void FollowLinkDepends(cmGeneratorTarget const* target,
|
||||
std::set<cmGeneratorTarget const*>& linked);
|
||||
|
||||
class TargetSetMap : public std::map<cmGeneratorTarget*, TargetSet>
|
||||
{
|
||||
};
|
||||
TargetSetMap TargetLinkClosure;
|
||||
void FillLinkClosure(cmGeneratorTarget const* target, TargetSet& linked);
|
||||
TargetSet const& GetTargetLinkClosure(cmGeneratorTarget* target);
|
||||
};
|
||||
|
||||
class cmGlobalVisualStudioGenerator::OrderedTargetDependSet
|
||||
|
||||
Reference in New Issue
Block a user