diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 6c322bbfa..1ef34bc35 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -224,7 +224,7 @@ void cmGlobalVisualStudio7Generator::Generate() // tell Visual Studio to reload them... if(!cmSystemTools::GetErrorOccuredFlag()) { - this->CallVisualStudioReloadMacro(); + this->CallVisualStudioMacro(MacroReload); } } diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 014fcd332..55f130523 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -169,6 +169,8 @@ void cmGlobalVisualStudio8Generator::Generate() 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); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index e424c2bcc..66f771f89 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -79,6 +79,9 @@ void RegisterVisualStudioMacros(const std::string& macrosFile); #define CMAKE_VSMACROS_RELOAD_MACRONAME \ "Macros.CMakeVSMacros1.Macros.ReloadProjects" +#define CMAKE_VSMACROS_STOP_MACRONAME \ + "Macros.CMakeVSMacros1.Macros.StopBuild" + //---------------------------------------------------------------------------- void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros() { @@ -92,9 +95,14 @@ void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros() std::string dst = dir + "/CMakeMacros/" CMAKE_VSMACROS_FILENAME; - // Only copy if dst does not already exist. Write this file initially, - // but never overwrite local mods. - if (!cmSystemTools::FileExists(dst.c_str())) + // Copy the macros file to the user directory only if the + // destination does not exist or the source location is newer. + // This will allow the user to edit the macros for development + // purposes but newer versions distributed with CMake will replace + // older versions in user directories. + int res; + if(!cmSystemTools::FileTimeCompare(src.c_str(), dst.c_str(), &res) || + res > 0) { if (!cmSystemTools::CopyFileAlways(src.c_str(), dst.c_str())) { @@ -110,7 +118,10 @@ void cmGlobalVisualStudioGenerator::ConfigureCMakeVisualStudioMacros() } //---------------------------------------------------------------------------- -void cmGlobalVisualStudioGenerator::CallVisualStudioReloadMacro() +void +cmGlobalVisualStudioGenerator +::CallVisualStudioMacro(MacroName m, + const char* vsSolutionFile) { // If any solution or project files changed during the generation, // tell Visual Studio to reload them... @@ -132,31 +143,46 @@ void cmGlobalVisualStudioGenerator::CallVisualStudioReloadMacro() IsVisualStudioMacrosFileRegistered(macrosFile, nextSubkeyName) ) { - std::vector filenames; - this->GetFilesReplacedDuringGenerate(filenames); - if (filenames.size() > 0) + std::string topLevelSlnName; + if(vsSolutionFile) { - // Convert vector to semi-colon delimited string of filenames: - std::string projects; - std::vector::iterator it = filenames.begin(); - if (it != filenames.end()) - { - projects = *it; - ++it; - } - for (; it != filenames.end(); ++it) - { - projects += ";"; - projects += *it; - } - - std::string topLevelSlnName = mf->GetStartOutputDirectory(); + topLevelSlnName = vsSolutionFile; + } + else + { + topLevelSlnName = mf->GetStartOutputDirectory(); topLevelSlnName += "/"; topLevelSlnName += mf->GetProjectName(); topLevelSlnName += ".sln"; + } + if(m == MacroReload) + { + std::vector filenames; + this->GetFilesReplacedDuringGenerate(filenames); + if (filenames.size() > 0) + { + // Convert vector to semi-colon delimited string of filenames: + std::string projects; + std::vector::iterator it = filenames.begin(); + if (it != filenames.end()) + { + projects = *it; + ++it; + } + for (; it != filenames.end(); ++it) + { + projects += ";"; + projects += *it; + } + cmCallVisualStudioMacro::CallMacro + (topLevelSlnName, CMAKE_VSMACROS_RELOAD_MACRONAME, projects); + } + } + else if(m == MacroStop) + { cmCallVisualStudioMacro::CallMacro(topLevelSlnName, - CMAKE_VSMACROS_RELOAD_MACRONAME, projects); + CMAKE_VSMACROS_STOP_MACRONAME, ""); } } } diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 575910ded..4237b9767 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -49,11 +49,14 @@ public: */ virtual std::string GetUserMacrosDirectory(); + enum MacroName {MacroReload, MacroStop}; + /** * Call the ReloadProjects macro if necessary based on * GetFilesReplacedDuringGenerate results. */ - virtual void CallVisualStudioReloadMacro(); + virtual void CallVisualStudioMacro(MacroName m, + const char* vsSolutionFile = 0); protected: virtual void CreateGUID(const char*) {}