diff options
author | Brad King <brad.king@kitware.com> | 2008-03-11 21:25:49 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-03-11 21:25:49 (GMT) |
commit | fdf169be3a9e78e55d4c87b8341c2bddfca6a57f (patch) | |
tree | 506e29f30d65bb4164d3dc6c46839bb8ec201536 /Source/cmGlobalVisualStudio8Generator.cxx | |
parent | b5cebc00f7a4ebc28a903f056fab2b0a799f1ad3 (diff) | |
download | CMake-fdf169be3a9e78e55d4c87b8341c2bddfca6a57f.zip CMake-fdf169be3a9e78e55d4c87b8341c2bddfca6a57f.tar.gz CMake-fdf169be3a9e78e55d4c87b8341c2bddfca6a57f.tar.bz2 |
BUG: Fixes to VS8/VS9 project regeneration rules
- ZERO_CHECK should check all stamps in case
of parallel build (fixes complex test failure)
- ZERO_CHECK should not appear when
CMAKE_SUPPRESS_REGENERATION is on (fixes bug 6490)
Diffstat (limited to 'Source/cmGlobalVisualStudio8Generator.cxx')
-rw-r--r-- | Source/cmGlobalVisualStudio8Generator.cxx | 150 |
1 files changed, 90 insertions, 60 deletions
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 52225aa..f88f14f 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -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()); + } + } } } |