Commit d4f66dfa authored by Brad King's avatar Brad King
Browse files

ENH: In cmMakefile::IssueMessage use cmDocumentationFormatterText to format the message nicely.

parent 5233b75a
......@@ -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;
......
......@@ -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>
......@@ -280,32 +282,6 @@ bool cmMakefile::CommandExists(const char* name) const
return this->GetCMakeInstance()->CommandExists(name);
}
//----------------------------------------------------------------------------
// 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
{
......@@ -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"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment