ENH: do not depend on the .dsp file but rather depend on .dsp.cmake and if the .dsp actually changes, then write it, so clean and rebuild will not cause many reloads

This commit is contained in:
Bill Hoffman 2002-01-14 19:08:38 -05:00
parent 1a31d4b314
commit cb796a7227

View File

@ -136,19 +136,27 @@ void cmDSPWriter::OutputDSPFile()
void cmDSPWriter::CreateSingleDSP(const char *lname, cmTarget &target) void cmDSPWriter::CreateSingleDSP(const char *lname, cmTarget &target)
{ {
// add to the list of projects
std::string pname = lname;
m_CreatedProjectNames.push_back(pname);
// create the dsp.cmake file
std::string fname; std::string fname;
fname = m_Makefile->GetStartOutputDirectory(); fname = m_Makefile->GetStartOutputDirectory();
fname += "/"; fname += "/";
fname += lname; fname += lname;
fname += ".dsp"; fname += ".dsp";
std::string pname = lname; // save the name of the real dsp file
m_CreatedProjectNames.push_back(pname); std::string realDSP = fname;
fname += ".cmake";
std::ofstream fout(fname.c_str()); std::ofstream fout(fname.c_str());
if(!fout) if(!fout)
{ {
cmSystemTools::Error("Error Writing ", fname.c_str()); cmSystemTools::Error("Error Writing ", fname.c_str());
} }
this->WriteDSPFile(fout,lname,target); this->WriteDSPFile(fout,lname,target);
fout.close();
// if the dsp file has changed, then write it.
cmSystemTools::CopyFileIfDifferent(fname.c_str(), realDSP.c_str());
} }
@ -159,13 +167,13 @@ void cmDSPWriter::AddDSPBuildRule(cmSourceGroup& sourceGroup)
{ {
return; return;
} }
dspname += ".dsp"; dspname += ".dsp.cmake";
std::string makefileIn = m_Makefile->GetStartDirectory(); std::string makefileIn = m_Makefile->GetStartDirectory();
makefileIn += "/"; makefileIn += "/";
makefileIn += "CMakeLists.txt"; makefileIn += "CMakeLists.txt";
makefileIn = cmSystemTools::HandleNetworkPaths(makefileIn.c_str()); makefileIn = cmSystemTools::HandleNetworkPaths(makefileIn.c_str());
makefileIn = cmSystemTools::EscapeSpaces(makefileIn.c_str()); makefileIn = cmSystemTools::EscapeSpaces(makefileIn.c_str());
std::string dsprule = "${CMAKE_COMMAND} "; std::string dsprule = "${CMAKE_COMMAND}";
m_Makefile->ExpandVariablesInString(dsprule); m_Makefile->ExpandVariablesInString(dsprule);
dsprule = cmSystemTools::HandleNetworkPaths(dsprule.c_str()); dsprule = cmSystemTools::HandleNetworkPaths(dsprule.c_str());
std::string args = makefileIn; std::string args = makefileIn;
@ -179,12 +187,30 @@ void cmDSPWriter::AddDSPBuildRule(cmSourceGroup& sourceGroup)
args += cmSystemTools::HandleNetworkPaths(m_Makefile->GetHomeOutputDirectory()); args += cmSystemTools::HandleNetworkPaths(m_Makefile->GetHomeOutputDirectory());
args += "\""; args += "\"";
m_Makefile->ExpandVariablesInString(args); m_Makefile->ExpandVariablesInString(args);
std::string configFile =
m_Makefile->GetDefinition("CMAKE_ROOT");
configFile += "/Templates/CMakeWindowsSystemConfig.cmake";
std::vector<std::string> listFiles = m_Makefile->GetListFiles();
bool found = false;
for(std::vector<std::string>::iterator i = listFiles.begin();
i != listFiles.end(); ++i)
{
if(*i == configFile)
{
found = true;
}
}
if(!found)
{
listFiles.push_back(configFile);
}
std::vector<std::string> outputs; std::vector<std::string> outputs;
outputs.push_back(dspname); outputs.push_back(dspname);
cmCustomCommand cc(makefileIn.c_str(), dsprule.c_str(), cmCustomCommand cc(makefileIn.c_str(), dsprule.c_str(),
args.c_str(), args.c_str(),
m_Makefile->GetListFiles(), listFiles,
outputs); outputs);
sourceGroup.AddCustomCommand(cc); sourceGroup.AddCustomCommand(cc);
} }
@ -455,7 +481,7 @@ cmDSPWriter::CombineCommands(const cmSourceGroup::Commands &commands,
c != commands.end(); ++c) c != commands.end(); ++c)
{ {
totalCommandStr += "\n\t"; totalCommandStr += "\n\t";
temp= c->second.m_Command; temp= c->second.m_Command;
cmSystemTools::ConvertToWindowsSlashes(temp); cmSystemTools::ConvertToWindowsSlashes(temp);
temp = cmSystemTools::EscapeSpaces(temp.c_str()); temp = cmSystemTools::EscapeSpaces(temp.c_str());
totalCommandStr += temp; totalCommandStr += temp;