summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-03-13 17:48:57 (GMT)
committerBrad King <brad.king@kitware.com>2008-03-13 17:48:57 (GMT)
commitf7f03347a64c629149803594b92c2b4b40e783fd (patch)
tree5035b672977616bb63be8f10fc2605e7dac83741 /Source/cmake.cxx
parent73df9a5cd4f6ac66ea71c073ce3e01d68c512074 (diff)
downloadCMake-f7f03347a64c629149803594b92c2b4b40e783fd.zip
CMake-f7f03347a64c629149803594b92c2b4b40e783fd.tar.gz
CMake-f7f03347a64c629149803594b92c2b4b40e783fd.tar.bz2
ENH: Improve new error/warning message generation
- Add cmListFileBacktrace to record stack traces - Move main IssueMessage method to the cmake class instance (make the backtrace an explicit argument) - Change cmMakefile::IssueMessage to construct a backtrace and call the cmake instance version - Record a backtrace at the point a target is created (useful later for messages issued by generators)
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx78
1 files changed, 78 insertions, 0 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 5f014c9..32c0911 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -28,6 +28,7 @@
#include "cmSourceFile.h"
#include "cmVersion.h"
#include "cmTest.h"
+#include "cmDocumentationFormatterText.h"
#if defined(CMAKE_BUILD_WITH_CMAKE)
# include "cmDependsFortran.h" // For -E cmake_copy_f90_mod callback.
@@ -4108,3 +4109,80 @@ int cmake::VisualStudioLinkNonIncremental(std::vector<std::string>& args,
}
return 0;
}
+
+//----------------------------------------------------------------------------
+void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
+ cmListFileBacktrace const& backtrace)
+{
+ cmOStringStream msg;
+ bool isError = false;
+ // Construct the message header.
+ if(t == cmake::FATAL_ERROR)
+ {
+ isError = true;
+ msg << "CMake Error";
+ }
+ else if(t == cmake::INTERNAL_ERROR)
+ {
+ isError = true;
+ msg << "CMake Internal Error (please report a bug)";
+ }
+ else
+ {
+ msg << "CMake Warning";
+ if(t == cmake::AUTHOR_WARNING)
+ {
+ // Allow suppression of these warnings.
+ cmCacheManager::CacheIterator it = this->CacheManager
+ ->GetCacheIterator("CMAKE_SUPPRESS_DEVELOPER_WARNINGS");
+ if(!it.IsAtEnd() && it.GetValueAsBool())
+ {
+ return;
+ }
+ msg << " (dev)";
+ }
+ }
+
+ // Add the immediate context.
+ cmListFileBacktrace::const_iterator i = backtrace.begin();
+ if(i != backtrace.end())
+ {
+ cmListFileContext const& lfc = *i;
+ msg << (lfc.Line? " at ": " in ") << lfc;
+ ++i;
+ }
+
+ // Add the message text.
+ {
+ msg << ":\n";
+ cmDocumentationFormatterText formatter;
+ formatter.SetIndent(" ");
+ formatter.PrintFormatted(msg, text.c_str());
+ }
+
+ // Add the rest of the context.
+ if(i != backtrace.end())
+ {
+ msg << "Call Stack (most recent call first):\n";
+ while(i != backtrace.end())
+ {
+ cmListFileContext const& lfc = *i;
+ msg << " " << lfc << "\n";
+ ++i;
+ }
+ }
+
+ // Add a terminating blank line.
+ msg << "\n";
+
+ // Output the message.
+ if(isError)
+ {
+ cmSystemTools::SetErrorOccured();
+ cmSystemTools::Message(msg.str().c_str(), "Error");
+ }
+ else
+ {
+ cmSystemTools::Message(msg.str().c_str(), "Warning");
+ }
+}