COMP: Converting INSTALL->ALL_BUILD dependency implementation to use the AddUtility method on a target. This significantly simplifies the implementation and removes warnings about hiding virtual functions.

This commit is contained in:
Brad King 2005-04-29 10:11:24 -04:00
parent cf5c2b7ae8
commit 48702f8a8d
6 changed files with 35 additions and 81 deletions

View File

@ -165,6 +165,17 @@ void cmGlobalVisualStudio6Generator::Generate()
AddUtilityCommand("INSTALL", false, no_output, no_depends, AddUtilityCommand("INSTALL", false, no_output, no_depends,
cmake_command.c_str(), cmake_command.c_str(),
"-DBUILD_TYPE=$(IntDir)", "-P", "cmake_install.cmake"); "-DBUILD_TYPE=$(IntDir)", "-P", "cmake_install.cmake");
// Make the INSTALL target depend on ALL_BUILD unless the
// project says to not do so.
const char* noall =
gen[0]->GetMakefile()
->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY");
if(!noall || cmSystemTools::IsOff(noall))
{
cmTarget* install = gen[0]->GetMakefile()->FindTarget("INSTALL");
install->AddUtility("ALL_BUILD");
}
} }
} }
@ -267,7 +278,6 @@ void cmGlobalVisualStudio6Generator::WriteDSWFile(std::ostream& fout,
if ((l->second.GetType() != cmTarget::INSTALL_FILES) if ((l->second.GetType() != cmTarget::INSTALL_FILES)
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS)) && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
{ {
const char* extra_depend = 0;
bool skip = false; bool skip = false;
// skip ALL_BUILD and RUN_TESTS if they have already been added // skip ALL_BUILD and RUN_TESTS if they have already been added
if(l->first == "ALL_BUILD" ) if(l->first == "ALL_BUILD" )
@ -291,16 +301,6 @@ void cmGlobalVisualStudio6Generator::WriteDSWFile(std::ostream& fout,
{ {
doneInstall = true; doneInstall = true;
} }
// Make the INSTALL target depend on ALL_BUILD unless the
// project says to not do so.
const char* noall =
root->GetMakefile()
->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY");
if(!noall || cmSystemTools::IsOff(noall))
{
extra_depend = "ALL_BUILD";
}
} }
if(l->first == "RUN_TESTS") if(l->first == "RUN_TESTS")
{ {
@ -315,8 +315,7 @@ void cmGlobalVisualStudio6Generator::WriteDSWFile(std::ostream& fout,
} }
if(!skip) if(!skip)
{ {
this->WriteProject(fout, si->c_str(), dir.c_str(),l->second, this->WriteProject(fout, si->c_str(), dir.c_str(),l->second);
extra_depend);
} }
++si; ++si;
} }
@ -366,8 +365,7 @@ void cmGlobalVisualStudio6Generator::OutputDSWFile()
void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout, void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout,
const char* dspname, const char* dspname,
const char* dir, const char* dir,
const cmTarget& target, const cmTarget& target)
const char* extra_depend)
{ {
fout << "#########################################################" fout << "#########################################################"
"######################\n\n"; "######################\n\n";
@ -401,14 +399,6 @@ void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout,
} }
} }
// Add an extra dependency if specified.
if(extra_depend)
{
fout << "Begin Project Dependency\n";
fout << "Project_Dep_Name " << extra_depend << "\n";
fout << "End Project Dependency\n";
}
std::set<cmStdString>::const_iterator i, end; std::set<cmStdString>::const_iterator i, end;
// write utility dependencies. // write utility dependencies.
i = target.GetUtilities().begin(); i = target.GetUtilities().begin();

View File

@ -79,7 +79,7 @@ private:
void WriteDSWHeader(std::ostream& fout); void WriteDSWHeader(std::ostream& fout);
void WriteProject(std::ostream& fout, void WriteProject(std::ostream& fout,
const char* name, const char* path, const char* name, const char* path,
const cmTarget &t, const char* extra_depend); const cmTarget &t);
void WriteExternalProject(std::ostream& fout, void WriteExternalProject(std::ostream& fout,
const char* name, const char* path, const char* name, const char* path,
const std::vector<std::string>& dependencies); const std::vector<std::string>& dependencies);

