diff options
-rw-r--r-- | Source/cmCallVisualStudioMacro.cxx | 42 | ||||
-rw-r--r-- | Source/cmCallVisualStudioMacro.h | 3 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioGenerator.cxx | 8 | ||||
-rw-r--r-- | Source/cmake.cxx | 5 |
4 files changed, 39 insertions, 19 deletions
diff --git a/Source/cmCallVisualStudioMacro.cxx b/Source/cmCallVisualStudioMacro.cxx index 2476631..2aefd20 100644 --- a/Source/cmCallVisualStudioMacro.cxx +++ b/Source/cmCallVisualStudioMacro.cxx @@ -24,6 +24,11 @@ #endif +// Just for this file: +// +static bool LogErrorsAsMessages; + + #if defined(HAVE_COMDEF_H) @@ -31,17 +36,20 @@ //---------------------------------------------------------------------------- -///! Use ReportHRESULT to make a cmSystemTools::Error after calling +///! Use ReportHRESULT to make a cmSystemTools::Message after calling ///! a COM method that may have failed. #define ReportHRESULT(hr, context) \ if (FAILED(hr)) \ { \ - std::ostringstream oss; \ - oss.flags(std::ios::hex); \ - oss << context << " failed HRESULT, hr = 0x" << hr << std::endl; \ - oss.flags(std::ios::dec); \ - oss << __FILE__ << "(" << __LINE__ << ")"; \ - cmSystemTools::Error(oss.str().c_str()); \ + if (LogErrorsAsMessages) \ + { \ + std::ostringstream oss; \ + oss.flags(std::ios::hex); \ + oss << context << " failed HRESULT, hr = 0x" << hr << std::endl; \ + oss.flags(std::ios::dec); \ + oss << __FILE__ << "(" << __LINE__ << ")"; \ + cmSystemTools::Message(oss.str().c_str()); \ + } \ } @@ -404,6 +412,8 @@ int cmCallVisualStudioMacro::GetNumberOfRunningVisualStudioInstances( { int count = 0; + LogErrorsAsMessages = false; + #if defined(HAVE_COMDEF_H) HRESULT hr = CoInitialize(0); ReportHRESULT(hr, "CoInitialize"); @@ -438,10 +448,13 @@ int cmCallVisualStudioMacro::GetNumberOfRunningVisualStudioInstances( int cmCallVisualStudioMacro::CallMacro( const std::string& slnFile, const std::string& macro, - const std::string& args) + const std::string& args, + const bool logErrorsAsMessages) { int err = 1; // no comdef.h + LogErrorsAsMessages = logErrorsAsMessages; + #if defined(HAVE_COMDEF_H) err = 2; // error initializing @@ -489,16 +502,19 @@ int cmCallVisualStudioMacro::CallMacro( (void)slnFile; (void)macro; (void)args; - cmSystemTools::Error("cmCallVisualStudioMacro::CallMacro is not " - "supported on this platform"); + if (LogErrorsAsMessages) + { + cmSystemTools::Message("cmCallVisualStudioMacro::CallMacro is not " + "supported on this platform"); + } #endif - if (err) + if (err && LogErrorsAsMessages) { std::ostringstream oss; oss << "cmCallVisualStudioMacro::CallMacro failed, err = " << err; - cmSystemTools::Error(oss.str().c_str()); + cmSystemTools::Message(oss.str().c_str()); } - return err; + return 0; } diff --git a/Source/cmCallVisualStudioMacro.h b/Source/cmCallVisualStudioMacro.h index ea3cc10..44f6e55 100644 --- a/Source/cmCallVisualStudioMacro.h +++ b/Source/cmCallVisualStudioMacro.h @@ -33,7 +33,8 @@ public: ///! macro in each Visual Studio instance. static int CallMacro(const std::string& slnFile, const std::string& macro, - const std::string& args); + const std::string& args, + const bool logErrorsAsMessages); ///! Count the number of running instances of Visual Studio with the ///! given solution file open. Pass "ALL" for slnFile to count all diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index e28b293..4e1b851 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -178,14 +178,16 @@ cmGlobalVisualStudioGenerator projects += ";"; projects += *it; } - cmCallVisualStudioMacro::CallMacro - (topLevelSlnName, CMAKE_VSMACROS_RELOAD_MACRONAME, projects); + cmCallVisualStudioMacro::CallMacro(topLevelSlnName, + CMAKE_VSMACROS_RELOAD_MACRONAME, projects, + this->GetCMakeInstance()->GetDebugOutput()); } } else if(m == MacroStop) { cmCallVisualStudioMacro::CallMacro(topLevelSlnName, - CMAKE_VSMACROS_STOP_MACRONAME, ""); + CMAKE_VSMACROS_STOP_MACRONAME, "", + this->GetCMakeInstance()->GetDebugOutput()); } } } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index e9ccf06..df95155 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1181,7 +1181,7 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) << " s. (clock)" << "\n"; return 0; - } + } // Command to calculate the md5sum of a file else if (args[1] == "md5sum" && args.size() >= 3) @@ -1422,7 +1422,8 @@ int cmake::ExecuteCMakeCommand(std::vector<std::string>& args) } } - return cmCallVisualStudioMacro::CallMacro(args[2], args[3], macroArgs); + return cmCallVisualStudioMacro::CallMacro(args[2], args[3], + macroArgs, true); } #endif |