diff options
author | Sebastian Holtermann <sebholt@xwmw.org> | 2017-02-17 13:47:20 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-02-21 15:12:55 (GMT) |
commit | 347572cf5ea2c653cba6150b5e6d6fa083a68cb0 (patch) | |
tree | d814fdb86e023b7766f4d1e75f65ac61b7e08dc2 /Source | |
parent | 03df033bfa551e83c2a265cc22f6f5278c80528b (diff) | |
download | CMake-347572cf5ea2c653cba6150b5e6d6fa083a68cb0.zip CMake-347572cf5ea2c653cba6150b5e6d6fa083a68cb0.tar.gz CMake-347572cf5ea2c653cba6150b5e6d6fa083a68cb0.tar.bz2 |
Autogen: Only touch an unchanged moc_compilation.cpp
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 73 |
1 files changed, 37 insertions, 36 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 3965503..cd39984 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1070,6 +1070,9 @@ bool cmQtAutoGenerators::MocGenerateAll( return true; } + bool mocCompFileGenerated = false; + bool mocCompChanged = false; + // look for name collisions { std::multimap<std::string, std::string> collisions; @@ -1089,8 +1092,7 @@ bool cmQtAutoGenerators::MocGenerateAll( return false; } } - - // generate moc files that are included by source files. + // Generate moc files that are included by source files. { const std::string subDir = "include/"; for (std::map<std::string, std::string>::const_iterator it = @@ -1103,16 +1105,14 @@ bool cmQtAutoGenerators::MocGenerateAll( } } } - - // generate moc files that are _not_ included by source files. - bool automocCppChanged = false; + // Generate moc files that are _not_ included by source files. { const std::string subDir; for (std::map<std::string, std::string>::const_iterator it = mocsNotIncluded.begin(); it != mocsNotIncluded.end(); ++it) { if (this->MocGenerateFile(it->first, it->second, subDir, mocDepends)) { - automocCppChanged = true; + mocCompFileGenerated = true; } else { if (this->RunMocFailed) { return false; @@ -1141,46 +1141,47 @@ bool cmQtAutoGenerators::MocGenerateAll( automocSource = outStream.str(); } - // Check if we even need to update moc_compilation.cpp - if (!automocCppChanged) { - // compare contents of the moc_compilation.cpp file + // Check if the content of moc_compilation.cpp changed + { const std::string oldContents = ReadAll(this->MocCppFilenameAbs); - if (oldContents == automocSource) { - // nothing changed: don't touch the moc_compilation.cpp file - if (this->Verbose) { - std::ostringstream err; - err << "AutoMoc: " << this->MocCppFilenameRel << " still up to date" - << std::endl; - this->LogInfo(err.str()); - } - return true; - } + mocCompChanged = (oldContents != automocSource); } - // Actually write moc_compilation.cpp - this->LogBold("Generating MOC compilation " + this->MocCppFilenameRel); + bool success = true; + if (mocCompChanged) { + // Actually write moc_compilation.cpp + this->LogBold("Generating MOC compilation " + this->MocCppFilenameRel); - // Make sure the parent directory exists - bool success = this->MakeParentDirectory(this->MocCppFilenameAbs); - if (success) { - cmsys::ofstream outfile; - outfile.open(this->MocCppFilenameAbs.c_str(), std::ios::trunc); - if (!outfile) { - success = false; - std::ostringstream err; - err << "AutoMoc: error opening " << this->MocCppFilenameAbs << "\n"; - this->LogError(err.str()); - } else { - outfile << automocSource; - // Check for write errors - if (!outfile.good()) { + // Make sure the parent directory exists + success = this->MakeParentDirectory(this->MocCppFilenameAbs); + if (success) { + cmsys::ofstream outfile; + outfile.open(this->MocCppFilenameAbs.c_str(), std::ios::trunc); + if (!outfile) { success = false; std::ostringstream err; - err << "AutoMoc: error writing " << this->MocCppFilenameAbs << "\n"; + err << "AutoMoc: error opening " << this->MocCppFilenameAbs << "\n"; this->LogError(err.str()); + } else { + outfile << automocSource; + // Check for write errors + if (!outfile.good()) { + success = false; + std::ostringstream err; + err << "AutoMoc: error writing " << this->MocCppFilenameAbs << "\n"; + this->LogError(err.str()); + } } } + } else if (mocCompFileGenerated) { + // Only touch moc_compilation.cpp + if (this->Verbose) { + this->LogInfo("Touching MOC compilation " + this->MocCppFilenameRel + + "\n"); + } + cmSystemTools::Touch(this->MocCppFilenameAbs, false); } + return success; } |