BUG: Fix issue #7088 - do not emit error messages when attempts to run Visual Studio macros fail. You can still get the error output as messages if you want using --debug-output from the cmake command line.
This commit is contained in:
parent
beeebcdc40
commit
17452105cd
|
@ -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)) \
|
||||
{ \
|
||||
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::Error(oss.str().c_str()); \
|
||||
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 "
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue