summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2017-04-22 13:12:45 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2017-04-22 13:12:45 (GMT)
commit97d25404f38cbcf35f1a793b90f926f54f4b0d59 (patch)
treecb6bc459f5ce83a037ed734e0bafc51c6e9e2fd1
parentd040459679371a234cb24ebed3701cd464cc5fc5 (diff)
downloadCMake-97d25404f38cbcf35f1a793b90f926f54f4b0d59.zip
CMake-97d25404f38cbcf35f1a793b90f926f54f4b0d59.tar.gz
CMake-97d25404f38cbcf35f1a793b90f926f54f4b0d59.tar.bz2
Autogen: Use FileWrite to write the settings file
-rw-r--r--Source/cmQtAutoGenerators.cxx40
1 files changed, 21 insertions, 19 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index b15fb8c..eec1fc6 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -102,12 +102,15 @@ inline static bool SettingsMatch(cmMakefile* makefile, const char* key,
return (value == makefile->GetSafeDefinition(key));
}
-static void SettingWrite(std::ostream& ostr, const char* key,
- const std::string& value)
+static void SettingAppend(std::string& str, const char* key,
+ const std::string& value)
{
if (!value.empty()) {
- ostr << "set(" << key << " " << cmOutputConverter::EscapeForCMake(value)
- << ")\n";
+ str += "set(";
+ str += key;
+ str += " ";
+ str += cmOutputConverter::EscapeForCMake(value);
+ str += ")\n";
}
}
@@ -575,22 +578,21 @@ bool cmQtAutoGenerators::SettingsFileWrite()
// Only write if any setting changed
if (this->AnySettingsChanged()) {
if (this->Verbose) {
- this->LogInfo("AutoGen: Writing settings file " + this->SettingsFile);
- }
- cmsys::ofstream outfile;
- outfile.open(this->SettingsFile.c_str(), std::ios::trunc);
- if (outfile) {
- SettingWrite(outfile, SettingsKeyMoc, this->SettingsStringMoc);
- SettingWrite(outfile, SettingsKeyUic, this->SettingsStringUic);
- SettingWrite(outfile, SettingsKeyRcc, this->SettingsStringRcc);
- success = outfile.good();
- outfile.close();
- } else {
- success = false;
- // Remove old settings file to trigger full rebuild on next run
+ this->LogInfo("AutoGen: Writing settings file " +
+ Quoted(this->SettingsFile));
+ }
+ // Compose settings file content
+ std::string settings;
+ SettingAppend(settings, SettingsKeyMoc, this->SettingsStringMoc);
+ SettingAppend(settings, SettingsKeyUic, this->SettingsStringUic);
+ SettingAppend(settings, SettingsKeyRcc, this->SettingsStringRcc);
+ // Write settings file
+ if (!this->FileWrite("AutoGen", this->SettingsFile, settings)) {
+ this->LogError("AutoGen: Error: Could not write old settings file " +
+ Quoted(this->SettingsFile));
+ // Remove old settings file to trigger a full rebuild on the next run
cmSystemTools::RemoveFile(this->SettingsFile);
- this->LogError("AutoGen: Error: Writing old settings file failed: " +
- this->SettingsFile);
+ success = false;
}
}
return success;