summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalVisualStudio7Generator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2006-08-26 02:56:41 (GMT)
committerBrad King <brad.king@kitware.com>2006-08-26 02:56:41 (GMT)
commit7e47f8496a3021a2b9a39a909514b7b20ff0d801 (patch)
treecc099ea4c6cbbab77913119c3827521d6f09e6bd /Source/cmLocalVisualStudio7Generator.cxx
parented6791c8986741e630844a155b7ce684a623b8c3 (diff)
downloadCMake-7e47f8496a3021a2b9a39a909514b7b20ff0d801.zip
CMake-7e47f8496a3021a2b9a39a909514b7b20ff0d801.tar.gz
CMake-7e47f8496a3021a2b9a39a909514b7b20ff0d801.tar.bz2
BUG: Fix for VS.NET 2003 SP1 to make sure global target and utility target rules run every time.
Diffstat (limited to 'Source/cmLocalVisualStudio7Generator.cxx')
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx67
1 files changed, 59 insertions, 8 deletions
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index e8a5dba..5de5f2f 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -44,9 +44,46 @@ void cmLocalVisualStudio7Generator::Generate()
lang.insert("IDL");
lang.insert("DEF");
this->CreateCustomTargetsAndCommands(lang);
+ this->FixTargets();
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
// for CommandLine= need to repleace quotes with &quot
// write out configurations
@@ -1268,15 +1305,29 @@ WriteCustomRule(std::ostream& fout,
<< "\t\t\t\t\tCommandLine=\""
<< this->EscapeForXML(command) << "\"\n"
<< "\t\t\t\t\tAdditionalDependencies=\"";
- // Write out the dependencies for the rule.
- std::string temp;
- for(std::vector<std::string>::const_iterator d = depends.begin();
- d != depends.end(); ++d)
+ if(depends.empty())
{
- // 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())
- << ";";
+ // There are no real dependencies. Produce an artificial one to
+ // make sure the rule runs reliably.
+ 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 << "\t\t\t\t\tOutputs=\"";