|
|
@@ -36,6 +36,25 @@ static const char* SettingsKeyRcc = "AM_RCC_OLD_SETTINGS";
|
|
|
|
|
|
// -- Static functions
|
|
|
|
|
|
+/**
|
|
|
+ * @brief Returns a the string escaped and enclosed in quotes
|
|
|
+ */
|
|
|
+static std::string Quoted(const std::string& text)
|
|
|
+{
|
|
|
+ static const char* rep[18] = { "\\", "\\\\", "\"", "\\\"", "\a", "\\a",
|
|
|
+ "\b", "\\b", "\f", "\\f", "\n", "\\n",
|
|
|
+ "\r", "\\r", "\t", "\\t", "\v", "\\v" };
|
|
|
+
|
|
|
+ std::string res = text;
|
|
|
+ for (const char* const* it = cmArrayBegin(rep); it != cmArrayEnd(rep);
|
|
|
+ it += 2) {
|
|
|
+ cmSystemTools::ReplaceString(res, *it, *(it + 1));
|
|
|
+ }
|
|
|
+ res = '"' + res;
|
|
|
+ res += '"';
|
|
|
+ return res;
|
|
|
+}
|
|
|
+
|
|
|
static std::string GetConfigDefinition(cmMakefile* makefile,
|
|
|
const std::string& key,
|
|
|
const std::string& config)
|
|
|
@@ -273,8 +292,8 @@ bool cmQtAutoGenerators::MocDependFilterPush(const std::string& key,
|
|
|
success = true;
|
|
|
} else {
|
|
|
this->LogError("AutoMoc: Error in AUTOMOC_DEPEND_FILTERS: Compiling "
|
|
|
- "regular expression failed.\nKey: \"" +
|
|
|
- key + "\"\nReg. exp.: \"" + regExp + "\"");
|
|
|
+ "regular expression failed.\nKey: " +
|
|
|
+ Quoted(key) + "\nExp.: " + Quoted(regExp));
|
|
|
}
|
|
|
} else {
|
|
|
this->LogError("AutoMoc: Error in AUTOMOC_DEPEND_FILTERS: Regular "
|
|
|
@@ -320,8 +339,8 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
|
|
|
}
|
|
|
// Check Qt version
|
|
|
if ((this->QtMajorVersion != "4") && (this->QtMajorVersion != "5")) {
|
|
|
- this->LogError("AutoGen: Error: Unsupported Qt version: \"" +
|
|
|
- this->QtMajorVersion + "\"");
|
|
|
+ this->LogError("AutoGen: Error: Unsupported Qt version: " +
|
|
|
+ Quoted(this->QtMajorVersion));
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -719,13 +738,13 @@ void cmQtAutoGenerators::MocFindDepends(
|
|
|
if (!incFile.empty()) {
|
|
|
mocDepends[absFilename].insert(incFile);
|
|
|
if (this->Verbose) {
|
|
|
- this->LogInfo("AutoMoc: Found dependency:\n \"" + absFilename +
|
|
|
- "\"\n \"" + incFile + "\"");
|
|
|
+ this->LogInfo("AutoMoc: Found dependency:\n " +
|
|
|
+ Quoted(absFilename) + "\n " + Quoted(incFile));
|
|
|
}
|
|
|
} else {
|
|
|
- this->LogWarning("AutoMoc: Warning: \"" + absFilename + "\"\n" +
|
|
|
- "Could not find dependency file \"" + match +
|
|
|
- "\"");
|
|
|
+ this->LogWarning("AutoMoc: Warning: " + Quoted(absFilename) +
|
|
|
+ "\n" + "Could not find dependency file " +
|
|
|
+ Quoted(match));
|
|
|
}
|
|
|
}
|
|
|
contentChars += filter.regExp.end();
|
|
|
@@ -878,9 +897,11 @@ bool cmQtAutoGenerators::MocParseSourceContent(
|
|
|
} else {
|
|
|
std::ostringstream ost;
|
|
|
ost << "AutoMoc: Error: " << absFilename << "\n"
|
|
|
- << "The file includes the moc file \"" << incString
|
|
|
- << "\", but could not find header \"" << incRealBasename << '{'
|
|
|
- << JoinExts(this->HeaderExtensions) << "}\"\n";
|
|
|
+ << "The file includes the moc file " << Quoted(incString)
|
|
|
+ << ", but could not find header "
|
|
|
+ << Quoted(incRealBasename + "{" +
|
|
|
+ JoinExts(this->HeaderExtensions) + "}");
|
|
|
+ ;
|
|
|
this->LogError(ost.str());
|
|
|
return false;
|
|
|
}
|
|
|
@@ -902,32 +923,33 @@ bool cmQtAutoGenerators::MocParseSourceContent(
|
|
|
fileToMoc = headerToMoc;
|
|
|
if (!requiresMoc && (incBasename == scannedFileBasename)) {
|
|
|
std::ostringstream ost;
|
|
|
- ost << "AutoMoc: Warning: " << absFilename << "\n"
|
|
|
- << "The file includes the moc file \"" << incString << "\""
|
|
|
+ ost << "AutoMoc: Warning: " << Quoted(absFilename) << "\n"
|
|
|
+ << "The file includes the moc file " << Quoted(incString)
|
|
|
<< ", but does not contain a Q_OBJECT or Q_GADGET macro.\n"
|
|
|
- << "Running moc on \"" << headerToMoc << "\"!\n"
|
|
|
- << "Include \"moc_" << incBasename
|
|
|
- << ".cpp\" for a compatibility with "
|
|
|
- "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n";
|
|
|
+ << "Running moc on " << Quoted(headerToMoc) << "!\n"
|
|
|
+ << "Include " << Quoted("moc_" + incBasename + ".cpp")
|
|
|
+ << " for a compatibility with strict mode (see "
|
|
|
+ "CMAKE_AUTOMOC_RELAXED_MODE).\n";
|
|
|
this->LogWarning(ost.str());
|
|
|
} else {
|
|
|
std::ostringstream ost;
|
|
|
- ost << "AutoMoc: Warning: " << absFilename << "\n"
|
|
|
- << "The file includes the moc file \"" << incString
|
|
|
- << "\" instead of \"moc_" << incBasename << ".cpp\".\n"
|
|
|
- << "Running moc on \"" << headerToMoc << "\"!\n"
|
|
|
- << "Include \"moc_" << incBasename
|
|
|
- << ".cpp\" for compatibility with "
|
|
|
- "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n";
|
|
|
+ ost << "AutoMoc: Warning: " << Quoted(absFilename) << "\n"
|
|
|
+ << "The file includes the moc file " << Quoted(incString)
|
|
|
+ << " instead of " << Quoted("moc_" + incBasename + ".cpp")
|
|
|
+ << ".\n"
|
|
|
+ << "Running moc on " << Quoted(headerToMoc) << "!\n"
|
|
|
+ << "Include " << Quoted("moc_" + incBasename + ".cpp")
|
|
|
+ << " for compatibility with strict mode (see "
|
|
|
+ "CMAKE_AUTOMOC_RELAXED_MODE).\n";
|
|
|
this->LogWarning(ost.str());
|
|
|
}
|
|
|
} else {
|
|
|
std::ostringstream ost;
|
|
|
- ost << "AutoMoc: Error: " << absFilename << "\n"
|
|
|
- << "The file includes the moc file \"" << incString
|
|
|
- << "\", which seems to be the moc file from a different "
|
|
|
+ ost << "AutoMoc: Error: " << Quoted(absFilename) << "\n"
|
|
|
+ << "The file includes the moc file " << Quoted(incString)
|
|
|
+ << ". which seems to be the moc file from a different "
|
|
|
"source file. CMake also could not find a matching "
|
|
|
- "header.\n";
|
|
|
+ "header.";
|
|
|
this->LogError(ost.str());
|
|
|
return false;
|
|
|
}
|
|
|
@@ -941,21 +963,21 @@ bool cmQtAutoGenerators::MocParseSourceContent(
|
|
|
// Accept but issue a warning if moc isn't required
|
|
|
if (!requiresMoc) {
|
|
|
std::ostringstream ost;
|
|
|
- ost << "AutoMoc: Error: " << absFilename << "\n"
|
|
|
- << "The file includes the moc file \"" << incString << "\""
|
|
|
+ ost << "AutoMoc: Error: " << Quoted(absFilename) << "\n"
|
|
|
+ << "The file includes the moc file " << Quoted(incString)
|
|
|
<< ", but does not contain a Q_OBJECT or Q_GADGET "
|
|
|
- "macro.\n";
|
|
|
+ "macro.";
|
|
|
this->LogWarning(ost.str());
|
|
|
}
|
|
|
} else {
|
|
|
// Don't allow FOO.moc include other than self in strict mode
|
|
|
std::ostringstream ost;
|
|
|
- ost << "AutoMoc: Error: " << absFilename << "\n"
|
|
|
- << "The file includes the moc file \"" << incString
|
|
|
- << "\", which seems to be the moc file from a different "
|
|
|
- "source file. This is not supported. Include \""
|
|
|
- << scannedFileBasename
|
|
|
- << ".moc\" to run moc on this source file.\n";
|
|
|
+ ost << "AutoMoc: Error: " << Quoted(absFilename) << "\n"
|
|
|
+ << "The file includes the moc file " << Quoted(incString)
|
|
|
+ << ", which seems to be the moc file from a different "
|
|
|
+ "source file. This is not supported. Include "
|
|
|
+ << Quoted(scannedFileBasename + ".moc")
|
|
|
+ << " to run moc on this source file.";
|
|
|
this->LogError(ost.str());
|
|
|
return false;
|
|
|
}
|
|
|
@@ -978,15 +1000,15 @@ bool cmQtAutoGenerators::MocParseSourceContent(
|
|
|
if (relaxed && !ownMocUnderscoreInclude.empty()) {
|
|
|
// This is for KDE4 compatibility:
|
|
|
std::ostringstream ost;
|
|
|
- ost << "AutoMoc: Warning: " << absFilename << "\n"
|
|
|
+ ost << "AutoMoc: Warning: " << Quoted(absFilename) << "\n"
|
|
|
<< "The file contains a " << macroName
|
|
|
<< " macro, but does not include "
|
|
|
- << "\"" << scannedFileBasename << ".moc\", but instead includes "
|
|
|
- << "\"" << ownMocUnderscoreInclude << "\".\n"
|
|
|
- << "Running moc on \"" << absFilename << "\"!\n"
|
|
|
- << "Better include \"" << scannedFileBasename
|
|
|
- << ".moc\" for compatibility with "
|
|
|
- "strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n";
|
|
|
+ << Quoted(scannedFileBasename + ".moc") << ", but instead includes "
|
|
|
+ << Quoted(ownMocUnderscoreInclude) << ".\n"
|
|
|
+ << "Running moc on " << Quoted(absFilename) << "!\n"
|
|
|
+ << "Better include " << Quoted(scannedFileBasename + ".moc")
|
|
|
+ << " for compatibility with strict mode (see "
|
|
|
+ "CMAKE_AUTOMOC_RELAXED_MODE).";
|
|
|
this->LogWarning(ost.str());
|
|
|
|
|
|
// Use scanned source file instead of scanned header file as moc source
|
|
|
@@ -997,10 +1019,10 @@ bool cmQtAutoGenerators::MocParseSourceContent(
|
|
|
} else {
|
|
|
// Otherwise always error out since it will not compile:
|
|
|
std::ostringstream ost;
|
|
|
- ost << "AutoMoc: Error: " << absFilename << "\n"
|
|
|
+ ost << "AutoMoc: Error: " << Quoted(absFilename) << "\n"
|
|
|
<< "The file contains a " << macroName
|
|
|
<< " macro, but does not include "
|
|
|
- << "\"" << scannedFileBasename << ".moc\"!\n";
|
|
|
+ << Quoted(scannedFileBasename + ".moc") << "!";
|
|
|
this->LogError(ost.str());
|
|
|
return false;
|
|
|
}
|
|
|
@@ -1280,7 +1302,7 @@ bool cmQtAutoGenerators::MocGenerateFile(
|
|
|
{
|
|
|
std::ostringstream ost;
|
|
|
ost << "AutoMoc: Error: moc process failed for\n";
|
|
|
- ost << "\"" << mocFileRel << "\"\n";
|
|
|
+ ost << Quoted(mocFileRel) << "\n";
|
|
|
ost << "AutoMoc: Command:\n" << cmJoin(cmd, " ") << "\n";
|
|
|
ost << "AutoMoc: Command output:\n" << output << "\n";
|
|
|
this->LogError(ost.str());
|
|
|
@@ -1419,8 +1441,8 @@ bool cmQtAutoGenerators::UicGenerateFile(const std::string& realName,
|
|
|
{
|
|
|
std::ostringstream ost;
|
|
|
ost << "AutoUic: Error: uic process failed for\n";
|
|
|
- ost << "\"" << uicFileRel << "\" needed by\n";
|
|
|
- ost << "\"" << realName << "\"\n";
|
|
|
+ ost << Quoted(uicFileRel) << " needed by\n";
|
|
|
+ ost << Quoted(realName) << "\n";
|
|
|
ost << "AutoUic: Command:\n" << cmJoin(cmd, " ") << "\n";
|
|
|
ost << "AutoUic: Command output:\n" << output << "\n";
|
|
|
this->LogError(ost.str());
|
|
|
@@ -1558,7 +1580,7 @@ bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile,
|
|
|
{
|
|
|
std::ostringstream ost;
|
|
|
ost << "AutoRcc: Error: rcc process failed for\n";
|
|
|
- ost << "\"" << rccOutputFile << "\"\n";
|
|
|
+ ost << Quoted(rccOutputFile) << "\n";
|
|
|
ost << "AutoRcc: Command:\n" << cmJoin(cmd, " ") << "\n";
|
|
|
ost << "AutoRcc: Command output:\n" << output << "\n";
|
|
|
this->LogError(ost.str());
|