|
|
@@ -19,6 +19,7 @@
|
|
|
#include "cmLocalVisualStudio7Generator.h"
|
|
|
#include "cmMakefile.h"
|
|
|
#include "cmake.h"
|
|
|
+#include "cmGeneratedFileStream.h"
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator()
|
|
|
@@ -131,6 +132,13 @@ void cmGlobalVisualStudio8Generator::Generate()
|
|
|
cmLocalVisualStudio7Generator* lg =
|
|
|
static_cast<cmLocalVisualStudio7Generator*>(generators[0]);
|
|
|
cmMakefile* mf = lg->GetMakefile();
|
|
|
+
|
|
|
+ // Skip the target if no regeneration is to be done.
|
|
|
+ if(mf->IsOn("CMAKE_SUPPRESS_REGENERATION"))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
std::string cmake_command = mf->GetRequiredDefinition("CMAKE_COMMAND");
|
|
|
cmCustomCommandLines noCommandLines;
|
|
|
mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false,
|
|
|
@@ -144,71 +152,93 @@ void cmGlobalVisualStudio8Generator::Generate()
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
+ // Create a list of all stamp files for this project.
|
|
|
+ std::vector<std::string> stamps;
|
|
|
+ std::string stampList = cmake::GetCMakeFilesDirectoryPostSlash();
|
|
|
+ stampList += "generate.stamp.list";
|
|
|
+ {
|
|
|
+ std::string stampListFile =
|
|
|
+ generators[0]->GetMakefile()->GetCurrentOutputDirectory();
|
|
|
+ stampListFile += "/";
|
|
|
+ stampListFile += stampList;
|
|
|
+ std::string stampFile;
|
|
|
+ cmGeneratedFileStream fout(stampList.c_str());
|
|
|
+ for(std::vector<cmLocalGenerator*>::const_iterator
|
|
|
+ gi = generators.begin(); gi != generators.end(); ++gi)
|
|
|
+ {
|
|
|
+ stampFile = (*gi)->GetMakefile()->GetCurrentOutputDirectory();
|
|
|
+ stampFile += "/";
|
|
|
+ stampFile += cmake::GetCMakeFilesDirectoryPostSlash();
|
|
|
+ stampFile += "generate.stamp";
|
|
|
+ stampFile = generators[0]->Convert(stampFile.c_str(),
|
|
|
+ cmLocalGenerator::START_OUTPUT);
|
|
|
+ fout << stampFile << "\n";
|
|
|
+ stamps.push_back(stampFile);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// Add a custom rule to re-run CMake if any input files changed.
|
|
|
- const char* suppRegenRule =
|
|
|
- mf->GetDefinition("CMAKE_SUPPRESS_REGENERATION");
|
|
|
- if(!cmSystemTools::IsOn(suppRegenRule))
|
|
|
+ {
|
|
|
+ // Collect the input files used to generate all targets in this
|
|
|
+ // project.
|
|
|
+ std::vector<std::string> listFiles;
|
|
|
+ for(unsigned int j = 0; j < generators.size(); ++j)
|
|
|
{
|
|
|
- // Collect the input files used to generate all targets in this
|
|
|
- // project.
|
|
|
- std::vector<std::string> listFiles;
|
|
|
- for(unsigned int j = 0; j < generators.size(); ++j)
|
|
|
- {
|
|
|
- cmMakefile* lmf = generators[j]->GetMakefile();
|
|
|
- listFiles.insert(listFiles.end(), lmf->GetListFiles().begin(),
|
|
|
- lmf->GetListFiles().end());
|
|
|
- }
|
|
|
- // Sort the list of input files and remove duplicates.
|
|
|
- std::sort(listFiles.begin(), listFiles.end(),
|
|
|
- std::less<std::string>());
|
|
|
- std::vector<std::string>::iterator new_end =
|
|
|
- std::unique(listFiles.begin(), listFiles.end());
|
|
|
- listFiles.erase(new_end, listFiles.end());
|
|
|
+ cmMakefile* lmf = generators[j]->GetMakefile();
|
|
|
+ listFiles.insert(listFiles.end(), lmf->GetListFiles().begin(),
|
|
|
+ lmf->GetListFiles().end());
|
|
|
+ }
|
|
|
+ // Sort the list of input files and remove duplicates.
|
|
|
+ std::sort(listFiles.begin(), listFiles.end(),
|
|
|
+ std::less<std::string>());
|
|
|
+ std::vector<std::string>::iterator new_end =
|
|
|
+ std::unique(listFiles.begin(), listFiles.end());
|
|
|
+ listFiles.erase(new_end, listFiles.end());
|
|
|
|
|
|
- // Create a rule to re-run CMake.
|
|
|
- std::string stampName = cmake::GetCMakeFilesDirectoryPostSlash();
|
|
|
- stampName += "generate.stamp";
|
|
|
- const char* dsprule = mf->GetRequiredDefinition("CMAKE_COMMAND");
|
|
|
- cmCustomCommandLine commandLine;
|
|
|
- commandLine.push_back(dsprule);
|
|
|
- std::string argH = "-H";
|
|
|
- argH += lg->Convert(mf->GetHomeDirectory(),
|
|
|
- cmLocalGenerator::START_OUTPUT,
|
|
|
- cmLocalGenerator::UNCHANGED, true);
|
|
|
- commandLine.push_back(argH);
|
|
|
- std::string argB = "-B";
|
|
|
- argB += lg->Convert(mf->GetHomeOutputDirectory(),
|
|
|
- cmLocalGenerator::START_OUTPUT,
|
|
|
- cmLocalGenerator::UNCHANGED, true);
|
|
|
- commandLine.push_back(argB);
|
|
|
- commandLine.push_back("--check-stamp-file");
|
|
|
- commandLine.push_back(stampName.c_str());
|
|
|
- commandLine.push_back("--vs-solution-file");
|
|
|
- commandLine.push_back("\"$(SolutionPath)\"");
|
|
|
- cmCustomCommandLines commandLines;
|
|
|
- commandLines.push_back(commandLine);
|
|
|
+ // Create a rule to re-run CMake.
|
|
|
+ std::string stampName = cmake::GetCMakeFilesDirectoryPostSlash();
|
|
|
+ stampName += "generate.stamp";
|
|
|
+ const char* dsprule = mf->GetRequiredDefinition("CMAKE_COMMAND");
|
|
|
+ cmCustomCommandLine commandLine;
|
|
|
+ commandLine.push_back(dsprule);
|
|
|
+ std::string argH = "-H";
|
|
|
+ argH += lg->Convert(mf->GetHomeDirectory(),
|
|
|
+ cmLocalGenerator::START_OUTPUT,
|
|
|
+ cmLocalGenerator::UNCHANGED, true);
|
|
|
+ commandLine.push_back(argH);
|
|
|
+ std::string argB = "-B";
|
|
|
+ argB += lg->Convert(mf->GetHomeOutputDirectory(),
|
|
|
+ cmLocalGenerator::START_OUTPUT,
|
|
|
+ cmLocalGenerator::UNCHANGED, true);
|
|
|
+ commandLine.push_back(argB);
|
|
|
+ commandLine.push_back("--check-stamp-list");
|
|
|
+ commandLine.push_back(stampList.c_str());
|
|
|
+ commandLine.push_back("--vs-solution-file");
|
|
|
+ commandLine.push_back("\"$(SolutionPath)\"");
|
|
|
+ cmCustomCommandLines commandLines;
|
|
|
+ commandLines.push_back(commandLine);
|
|
|
|
|
|
- // Add the rule. Note that we cannot use the CMakeLists.txt
|
|
|
- // file as the main dependency because it would get
|
|
|
- // overwritten by the CreateVCProjBuildRule.
|
|
|
- // (this could be avoided with per-target source files)
|
|
|
- const char* no_main_dependency = 0;
|
|
|
- const char* no_working_directory = 0;
|
|
|
- mf->AddCustomCommandToOutput(
|
|
|
- stampName.c_str(), listFiles,
|
|
|
- no_main_dependency, commandLines, "Checking Build System",
|
|
|
- no_working_directory, true);
|
|
|
- std::string ruleName = stampName;
|
|
|
- ruleName += ".rule";
|
|
|
- if(cmSourceFile* file = mf->GetSource(ruleName.c_str()))
|
|
|
- {
|
|
|
- tgt->AddSourceFile(file);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- cmSystemTools::Error("Error adding rule for ", stampName.c_str());
|
|
|
- }
|
|
|
+ // Add the rule. Note that we cannot use the CMakeLists.txt
|
|
|
+ // file as the main dependency because it would get
|
|
|
+ // overwritten by the CreateVCProjBuildRule.
|
|
|
+ // (this could be avoided with per-target source files)
|
|
|
+ const char* no_main_dependency = 0;
|
|
|
+ const char* no_working_directory = 0;
|
|
|
+ mf->AddCustomCommandToOutput(
|
|
|
+ stamps, listFiles,
|
|
|
+ no_main_dependency, commandLines, "Checking Build System",
|
|
|
+ no_working_directory, true);
|
|
|
+ std::string ruleName = stamps[0];
|
|
|
+ ruleName += ".rule";
|
|
|
+ if(cmSourceFile* file = mf->GetSource(ruleName.c_str()))
|
|
|
+ {
|
|
|
+ tgt->AddSourceFile(file);
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cmSystemTools::Error("Error adding rule for ", stamps[0].c_str());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|