summaryrefslogtreecommitdiffstats
path: root/Source/cmQtAutoGenerators.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2016-11-30 19:31:22 (GMT)
committerBrad King <brad.king@kitware.com>2016-12-07 13:23:52 (GMT)
commit1c97d1df20bbf771568321020e84718b82788272 (patch)
tree7067e7bd06c4d3a847d37c7ae9599ecbe6213dae /Source/cmQtAutoGenerators.cxx
parent69871e67e3b0612d7df8cc3ecf4a631850935e48 (diff)
downloadCMake-1c97d1df20bbf771568321020e84718b82788272.zip
CMake-1c97d1df20bbf771568321020e84718b82788272.tar.gz
CMake-1c97d1df20bbf771568321020e84718b82788272.tar.bz2
QtAutogen: Improved error recognition on config load
Diffstat (limited to 'Source/cmQtAutoGenerators.cxx')
-rw-r--r--Source/cmQtAutoGenerators.cxx60
1 files changed, 38 insertions, 22 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index c0a9b63..eea9804 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -8,7 +8,6 @@
#include <cmsys/FStream.hxx>
#include <cmsys/RegularExpression.hxx>
#include <cmsys/Terminal.h>
-#include <iostream>
#include <sstream>
#include <stdlib.h>
#include <string.h>
@@ -159,7 +158,6 @@ void cmQtAutoGenerators::MergeUicOptions(
bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
const std::string& config)
{
- bool success = true;
cmake cm;
cm.SetHomeOutputDirectory(targetDirectory);
cm.SetHomeDirectory(targetDirectory);
@@ -173,18 +171,18 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
CM_AUTO_PTR<cmMakefile> mf(new cmMakefile(&gg, snapshot));
gg.SetCurrentMakefile(mf.get());
- this->ReadAutogenInfoFile(mf.get(), targetDirectory, config);
+ if (!this->ReadAutogenInfoFile(mf.get(), targetDirectory, config)) {
+ return false;
+ }
this->ReadOldMocDefinitionsFile(mf.get(), targetDirectory);
-
this->Init();
if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5") {
- success = this->RunAutogen(mf.get());
+ if (!this->RunAutogen(mf.get())) {
+ return false;
+ }
}
-
- this->WriteOldMocDefinitionsFile(targetDirectory);
-
- return success;
+ return this->WriteOldMocDefinitionsFile(targetDirectory);
}
bool cmQtAutoGenerators::ReadAutogenInfoFile(
@@ -196,7 +194,9 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
filename += "/AutogenInfo.cmake";
if (!makefile->ReadListFile(filename.c_str())) {
- cmSystemTools::Error("Error processing file: ", filename.c_str());
+ std::ostringstream err;
+ err << "AUTOGEN: Error processing file: " << filename << std::endl;
+ this->LogError(err.str());
return false;
}
@@ -303,8 +303,15 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
std::vector<std::string> rccInputLists;
cmSystemTools::ExpandListArgument(rccInputs, rccInputLists);
+ // qrc files in the end of the list may have been empty
+ if (rccInputLists.size() < this->RccSources.size()) {
+ rccInputLists.resize(this->RccSources.size());
+ }
if (this->RccSources.size() != rccInputLists.size()) {
- cmSystemTools::Error("Error processing file: ", filename.c_str());
+ std::ostringstream err;
+ err << "AUTOGEN: RCC sources lists size missmatch in: " << filename;
+ err << std::endl;
+ this->LogError(err.str());
return false;
}
@@ -341,7 +348,7 @@ std::string cmQtAutoGenerators::MakeCompileSettingsString(cmMakefile* makefile)
return s;
}
-bool cmQtAutoGenerators::ReadOldMocDefinitionsFile(
+void cmQtAutoGenerators::ReadOldMocDefinitionsFile(
cmMakefile* makefile, const std::string& targetDirectory)
{
std::string filename(cmSystemTools::CollapseFullPath(targetDirectory));
@@ -352,23 +359,32 @@ bool cmQtAutoGenerators::ReadOldMocDefinitionsFile(
this->OldCompileSettingsStr =
makefile->GetSafeDefinition("AM_OLD_COMPILE_SETTINGS");
}
- return true;
}
-void cmQtAutoGenerators::WriteOldMocDefinitionsFile(
+bool cmQtAutoGenerators::WriteOldMocDefinitionsFile(
const std::string& targetDirectory)
{
+ bool success = true;
+
std::string filename(cmSystemTools::CollapseFullPath(targetDirectory));
cmSystemTools::ConvertToUnixSlashes(filename);
filename += "/AutomocOldMocDefinitions.cmake";
- cmsys::ofstream outfile;
- outfile.open(filename.c_str(), std::ios::trunc);
- outfile << "set(AM_OLD_COMPILE_SETTINGS "
- << cmOutputConverter::EscapeForCMake(this->CurrentCompileSettingsStr)
- << ")\n";
+ {
+ cmsys::ofstream outfile;
+ outfile.open(filename.c_str(), std::ios::trunc);
+ if (outfile.is_open()) {
+ outfile << "set(AM_OLD_COMPILE_SETTINGS "
+ << cmOutputConverter::EscapeForCMake(
+ this->CurrentCompileSettingsStr)
+ << ")\n";
+ success = outfile.good();
+ } else {
+ success = false;
+ }
+ }
- outfile.close();
+ return success;
}
void cmQtAutoGenerators::Init()
@@ -1431,12 +1447,12 @@ void cmQtAutoGenerators::NameCollisionLog(
void cmQtAutoGenerators::LogInfo(const std::string& message)
{
- std::cout << message;
+ cmSystemTools::Message(message.c_str());
}
void cmQtAutoGenerators::LogError(const std::string& message)
{
- std::cerr << message;
+ cmSystemTools::Error(message.c_str());
}
void cmQtAutoGenerators::LogCommand(const std::vector<std::string>& command)