View File

@ -130,7 +130,6 @@ void cmGlobalVisualStudio71Generator::WriteSLNFile(std::ostream& fout,
if ((l->second.GetType() != cmTarget::INSTALL_FILES) if ((l->second.GetType() != cmTarget::INSTALL_FILES)
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS)) && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
{ {
const char* extra_depend = 0;
bool skip = false; bool skip = false;
if(l->first == "ALL_BUILD" ) if(l->first == "ALL_BUILD" )
{ {
@ -153,15 +152,6 @@ void cmGlobalVisualStudio71Generator::WriteSLNFile(std::ostream& fout,
{ {
doneInstall = true; doneInstall = true;
} }
// Make the INSTALL target depend on ALL_BUILD unless the
// project says to not do so.
const char* noall =
root->GetMakefile()
->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY");
if(!noall || cmSystemTools::IsOff(noall))
{
extra_depend = "ALL_BUILD";
}
} }
if(l->first == "RUN_TESTS") if(l->first == "RUN_TESTS")
{ {
@ -176,8 +166,7 @@ void cmGlobalVisualStudio71Generator::WriteSLNFile(std::ostream& fout,
} }
if(!skip) if(!skip)
{ {
this->WriteProject(fout, si->c_str(), dir.c_str(),l->second, this->WriteProject(fout, si->c_str(), dir.c_str(),l->second);
extra_depend);
} }
++si; ++si;
} }
@ -240,8 +229,7 @@ void
cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout, cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
const char* dspname, const char* dspname,
const char* dir, const char* dir,
const cmTarget& t, const cmTarget& t)
const char* extra_depend)
{ {
std::string d = cmSystemTools::ConvertToOutputPath(dir); std::string d = cmSystemTools::ConvertToOutputPath(dir);
fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
@ -249,7 +237,7 @@ cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
<< d << "\\" << dspname << ".vcproj\", \"{" << d << "\\" << dspname << ".vcproj\", \"{"
<< this->GetGUID(dspname) << "}\"\n"; << this->GetGUID(dspname) << "}\"\n";
fout << "\tProjectSection(ProjectDependencies) = postProject\n"; fout << "\tProjectSection(ProjectDependencies) = postProject\n";
this->WriteProjectDepends(fout, dspname, dir, t, extra_depend); this->WriteProjectDepends(fout, dspname, dir, t);
fout << "\tEndProjectSection\n"; fout << "\tEndProjectSection\n";
fout <<"EndProject\n"; fout <<"EndProject\n";
@ -265,8 +253,7 @@ cmGlobalVisualStudio71Generator
::WriteProjectDepends(std::ostream& fout, ::WriteProjectDepends(std::ostream& fout,
const char* dspname, const char* dspname,
const char*, const char*,
const cmTarget& target, const cmTarget& target)
const char* extra_depend)
{ {
// insert Begin Project Dependency Project_Dep_Name project stuff here // insert Begin Project Dependency Project_Dep_Name project stuff here
if (target.GetType() != cmTarget::STATIC_LIBRARY) if (target.GetType() != cmTarget::STATIC_LIBRARY)
@ -291,13 +278,6 @@ cmGlobalVisualStudio71Generator
} }
} }
// Add the extra dependency if requested.
if(extra_depend)
{
fout << "\t\t{" << this->GetGUID(extra_depend) << "} = {"
<< this->GetGUID(extra_depend) << "}\n";
}
std::set<cmStdString>::const_iterator i, end; std::set<cmStdString>::const_iterator i, end;
// write utility dependencies. // write utility dependencies.
i = target.GetUtilities().begin(); i = target.GetUtilities().begin();

View File

@ -48,10 +48,10 @@ protected:
std::vector<cmLocalGenerator*>& generators); std::vector<cmLocalGenerator*>& generators);
virtual void WriteProject(std::ostream& fout, virtual void WriteProject(std::ostream& fout,
const char* name, const char* path, const char* name, const char* path,
const cmTarget &t, const char* extra_depend); const cmTarget &t);
virtual void WriteProjectDepends(std::ostream& fout, virtual void WriteProjectDepends(std::ostream& fout,
const char* name, const char* path, const char* name, const char* path,
const cmTarget &t, const char* extra_depend); const cmTarget &t);
virtual void WriteProjectConfigurations(std::ostream& fout, const char* name, bool in_all); virtual void WriteProjectConfigurations(std::ostream& fout, const char* name, bool in_all);
virtual void WriteExternalProject(std::ostream& fout, const char* name, const char* path, virtual void WriteExternalProject(std::ostream& fout, const char* name, const char* path,
const std::vector<std::string>& depends); const std::vector<std::string>& depends);

