diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalVisualStudio7Generator.cxx | 12 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio7Generator.h | 2 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio8Generator.cxx | 125 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio8Generator.h | 8 | ||||
-rw-r--r-- | Source/cmLocalVisualStudio7Generator.cxx | 3 |
5 files changed, 149 insertions, 1 deletions
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 8a9888b..e2d8d6b 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -274,6 +274,7 @@ void cmGlobalVisualStudio7Generator::WriteSLNFile(std::ostream& fout, std::string rootdir = root->GetMakefile()->GetStartOutputDirectory(); rootdir += "/"; bool doneAllBuild = false; + bool doneCheckBuild = false; bool doneRunTests = false; bool doneInstall = false; @@ -363,6 +364,17 @@ void cmGlobalVisualStudio7Generator::WriteSLNFile(std::ostream& fout, doneAllBuild = true; } } + if(l->first == CMAKE_CHECK_BUILD_SYSTEM_TARGET) + { + if(doneCheckBuild) + { + skip = true; + } + else + { + doneCheckBuild = true; + } + } if(l->first == "INSTALL") { if(doneInstall) diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 39f554c..8141370 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -104,4 +104,6 @@ protected: std::map<cmStdString, cmStdString> m_GUIDMap; }; +#define CMAKE_CHECK_BUILD_SYSTEM_TARGET "ZeroTargetCheck" + #endif diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index eb87b1c..be0f1a2 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -53,3 +53,128 @@ void cmGlobalVisualStudio8Generator::GetDocumentation(cmDocumentationEntry& entr entry.brief = "Generates Visual Studio .NET 2005 project files."; entry.full = ""; } + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio8Generator::Configure() +{ + this->cmGlobalVisualStudio7Generator::Configure(); + this->CreateGUID(CMAKE_CHECK_BUILD_SYSTEM_TARGET); +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio8Generator::Generate() +{ + // Add a special target on which all other targets depend that + // checks the build system and optionally re-runs CMake. + const char* no_output = 0; + std::vector<std::string> no_depends; + std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it; + for(it = m_ProjectMap.begin(); it!= m_ProjectMap.end(); ++it) + { + std::vector<cmLocalGenerator*>& generators = it->second; + if(!generators.empty()) + { + // Add the build-system check target to the first local + // generator of this project. + cmLocalVisualStudio7Generator* lg = + static_cast<cmLocalVisualStudio7Generator*>(generators[0]); + cmMakefile* mf = lg->GetMakefile(); + std::string cmake_command = mf->GetRequiredDefinition("CMAKE_COMMAND"); + mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, true, + no_output, no_depends, + "echo", "Checking build system"); + + // 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) + { + 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. + 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::SHELL, true); + commandLine.push_back(argH); + std::string argB = "-B"; + argB += lg->Convert(mf->GetHomeOutputDirectory(), + cmLocalGenerator::START_OUTPUT, + cmLocalGenerator::SHELL, true); + commandLine.push_back(argB); + 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 AddVCProjBuildRule of the ALL_BUILD + // target. + const char* no_comment = 0; + const char* no_main_dependency = 0; + mf->AddCustomCommandToOutput( + CMAKE_CHECK_BUILD_SYSTEM_TARGET ".vcproj.cmake", listFiles, + no_main_dependency, commandLines, no_comment, true); + } + } + } + + // Now perform the main generation. + this->cmGlobalVisualStudio7Generator::Generate(); +} + +//---------------------------------------------------------------------------- +void cmGlobalVisualStudio8Generator::WriteSLNFile( + std::ostream& fout, cmLocalGenerator* root, + std::vector<cmLocalGenerator*>& generators) +{ + // Make all targets depend on their respective project's build + // system check target. + unsigned int i; + for(i = 0; i < generators.size(); ++i) + { + if(this->IsExcluded(root, generators[i])) + { + continue; + } + cmMakefile* mf = generators[i]->GetMakefile(); + std::vector<std::string> dspnames = + static_cast<cmLocalVisualStudio7Generator*>(generators[i]) + ->GetCreatedProjectNames(); + cmTargets &tgts = generators[i]->GetMakefile()->GetTargets(); + for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l) + { + if(l->first == CMAKE_CHECK_BUILD_SYSTEM_TARGET) + { + for(unsigned int j = 0; j < generators.size(); ++j) + { + // Every target in all generators should depend on this target. + cmMakefile* lmf = generators[j]->GetMakefile(); + cmTargets &atgts = lmf->GetTargets(); + for(cmTargets::iterator al = atgts.begin(); al != atgts.end(); ++al) + { + al->second.AddUtility(l->first.c_str()); + } + } + } + } + } + + // Now write the solution file. + this->cmGlobalVisualStudio7Generator::WriteSLNFile(fout, root, generators); +} diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 07a359a..85ff7dd 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -42,7 +42,15 @@ public: ///! Create a local generator appropriate to this Global Generator virtual cmLocalGenerator *CreateLocalGenerator(); + /** + * Override Configure and Generate to add the build-system check + * target. + */ + virtual void Configure(); + virtual void Generate(); protected: + virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root, + std::vector<cmLocalGenerator*>& generators); virtual void WriteSLNHeader(std::ostream& fout); }; #endif diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 83c3497..bc39e53 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -959,7 +959,8 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout, // if we should add regen rule then... const char *suppRegenRule = m_Makefile->GetDefinition("CMAKE_SUPPRESS_REGENERATION"); - if (!cmSystemTools::IsOn(suppRegenRule)) + if (!cmSystemTools::IsOn(suppRegenRule) && + (strcmp(libName, CMAKE_CHECK_BUILD_SYSTEM_TARGET) != 0)) { this->AddVCProjBuildRule(); } |