ENH: clean up utility rule generation

This commit is contained in:
Bill Hoffman 2002-04-11 10:29:51 -04:00
parent 4988ad93c0
commit ea4a3d5e7b
2 changed files with 30 additions and 1 deletions

View File

@ -785,6 +785,27 @@ void cmUnixMakefileGenerator::OutputExecutableRule(std::ostream& fout,
cc);
}
void cmUnixMakefileGenerator::OutputUtilityRule(std::ostream& fout,
const char* name,
const cmTarget &t)
{
std::string customCommands = this->CreateTargetRules(t, name);
const char* cc = 0;
if(customCommands.size() > 0)
{
cc = customCommands.c_str();
}
std::string comment = "Rule to build Utility ";
comment += name;
this->OutputMakeRule(fout,
comment.c_str(),
name,
0,
cc);
}
void cmUnixMakefileGenerator::OutputTargets(std::ostream& fout)
@ -810,6 +831,8 @@ void cmUnixMakefileGenerator::OutputTargets(std::ostream& fout)
this->OutputExecutableRule(fout, l->first.c_str(), l->second);
break;
case cmTarget::UTILITY:
this->OutputUtilityRule(fout, l->first.c_str(), l->second);
break;
// This is handled by the OutputCustomRules method
case cmTarget::INSTALL_FILES:
// This is handled by the OutputInstallRules method
@ -1386,7 +1409,11 @@ void cmUnixMakefileGenerator::OutputCustomRules(std::ostream& fout)
tgt->second.GetCustomCommands().begin();
cr != tgt->second.GetCustomCommands().end(); ++cr)
{
if ( cr->GetSourceName() != tgt->first )
// if the source for the custom command is the same name
// as the target, then to not create a rule in the makefile for
// the custom command, as the command will be fired when the other target
// is built.
if ( cr->GetSourceName().compare(tgt->first) !=0)
{
cmSourceGroup& sourceGroup =
m_Makefile->FindSourceGroup(cr->GetSourceName().c_str(),

View File

@ -98,6 +98,8 @@ protected:
const cmTarget &);
virtual void OutputExecutableRule(std::ostream&, const char* name,
const cmTarget &);
virtual void OutputUtilityRule(std::ostream&, const char* name,
const cmTarget &);
virtual void OutputTargets(std::ostream&);
virtual void OutputSubDirectoryRules(std::ostream&);