summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2017-02-14 18:53:08 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2017-02-19 11:35:41 (GMT)
commit74a2fcff50356dcdcd4004664a2b2b81a8142660 (patch)
treee7345ae6c4b4ed2249238a566dfb523f6ac6d782
parent21886ff66a8a84c20a3c7f24601b5a353d8c7d06 (diff)
downloadCMake-74a2fcff50356dcdcd4004664a2b2b81a8142660.zip
CMake-74a2fcff50356dcdcd4004664a2b2b81a8142660.tar.gz
CMake-74a2fcff50356dcdcd4004664a2b2b81a8142660.tar.bz2
Autogen: Single point of return in MocGenerateFile
-rw-r--r--Source/cmQtAutoGenerators.cxx81
1 files changed, 45 insertions, 36 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 8d8b47a..ac0acb3 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -1200,13 +1200,15 @@ bool cmQtAutoGenerators::MocGenerateFile(const std::string& sourceFile,
const std::string& mocFileName,
const std::string& subDirPrefix)
{
+ bool mocGenerated = false;
+ bool generateMoc = this->GenerateAllMoc;
+
const std::string mocFileRel =
this->AutogenBuildSubDir + subDirPrefix + mocFileName;
const std::string mocFileAbs = this->CurrentBinaryDir + mocFileRel;
- bool generateMoc = this->GenerateAllMoc;
- // Test if the source file is newer that the build file
if (!generateMoc) {
+ // Test if the source file is newer that the build file
generateMoc = FileAbsentOrOlder(mocFileAbs, sourceFile);
}
if (generateMoc) {
@@ -1214,48 +1216,55 @@ bool cmQtAutoGenerators::MocGenerateFile(const std::string& sourceFile,
this->LogBold("Generating MOC source " + mocFileRel);
// Make sure the parent directory exists
- if (!this->MakeParentDirectory(mocFileAbs)) {
- this->RunMocFailed = true;
- return false;
- }
-
- std::vector<std::string> command;
- command.push_back(this->MocExecutable);
- command.insert(command.end(), this->MocIncludes.begin(),
- this->MocIncludes.end());
- command.insert(command.end(), this->MocDefinitions.begin(),
- this->MocDefinitions.end());
- command.insert(command.end(), this->MocOptions.begin(),
- this->MocOptions.end());
+ if (this->MakeParentDirectory(mocFileAbs)) {
+ // Compose moc command
+ std::vector<std::string> cmd;
+ cmd.push_back(this->MocExecutable);
+ cmd.insert(cmd.end(), this->MocIncludes.begin(),
+ this->MocIncludes.end());
+ cmd.insert(cmd.end(), this->MocDefinitions.begin(),
+ this->MocDefinitions.end());
+ cmd.insert(cmd.end(), this->MocOptions.begin(), this->MocOptions.end());
#ifdef _WIN32
- command.push_back("-DWIN32");
+ cmd.push_back("-DWIN32");
#endif
- command.push_back("-o");
- command.push_back(mocFileAbs);
- command.push_back(sourceFile);
+ cmd.push_back("-o");
+ cmd.push_back(mocFileAbs);
+ cmd.push_back(sourceFile);
- if (this->Verbose) {
- this->LogCommand(command);
- }
+ // Log moc command
+ if (this->Verbose) {
+ this->LogCommand(cmd);
+ }
- std::string output;
- int retVal = 0;
- bool result =
- cmSystemTools::RunSingleCommand(command, &output, &output, &retVal);
- if (!result || retVal) {
- {
- std::ostringstream err;
- err << "AutoMoc: Error: moc process for " << mocFileRel << " failed:\n"
- << output << std::endl;
- this->LogError(err.str());
+ // Execute moc command
+ bool res = false;
+ int retVal = 0;
+ std::string output;
+ res = cmSystemTools::RunSingleCommand(cmd, &output, &output, &retVal);
+
+ if (!res || (retVal != 0)) {
+ // Command failed
+ {
+ std::ostringstream err;
+ err << "AutoMoc: Error: moc process failed for\n";
+ err << "\"" << mocFileRel << "\"\n";
+ err << "AutoMoc: Command:\n" << cmJoin(cmd, " ") << "\n";
+ err << "AutoMoc: Command output:\n" << output << "\n";
+ this->LogError(err.str());
+ }
+ cmSystemTools::RemoveFile(mocFileAbs);
+ this->RunMocFailed = true;
+ } else {
+ // Success
+ mocGenerated = true;
}
- cmSystemTools::RemoveFile(mocFileAbs);
+ } else {
+ // Parent directory creation failed
this->RunMocFailed = true;
- return false;
}
- return true;
}
- return false;
+ return mocGenerated;
}
bool cmQtAutoGenerators::UicGenerateAll(