summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2007-11-19 18:44:51 (GMT)
committerBrad King <brad.king@kitware.com>2007-11-19 18:44:51 (GMT)
commit9f864879b4869cefea70099414634c0aed2eb547 (patch)
tree2bbf3d3f5ece0f775b8dc81783338b4aab714d42 /Source
parent13e96b14031e72a13e1e9da674bb50a05ded1200 (diff)
downloadCMake-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')
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx2
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx2
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx72
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h5
4 files changed, 56 insertions, 25 deletions
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 6c322bb..1ef34bc 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 014fcd3..55f1305 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 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, "");
}
}
}
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index 575910d..4237b97 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*) {}