summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGenerators.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmQtAutoGenerators.cxx')
-rw-r--r--Source/cmQtAutoGenerators.cxx82
1 files changed, 65 insertions, 17 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index d12d96d..1fe07ce 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -281,9 +281,11 @@ cmQtAutoGenerators::cmQtAutoGenerators()
// Moc macro filters
this->MocMacroFilters[0].first = "Q_OBJECT";
- this->MocMacroFilters[0].second.compile("[\n][ \t]*Q_OBJECT[^a-zA-Z0-9_]");
+ this->MocMacroFilters[0].second.compile(
+ "[\n][ \t]*{?[ \t]*Q_OBJECT[^a-zA-Z0-9_]");
this->MocMacroFilters[1].first = "Q_GADGET";
- this->MocMacroFilters[1].second.compile("[\n][ \t]*Q_GADGET[^a-zA-Z0-9_]");
+ this->MocMacroFilters[1].second.compile(
+ "[\n][ \t]*{?[ \t]*Q_GADGET[^a-zA-Z0-9_]");
// Precompile regular expressions
this->MocRegExpInclude.compile(
@@ -364,6 +366,9 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
return false;
}
+ // -- Meta
+ InfoGetConfig(makefile, "AM_CONFIG_SUFFIX", config, this->ConfigSuffix);
+
// - Old settings file
{
this->SettingsFile = cmSystemTools::CollapseFullPath(targetDirectory);
@@ -373,9 +378,6 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
this->SettingsFile += ".cmake";
}
- // -- Meta
- InfoGetConfig(makefile, "AM_CONFIG_SUFFIX", config, this->ConfigSuffix);
-
// - Files and directories
InfoGet(makefile, "AM_CMAKE_SOURCE_DIR", this->ProjectSourceDir);
InfoGet(makefile, "AM_CMAKE_BINARY_DIR", this->ProjectBinaryDir);
@@ -634,9 +636,7 @@ bool cmQtAutoGenerators::SettingsFileWrite()
void cmQtAutoGenerators::Init(cmMakefile* makefile)
{
// Mocs compilation file
- this->MocCompFileRel = "mocs_compilation";
- this->MocCompFileRel += this->ConfigSuffix;
- this->MocCompFileRel += ".cpp";
+ this->MocCompFileRel = "mocs_compilation.cpp";
this->MocCompFileAbs = cmSystemTools::CollapseCombinedPath(
this->AutogenBuildDir, this->MocCompFileRel);
@@ -647,7 +647,9 @@ void cmQtAutoGenerators::Init(cmMakefile* makefile)
// Moc predefs file
if (!this->MocPredefsCmd.empty()) {
- this->MocPredefsFileRel = "moc_predefs.h";
+ this->MocPredefsFileRel = "moc_predefs";
+ this->MocPredefsFileRel += this->ConfigSuffix;
+ this->MocPredefsFileRel += ".h";
this->MocPredefsFileAbs = cmSystemTools::CollapseCombinedPath(
this->AutogenBuildDir, this->MocPredefsFileRel);
}
@@ -722,10 +724,10 @@ bool cmQtAutoGenerators::RunAutogen()
// the program goes through all .cpp files to see which moc files are
// included. It is not really interesting how the moc file is named, but
// what file the moc is created from. Once a moc is included the same moc
- // may not be included in the mocs_compilation_$<CONFIG>.cpp file anymore.
+ // may not be included in the mocs_compilation.cpp file anymore.
// OTOH if there's a header containing Q_OBJECT where no corresponding
// moc file is included anywhere a moc_<filename>.cpp file is created and
- // included in the mocs_compilation_$<CONFIG>.cpp file.
+ // included in the mocs_compilation.cpp file.
// Create AUTOGEN include directory
{
@@ -1253,7 +1255,9 @@ bool cmQtAutoGenerators::MocGenerateAll(
if (!this->MocPredefsCmd.empty()) {
if (this->MocSettingsChanged ||
FileAbsentOrOlder(this->MocPredefsFileAbs, this->SettingsFile)) {
- this->LogBold("Generating MOC predefs " + this->MocPredefsFileRel);
+ if (this->Verbose) {
+ this->LogBold("Generating MOC predefs " + this->MocPredefsFileRel);
+ }
std::string output;
{
@@ -1340,7 +1344,9 @@ bool cmQtAutoGenerators::MocGenerateAll(
if (this->FileDiffers(this->MocCompFileAbs, automocSource)) {
// Actually write mocs compilation file
- this->LogBold("Generating MOC compilation " + this->MocCompFileRel);
+ if (this->Verbose) {
+ this->LogBold("Generating MOC compilation " + this->MocCompFileRel);
+ }
if (!this->FileWrite("AutoMoc", this->MocCompFileAbs, automocSource)) {
return false;
}
@@ -1391,7 +1397,9 @@ bool cmQtAutoGenerators::MocGenerateFile(
}
if (generateMoc) {
// Log
- this->LogBold("Generating MOC source " + mocFileRel);
+ if (this->Verbose) {
+ this->LogBold("Generating MOC source " + mocFileRel);
+ }
// Make sure the parent directory exists
if (this->MakeParentDirectory("AutoMoc", mocFileAbs)) {
@@ -1596,7 +1604,9 @@ bool cmQtAutoGenerators::UicGenerateFile(const std::string& realName,
}
if (generateUic) {
// Log
- this->LogBold("Generating UIC header " + uicFileRel);
+ if (this->Verbose) {
+ this->LogBold("Generating UIC header " + uicFileRel);
+ }
// Make sure the parent directory exists
if (this->MakeParentDirectory("AutoUic", uicFileAbs)) {
@@ -1702,10 +1712,10 @@ bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile,
{
bool rccGenerated = false;
bool generateRcc = this->RccSettingsChanged;
-
const std::string rccBuildFile =
cmSystemTools::CollapseCombinedPath(this->AutogenBuildDir, rccOutputFile);
+ // Check if regeneration is required
if (!generateRcc) {
// Test if the resources list file is newer than build file
generateRcc = FileAbsentOrOlder(rccBuildFile, rccInputFile);
@@ -1738,9 +1748,12 @@ bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile,
}
}
}
+ // Regenerate on demand
if (generateRcc) {
// Log
- this->LogBold("Generating RCC source " + rccOutputFile);
+ if (this->Verbose) {
+ this->LogBold("Generating RCC source " + rccOutputFile);
+ }
// Make sure the parent directory exists
if (this->MakeParentDirectory("AutoRcc", rccBuildFile)) {
@@ -1793,6 +1806,41 @@ bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile,
this->RccRunFailed = true;
}
}
+ // For a multi configuration generator generate a wrapper file
+ if (!this->ConfigSuffix.empty() && !this->RccRunFailed) {
+ // Wrapper file name
+ const std::string cppSuffix = ".cpp";
+ const size_t suffixLength = this->ConfigSuffix.size() + cppSuffix.size();
+ const std::string wrapperFileRel =
+ rccOutputFile.substr(0, rccOutputFile.size() - suffixLength) + cppSuffix;
+ const std::string wrapperFileAbs = cmSystemTools::CollapseCombinedPath(
+ this->AutogenBuildDir, wrapperFileRel);
+ // Wrapper file content
+ std::string content =
+ "// This is an autogenerated configuration wrapper file. Do not edit.\n"
+ "#include \"";
+ content += cmsys::SystemTools::GetFilenameName(rccBuildFile);
+ content += "\"\n";
+ // Write content to file
+ if (this->FileDiffers(wrapperFileAbs, content)) {
+ // Write new wrapper file if the content differs
+ if (this->Verbose) {
+ this->LogBold("Generating RCC wrapper " + wrapperFileRel);
+ }
+ if (!this->FileWrite("AutoRcc", wrapperFileAbs, content)) {
+ // Error
+ rccGenerated = false;
+ this->RccRunFailed = true;
+ }
+ } else if (rccGenerated) {
+ // Only touch wrapper file if the content matches
+ if (this->Verbose) {
+ this->LogInfo("Touching RCC wrapper " + wrapperFileRel);
+ }
+ cmSystemTools::Touch(wrapperFileAbs, false);
+ }
+ }
+
return rccGenerated;
}