diff options
author | Brad King <brad.king@kitware.com> | 2007-11-19 18:44:51 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2007-11-19 18:44:51 (GMT) |
commit | 9f864879b4869cefea70099414634c0aed2eb547 (patch) | |
tree | 2bbf3d3f5ece0f775b8dc81783338b4aab714d42 /Source/cmGlobalVisualStudioGenerator.cxx | |
parent | 13e96b14031e72a13e1e9da674bb50a05ded1200 (diff) | |
download | CMake-9f864879b4869cefea70099414634c0aed2eb547.zip CMake-9f864879b4869cefea70099414634c0aed2eb547.tar.gz CMake-9f864879b4869cefea70099414634c0aed2eb547.tar.bz2 |
ENH: Renamed cmGlobalVisualStudioGenerator::CallVisualStudioReloadMacro method to CallVisualStudioMacro and added arguments to select which macro to call and optionally pass the solution file name. Added option to call to new StopBuild macro. Updated logic for replacing the macro file in user directories when the distributed version is newer.
Diffstat (limited to 'Source/cmGlobalVisualStudioGenerator.cxx')
-rw-r--r-- | Source/cmGlobalVisualStudioGenerator.cxx | 72 |
1 files changed, 49 insertions, 23 deletions
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index e424c2b..66f771f 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<std::string> 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<std::string>::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<std::string> filenames; + this->GetFilesReplacedDuringGenerate(filenames); + if (filenames.size() > 0) + { + // Convert vector to semi-colon delimited string of filenames: + std::string projects; + std::vector<std::string>::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, ""); } } } |