View File

@ -197,6 +197,17 @@ void cmGlobalVisualStudio7Generator::Generate()
AddUtilityCommand("INSTALL", false, no_output, no_depends, AddUtilityCommand("INSTALL", false, no_output, no_depends,
cmake_command.c_str(), cmake_command.c_str(),
"-DBUILD_TYPE=$(IntDir)", "-P", "cmake_install.cmake"); "-DBUILD_TYPE=$(IntDir)", "-P", "cmake_install.cmake");
// Make the INSTALL target depend on ALL_BUILD unless the
// project says to not do so.
const char* noall =
gen[0]->GetMakefile()
->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY");
if(!noall || cmSystemTools::IsOff(noall))
{
cmTarget* install = gen[0]->GetMakefile()->FindTarget("INSTALL");
install->AddUtility("ALL_BUILD");
}
} }
} }
@ -432,21 +443,7 @@ void cmGlobalVisualStudio7Generator::WriteSLNFile(std::ostream& fout,
else if ((l->second.GetType() != cmTarget::INSTALL_FILES) else if ((l->second.GetType() != cmTarget::INSTALL_FILES)
&& (l->second.GetType() != cmTarget::INSTALL_PROGRAMS)) && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
{ {
// Make the INSTALL target depend on ALL_BUILD unless the this->WriteProjectDepends(fout, si->c_str(), dir.c_str(), l->second);
// project says to not do so.
const char* extra_depend = 0;
if(l->first == "INSTALL")
{
const char* noall =
root->GetMakefile()
->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY");
if(!noall || cmSystemTools::IsOff(noall))
{
extra_depend = "ALL_BUILD";
}
}
this->WriteProjectDepends(fout, si->c_str(), dir.c_str(), l->second,
extra_depend);
++si; ++si;
} }
} }
@ -517,8 +514,7 @@ cmGlobalVisualStudio7Generator
::WriteProjectDepends(std::ostream& fout, ::WriteProjectDepends(std::ostream& fout,
const char* dspname, const char* dspname,
const char*, const char*,
const cmTarget& target, const cmTarget& target)
const char* extra_depend)
{ {
int depcount = 0; int depcount = 0;
// insert Begin Project Dependency Project_Dep_Name project stuff here // insert Begin Project Dependency Project_Dep_Name project stuff here
@ -555,18 +551,6 @@ cmGlobalVisualStudio7Generator
} }
} }
// Add the extra dependency if requested.
if(extra_depend)
{
std::string guid = this->GetGUID(extra_depend);
if(!guid.empty())
{
fout << "\t\t{" << this->GetGUID(dspname) << "}." << depcount << " = {"
<< guid << "}\n";
depcount++;
}
}
std::set<cmStdString>::const_iterator i, end; std::set<cmStdString>::const_iterator i, end;
// write utility dependencies. // write utility dependencies.
i = target.GetUtilities().begin(); i = target.GetUtilities().begin();

View File

@ -89,7 +89,7 @@ protected:
const cmTarget &t); const cmTarget &t);
virtual void WriteProjectDepends(std::ostream& fout, virtual void WriteProjectDepends(std::ostream& fout,
const char* name, const char* path, const char* name, const char* path,
const cmTarget &t, const char* extra_depend); const cmTarget &t);
virtual void WriteProjectConfigurations(std::ostream& fout, const char* name, bool in_all); virtual void WriteProjectConfigurations(std::ostream& fout, const char* name, bool in_all);
virtual void WriteSLNFooter(std::ostream& fout); virtual void WriteSLNFooter(std::ostream& fout);
virtual void WriteSLNHeader(std::ostream& fout); virtual void WriteSLNHeader(std::ostream& fout);