summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-03-07 21:01:22 (GMT)
committerBrad King <brad.king@kitware.com>2008-03-07 21:01:22 (GMT)
commitd4f66dfa327bc97e4e1655a027a9c3ff5e6c519c (patch)
tree2c2a7fe2679bf45a378bfb7cbbf4c06ca31c6806 /Source
parent5233b75a777b0f3379408291e6f32b0eb15c2f54 (diff)
downloadCMake-d4f66dfa327bc97e4e1655a027a9c3ff5e6c519c.zip
CMake-d4f66dfa327bc97e4e1655a027a9c3ff5e6c519c.tar.gz
CMake-d4f66dfa327bc97e4e1655a027a9c3ff5e6c519c.tar.bz2
ENH: In cmMakefile::IssueMessage use cmDocumentationFormatterText to format the message nicely.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmDocumentationFormatterText.cxx2
-rw-r--r--Source/cmMakefile.cxx39
2 files changed, 10 insertions, 31 deletions
diff --git a/Source/cmDocumentationFormatterText.cxx b/Source/cmDocumentationFormatterText.cxx
index ca22166..b45abf8 100644
--- a/Source/cmDocumentationFormatterText.cxx
+++ b/Source/cmDocumentationFormatterText.cxx
@@ -69,7 +69,7 @@ void cmDocumentationFormatterText::PrintPreformatted(std::ostream& os,
bool newline = true;
for(const char* ptr = text; *ptr; ++ptr)
{
- if(newline)
+ if(newline && *ptr != '\n')
{
os << this->TextIndent;
newline = false;
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index aaea0de..9990302 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -35,6 +35,8 @@
#include "cmake.h"
#include <stdlib.h> // required for atoi
+#include "cmDocumentationFormatterText.h"
+
#include <cmsys/RegularExpression.hxx>
#include <cmsys/auto_ptr.hxx>
@@ -281,32 +283,6 @@ bool cmMakefile::CommandExists(const char* name) const
}
//----------------------------------------------------------------------------
-// Helper function to print a block of text with every line following
-// a given prefix.
-void cmMakefilePrintPrefixed(std::ostream& os, const char* prefix,
- std::string const& msg)
-{
- bool newline = true;
- for(const char* c = msg.c_str(); *c; ++c)
- {
- if(newline && *c != '\n')
- {
- os << prefix;
- newline = false;
- }
- os << *c;
- if(*c == '\n')
- {
- newline = true;
- }
- }
- if(!newline)
- {
- os << "\n";
- }
-}
-
-//----------------------------------------------------------------------------
void cmMakefile::IssueError(std::string const& msg) const
{
this->IssueMessage(msg, true);
@@ -351,9 +327,13 @@ void cmMakefile::IssueMessage(std::string const& text, bool isError) const
}
// Add the message text.
+ {
msg << " {\n";
- cmMakefilePrintPrefixed(msg, " ", text);
+ cmDocumentationFormatterText formatter;
+ formatter.SetIndent(" ");
+ formatter.PrintFormatted(msg, text.c_str());
msg << "}";
+ }
// Add the rest of the context.
if(i != this->CallStack.rend())
@@ -3303,7 +3283,7 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
default: break;
}
e << "created in source directory \""
- << existing->GetMakefile()->GetCurrentDirectory() << "\".\n"
+ << existing->GetMakefile()->GetCurrentDirectory() << "\"."
<< "\n";
e <<
"Logical target names must be globally unique because:\n"
@@ -3316,7 +3296,7 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
"Consider using the OUTPUT_NAME target property to create two "
"targets with the same physical name while keeping logical "
"names distinct. "
- "Custom targets must simply have globally unique names.\n"
+ "Custom targets must simply have globally unique names."
"\n"
"If you are building an older project it is possible that "
"it violated this rule but was working accidentally because "
@@ -3324,7 +3304,6 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
if(isCustom && existing->GetType() == cmTarget::UTILITY)
{
e <<
- "\n"
"For projects that care only about Makefile generators and do "
"not wish to support Xcode or VS IDE generators, one may add\n"
" set_property(GLOBAL PROPERTY ALLOW_DUPLICATE_CUSTOM_TARGETS 1)\n"