diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2017-08-05 12:21:50 (GMT) |
---|---|---|
committer | Sebastian Holtermann <sebholt@xwmw.org> | 2017-08-05 12:21:50 (GMT) |
commit | 6d83757f2620413918f76de975cd38efa3157416 (patch) | |
tree | 8b42a40e7717701deea1ecf0c1b8091f65371154 /Source | |
parent | 74a1b8ebdeaca81e0654a7e40f78c36cef265025 (diff) | |
download | CMake-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')
-rw-r--r-- | Source/cmQtAutoGeneratorInitializer.cxx | 29 | ||||
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 36 |
2 files changed, 45 insertions, 20 deletions
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index ab247cb..1c0d4c3 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -882,29 +882,20 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( // Compose rcc output file name { - std::string rccOutBase = autogenBuildDir + "/"; - rccOutBase += fpathCheckSum.getPart(absFile); - rccOutBase += "/qrc_"; - rccOutBase += + std::string rccBuildFile = autogenBuildDir + "/"; + rccBuildFile += fpathCheckSum.getPart(absFile); + rccBuildFile += "/qrc_"; + rccBuildFile += cmsys::SystemTools::GetFilenameWithoutLastExtension(absFile); + rccBuildFile += ".cpp"; // Register rcc ouput file as generated - for (std::vector<std::string>::const_iterator it = - suffixes.begin(); - it != suffixes.end(); ++it) { - std::string rccOutCfg = rccOutBase; - rccOutCfg += *it; - rccOutCfg += ".cpp"; - AddGeneratedSource(makefile, rccOutCfg, - cmQtAutoGeneratorCommon::RCC); - autogenProvides.push_back(rccOutCfg); - } + AddGeneratedSource(makefile, rccBuildFile, + cmQtAutoGeneratorCommon::RCC); // Add rcc output file to origin target sources - if (multiConfig) { - target->AddSource(rccOutBase + "_$<CONFIG>.cpp"); - } else { - target->AddSource(rccOutBase + ".cpp"); - } + target->AddSource(rccBuildFile); + // Register rcc ouput file as generated by the _autogen target + autogenProvides.push_back(rccBuildFile); } if (PropertyEnabled(sf, "GENERATED")) { 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; } |