summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGenerators.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2017-08-05 12:21:50 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2017-08-05 12:21:50 (GMT)
commit6d83757f2620413918f76de975cd38efa3157416 (patch)
tree8b42a40e7717701deea1ecf0c1b8091f65371154 /Source/cmQtAutoGenerators.cxx
parent74a1b8ebdeaca81e0654a7e40f78c36cef265025 (diff)
downloadCMake-6d83757f2620413918f76de975cd38efa3157416.zip
CMake-6d83757f2620413918f76de975cd38efa3157416.tar.gz
CMake-6d83757f2620413918f76de975cd38efa3157416.tar.bz2
Autogen: Generate rcc wrapper file on demand
For multi configuration generators remove per-config qrc_FOO_$<CONFIG>.cpp source file support. Instead use a single source file qrc_FOO.cpp which is a wrapper that includes the actual rcc generated qrc_FOO_CONFIG.cpp file. This way, after a repeated configuration change, only the wrapper file qrc_FOO.cpp must be regenerated to include the appropriate qrc_FOO_CONFIG.cpp file.
Diffstat (limited to 'Source/cmQtAutoGenerators.cxx')
-rw-r--r--Source/cmQtAutoGenerators.cxx36
1 files changed, 35 insertions, 1 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 092bd2d..bdf682a 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -1664,10 +1664,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);
@@ -1700,6 +1700,7 @@ bool cmQtAutoGenerators::RccGenerateFile(const std::string& rccInputFile,
}
}
}
+ // Regenerate on demand
if (generateRcc) {
// Log
this->LogBold("Generating RCC source " + rccOutputFile);
@@ -1755,6 +1756,39 @@ 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
+ 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;
}