BUG: Fix for VS.NET 2003 SP1 to make sure global target and utility target rules run every time.

This commit is contained in:
Brad King 2006-08-25 22:56:41 -04:00
parent ed6791c898
commit 7e47f8496a
2 changed files with 60 additions and 8 deletions

View File

@ -44,9 +44,46 @@ void cmLocalVisualStudio7Generator::Generate()
lang.insert("IDL"); lang.insert("IDL");
lang.insert("DEF"); lang.insert("DEF");
this->CreateCustomTargetsAndCommands(lang); this->CreateCustomTargetsAndCommands(lang);
this->FixTargets();
this->OutputVCProjFile(); this->OutputVCProjFile();
} }
void cmLocalVisualStudio7Generator::FixTargets()
{
// Visual Studio .NET 2003 Service Pack 1 will not run post-build
// commands for targets in which no sources are built. Add dummy
// rules to force these targets to build.
cmTargets &tgts = this->Makefile->GetTargets();
for(cmTargets::iterator l = tgts.begin();
l != tgts.end(); l++)
{
cmTarget& tgt = l->second;
if(tgt.GetType() == cmTarget::GLOBAL_TARGET ||
tgt.GetType() == cmTarget::UTILITY)
{
std::vector<std::string> no_depends;
cmCustomCommandLine force_command;
force_command.push_back(";");
cmCustomCommandLines force_commands;
force_commands.push_back(force_command);
const char* no_main_dependency = 0;
std::string force = this->Makefile->GetStartOutputDirectory();
force += cmake::GetCMakeFilesDirectory();
force += "/";
force += tgt.GetName();
force += "_force";
this->Makefile->AddCustomCommandToOutput(force.c_str(), no_depends,
no_main_dependency,
force_commands, " ", 0, true);
if(cmSourceFile* file =
this->Makefile->GetSourceFileWithOutput(force.c_str()))
{
tgt.GetSourceFiles().push_back(file);
}
}
}
}
// TODO // TODO
// for CommandLine= need to repleace quotes with &quot // for CommandLine= need to repleace quotes with &quot
// write out configurations // write out configurations
@ -1268,15 +1305,29 @@ WriteCustomRule(std::ostream& fout,
<< "\t\t\t\t\tCommandLine=\"" << "\t\t\t\t\tCommandLine=\""
<< this->EscapeForXML(command) << "\"\n" << this->EscapeForXML(command) << "\"\n"
<< "\t\t\t\t\tAdditionalDependencies=\""; << "\t\t\t\t\tAdditionalDependencies=\"";
// Write out the dependencies for the rule. if(depends.empty())
std::string temp;
for(std::vector<std::string>::const_iterator d = depends.begin();
d != depends.end(); ++d)
{ {
// Lookup the real name of the dependency in case it is a CMake target. // There are no real dependencies. Produce an artificial one to
std::string dep = this->GetRealDependency(d->c_str(), i->c_str()); // make sure the rule runs reliably.
fout << this->ConvertToXMLOutputPath(dep.c_str()) if(!cmSystemTools::FileExists(source))
<< ";"; {
std::ofstream depout(source);
depout << "Artificial dependency for a custom command.\n";
}
fout << this->ConvertToXMLOutputPath(source);
}
else
{
// Write out the dependencies for the rule.
std::string temp;
for(std::vector<std::string>::const_iterator d = depends.begin();
d != depends.end(); ++d)
{
// Lookup the real name of the dependency in case it is a CMake target.
std::string dep = this->GetRealDependency(d->c_str(), i->c_str());
fout << this->ConvertToXMLOutputPath(dep.c_str())
<< ";";
}
} }
fout << "\"\n"; fout << "\"\n";
fout << "\t\t\t\t\tOutputs=\""; fout << "\t\t\t\t\tOutputs=\"";

View File

@ -71,6 +71,7 @@ private:
std::string& flags); std::string& flags);
std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags, std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags,
const char* configName); const char* configName);
void FixTargets();
void OutputVCProjFile(); void OutputVCProjFile();
void WriteVCProjHeader(std::ostream& fout, const char *libName, void WriteVCProjHeader(std::ostream& fout, const char *libName,
cmTarget &tgt, std::vector<cmSourceGroup> &sgs); cmTarget &tgt, std::vector<cmSourceGroup> &sgs);