summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGenerators.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2017-04-22 12:39:50 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2017-04-22 12:39:50 (GMT)
commit7c5f5f1a209952828ddce26827b96ab9b9143949 (patch)
treef0503d4a0b8fff921182bbe0bc204a7d3083a2aa /Source/cmQtAutoGenerators.cxx
parent1d5ed679ced9126f7cf686dd614e02b473d16b5e (diff)
downloadCMake-7c5f5f1a209952828ddce26827b96ab9b9143949.zip
CMake-7c5f5f1a209952828ddce26827b96ab9b9143949.tar.gz
CMake-7c5f5f1a209952828ddce26827b96ab9b9143949.tar.bz2
Autogen: Generate moc_predefs.h only on demand
Diffstat (limited to 'Source/cmQtAutoGenerators.cxx')
-rw-r--r--Source/cmQtAutoGenerators.cxx71
1 files changed, 41 insertions, 30 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 12acf1a..8e592b0 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -248,6 +248,7 @@ cmQtAutoGenerators::cmQtAutoGenerators()
: Verbose(cmsys::SystemTools::HasEnv("VERBOSE"))
, ColorOutput(true)
, MocSettingsChanged(false)
+ , MocPredefsChanged(false)
, MocRunFailed(false)
, UicSettingsChanged(false)
, UicRunFailed(false)
@@ -520,6 +521,8 @@ void cmQtAutoGenerators::SettingsFileRead(cmMakefile* makefile)
str += " ~~~ ";
str += this->IncludeProjectDirsBefore ? "TRUE" : "FALSE";
str += " ~~~ ";
+ str += JoinOptionsList(this->MocPredefsCmd);
+ str += " ~~~ ";
}
if (this->UicEnabled()) {
std::string& str = this->SettingsStringUic;
@@ -1186,40 +1189,48 @@ bool cmQtAutoGenerators::MocGenerateAll(
// Generate moc_predefs
if (!this->MocPredefsCmd.empty()) {
- this->LogBold("Generating MOC predefs " + this->MocPredefsFileRel);
+ if (this->MocSettingsChanged ||
+ FileAbsentOrOlder(this->MocPredefsFileAbs, this->SettingsFile)) {
+ this->LogBold("Generating MOC predefs " + this->MocPredefsFileRel);
- std::string output;
- {
- std::vector<std::string> cmd = this->MocPredefsCmd;
- // Add includes
- cmd.insert(cmd.end(), this->MocIncludes.begin(),
- this->MocIncludes.end());
- // Add definitions
- for (std::vector<std::string>::const_iterator it =
- this->MocDefinitions.begin();
- it != this->MocDefinitions.end(); ++it) {
- cmd.push_back("-D" + (*it));
+ std::string output;
+ {
+ // Compose command
+ std::vector<std::string> cmd = this->MocPredefsCmd;
+ // Add includes
+ cmd.insert(cmd.end(), this->MocIncludes.begin(),
+ this->MocIncludes.end());
+ // Add definitions
+ for (std::vector<std::string>::const_iterator it =
+ this->MocDefinitions.begin();
+ it != this->MocDefinitions.end(); ++it) {
+ cmd.push_back("-D" + (*it));
#ifdef _WIN32
- cmd.push_back("-DWIN32");
+ cmd.push_back("-DWIN32");
#endif
- }
- // Add options
- cmd.insert(cmd.end(), this->MocOptions.begin(), this->MocOptions.end());
- if (!this->RunCommand(cmd, output, false)) {
- {
- std::ostringstream ost;
- ost << "AutoMoc: Error: moc predefs generation command failed\n";
- ost << "AutoMoc: Command:\n" << QuotedCommand(cmd) << "\n";
- ost << "AutoMoc: Command output:\n" << output << "\n";
- this->LogError(ost.str());
}
- return false;
+ // Add options
+ cmd.insert(cmd.end(), this->MocOptions.begin(),
+ this->MocOptions.end());
+ // Execute command
+ if (!this->RunCommand(cmd, output, false)) {
+ {
+ std::ostringstream ost;
+ ost << "AutoMoc: Error: moc predefs generation command failed\n";
+ ost << "AutoMoc: Command:\n" << QuotedCommand(cmd) << "\n";
+ ost << "AutoMoc: Command output:\n" << output << "\n";
+ this->LogError(ost.str());
+ }
+ return false;
+ }
}
- }
-
- if (this->FileDiffers(this->MocPredefsFileAbs, output)) {
- if (!this->FileWrite("AutoMoc", this->MocPredefsFileAbs, output)) {
- return false;
+ // (Re)write predefs file only on demand
+ if (this->FileDiffers(this->MocPredefsFileAbs, output)) {
+ if (this->FileWrite("AutoMoc", this->MocPredefsFileAbs, output)) {
+ this->MocPredefsChanged = true;
+ } else {
+ return false;
+ }
}
}
}
@@ -1300,7 +1311,7 @@ bool cmQtAutoGenerators::MocGenerateFile(
const std::map<std::string, std::set<std::string> >& mocDepends)
{
bool mocGenerated = false;
- bool generateMoc = this->MocSettingsChanged;
+ bool generateMoc = this->MocSettingsChanged || this->MocPredefsChanged;
const std::string mocFileRel =
this->AutogenBuildSubDir + subDir + mocFileName;