|
|
@@ -15,7 +15,6 @@
|
|
|
#include <utility>
|
|
|
|
|
|
#include "cmAlgorithms.h"
|
|
|
-#include "cmFilePathUuid.h"
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
#include "cmMakefile.h"
|
|
|
#include "cmOutputConverter.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,30 +194,41 @@ 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;
|
|
|
}
|
|
|
|
|
|
+ // - Target names
|
|
|
+ this->OriginTargetName =
|
|
|
+ makefile->GetSafeDefinition("AM_ORIGIN_TARGET_NAME");
|
|
|
+ this->AutogenTargetName = makefile->GetSafeDefinition("AM_TARGET_NAME");
|
|
|
+
|
|
|
+ // - Directories
|
|
|
+ this->ProjectSourceDir = makefile->GetSafeDefinition("AM_CMAKE_SOURCE_DIR");
|
|
|
+ this->ProjectBinaryDir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR");
|
|
|
+ this->CurrentSourceDir =
|
|
|
+ makefile->GetSafeDefinition("AM_CMAKE_CURRENT_SOURCE_DIR");
|
|
|
+ this->CurrentBinaryDir =
|
|
|
+ makefile->GetSafeDefinition("AM_CMAKE_CURRENT_BINARY_DIR");
|
|
|
+
|
|
|
+ // - Qt environment
|
|
|
this->QtMajorVersion = makefile->GetSafeDefinition("AM_QT_VERSION_MAJOR");
|
|
|
if (this->QtMajorVersion == "") {
|
|
|
this->QtMajorVersion =
|
|
|
makefile->GetSafeDefinition("AM_Qt5Core_VERSION_MAJOR");
|
|
|
}
|
|
|
- this->Sources = makefile->GetSafeDefinition("AM_SOURCES");
|
|
|
- {
|
|
|
- std::string rccSources = makefile->GetSafeDefinition("AM_RCC_SOURCES");
|
|
|
- cmSystemTools::ExpandListArgument(rccSources, this->RccSources);
|
|
|
- }
|
|
|
- this->SkipMoc = makefile->GetSafeDefinition("AM_SKIP_MOC");
|
|
|
- this->SkipUic = makefile->GetSafeDefinition("AM_SKIP_UIC");
|
|
|
- this->Headers = makefile->GetSafeDefinition("AM_HEADERS");
|
|
|
- this->IncludeProjectDirsBefore =
|
|
|
- makefile->IsOn("AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE");
|
|
|
- this->Srcdir = makefile->GetSafeDefinition("AM_CMAKE_CURRENT_SOURCE_DIR");
|
|
|
- this->Builddir = makefile->GetSafeDefinition("AM_CMAKE_CURRENT_BINARY_DIR");
|
|
|
this->MocExecutable = makefile->GetSafeDefinition("AM_QT_MOC_EXECUTABLE");
|
|
|
this->UicExecutable = makefile->GetSafeDefinition("AM_QT_UIC_EXECUTABLE");
|
|
|
this->RccExecutable = makefile->GetSafeDefinition("AM_QT_RCC_EXECUTABLE");
|
|
|
+
|
|
|
+ // - File Lists
|
|
|
+ this->Sources = makefile->GetSafeDefinition("AM_SOURCES");
|
|
|
+ this->Headers = makefile->GetSafeDefinition("AM_HEADERS");
|
|
|
+
|
|
|
+ // - Moc
|
|
|
+ this->SkipMoc = makefile->GetSafeDefinition("AM_SKIP_MOC");
|
|
|
{
|
|
|
std::string compileDefsPropOrig = "AM_MOC_COMPILE_DEFINITIONS";
|
|
|
std::string compileDefsProp = compileDefsPropOrig;
|
|
|
@@ -244,12 +253,9 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
|
|
|
includes ? includes : makefile->GetSafeDefinition(includesPropOrig);
|
|
|
}
|
|
|
this->MocOptionsStr = makefile->GetSafeDefinition("AM_MOC_OPTIONS");
|
|
|
- this->ProjectBinaryDir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR");
|
|
|
- this->ProjectSourceDir = makefile->GetSafeDefinition("AM_CMAKE_SOURCE_DIR");
|
|
|
- this->TargetName = makefile->GetSafeDefinition("AM_TARGET_NAME");
|
|
|
- this->OriginTargetName =
|
|
|
- makefile->GetSafeDefinition("AM_ORIGIN_TARGET_NAME");
|
|
|
|
|
|
+ // - Uic
|
|
|
+ this->SkipUic = makefile->GetSafeDefinition("AM_SKIP_UIC");
|
|
|
{
|
|
|
const char* uicOptionsFiles =
|
|
|
makefile->GetSafeDefinition("AM_UIC_OPTIONS_FILES");
|
|
|
@@ -280,6 +286,12 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
|
|
|
this->UicOptions[*fileIt] = *optionIt;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // - Rcc
|
|
|
+ {
|
|
|
+ std::string rccSources = makefile->GetSafeDefinition("AM_RCC_SOURCES");
|
|
|
+ cmSystemTools::ExpandListArgument(rccSources, this->RccSources);
|
|
|
+ }
|
|
|
{
|
|
|
const char* rccOptionsFiles =
|
|
|
makefile->GetSafeDefinition("AM_RCC_OPTIONS_FILES");
|
|
|
@@ -303,8 +315,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;
|
|
|
}
|
|
|
|
|
|
@@ -318,9 +337,14 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(
|
|
|
this->RccInputs[*fileIt] = rccInputFiles;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // - Settings
|
|
|
this->CurrentCompileSettingsStr = this->MakeCompileSettingsString(makefile);
|
|
|
|
|
|
- this->RelaxedMode = makefile->IsOn("AM_RELAXED_MODE");
|
|
|
+ // - Flags
|
|
|
+ this->IncludeProjectDirsBefore =
|
|
|
+ makefile->IsOn("AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE");
|
|
|
+ this->MocRelaxedMode = makefile->IsOn("AM_MOC_RELAXED_MODE");
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
@@ -341,7 +365,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,34 +376,49 @@ 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) {
|
|
|
+ outfile << "set(AM_OLD_COMPILE_SETTINGS "
|
|
|
+ << cmOutputConverter::EscapeForCMake(
|
|
|
+ this->CurrentCompileSettingsStr)
|
|
|
+ << ")\n";
|
|
|
+ success = outfile.good();
|
|
|
+ } else {
|
|
|
+ success = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- outfile.close();
|
|
|
+ return success;
|
|
|
}
|
|
|
|
|
|
void cmQtAutoGenerators::Init()
|
|
|
{
|
|
|
- this->TargetBuildSubDir = this->TargetName;
|
|
|
- this->TargetBuildSubDir += ".dir/";
|
|
|
+ this->AutogenBuildSubDir = this->AutogenTargetName;
|
|
|
+ this->AutogenBuildSubDir += "/";
|
|
|
|
|
|
- this->OutMocCppFilenameRel = this->TargetName;
|
|
|
- this->OutMocCppFilenameRel += ".cpp";
|
|
|
+ this->OutMocCppFilenameRel = this->AutogenBuildSubDir;
|
|
|
+ this->OutMocCppFilenameRel += "moc_compilation.cpp";
|
|
|
|
|
|
- this->OutMocCppFilenameAbs = this->Builddir + this->OutMocCppFilenameRel;
|
|
|
+ this->OutMocCppFilenameAbs =
|
|
|
+ this->CurrentBinaryDir + this->OutMocCppFilenameRel;
|
|
|
+
|
|
|
+ // Init file path checksum generator
|
|
|
+ fpathCheckSum.setupParentDirs(this->CurrentSourceDir, this->CurrentBinaryDir,
|
|
|
+ this->ProjectSourceDir,
|
|
|
+ this->ProjectBinaryDir);
|
|
|
|
|
|
std::vector<std::string> cdefList;
|
|
|
cmSystemTools::ExpandListArgument(this->MocCompileDefinitionsStr, cdefList);
|
|
|
@@ -464,10 +503,10 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
|
|
|
// the program goes through all .cpp files to see which moc files are
|
|
|
// included. It is not really interesting how the moc file is named, but
|
|
|
// what file the moc is created from. Once a moc is included the same moc
|
|
|
- // may not be included in the _automoc.cpp file anymore. OTOH if there's a
|
|
|
- // header containing Q_OBJECT where no corresponding moc file is included
|
|
|
- // anywhere a moc_<filename>.cpp file is created and included in
|
|
|
- // the _automoc.cpp file.
|
|
|
+ // may not be included in the moc_compilation.cpp file anymore. OTOH if
|
|
|
+ // there's a header containing Q_OBJECT where no corresponding moc file
|
|
|
+ // is included anywhere a moc_<filename>.cpp file is created and included in
|
|
|
+ // the moc_compilation.cpp file.
|
|
|
|
|
|
// key = moc source filepath, value = moc output filepath
|
|
|
std::map<std::string, std::string> includedMocs;
|
|
|
@@ -497,11 +536,16 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
|
|
|
err << "AUTOGEN: Checking " << absFilename << std::endl;
|
|
|
this->LogInfo(err.str());
|
|
|
}
|
|
|
- if (this->RelaxedMode) {
|
|
|
- this->ParseCppFile(absFilename, headerExtensions, includedMocs, uiFiles);
|
|
|
+ if (this->MocRelaxedMode) {
|
|
|
+ if (!this->ParseCppFile(absFilename, headerExtensions, includedMocs,
|
|
|
+ uiFiles)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
} else {
|
|
|
- this->StrictParseCppFile(absFilename, headerExtensions, includedMocs,
|
|
|
- uiFiles);
|
|
|
+ if (!this->StrictParseCppFile(absFilename, headerExtensions,
|
|
|
+ includedMocs, uiFiles)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
this->SearchHeadersForCppFile(absFilename, headerExtensions, headerFiles);
|
|
|
}
|
|
|
@@ -533,38 +577,28 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
|
|
|
this->ParseHeaders(headerFiles, includedMocs, notIncludedMocs, includedUis);
|
|
|
|
|
|
if (!this->MocExecutable.empty()) {
|
|
|
- this->GenerateMocFiles(includedMocs, notIncludedMocs);
|
|
|
+ if (!this->GenerateMocFiles(includedMocs, notIncludedMocs)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
if (!this->UicExecutable.empty()) {
|
|
|
- this->GenerateUiFiles(includedUis);
|
|
|
+ if (!this->GenerateUiFiles(includedUis)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
if (!this->RccExecutable.empty()) {
|
|
|
- this->GenerateQrcFiles();
|
|
|
- }
|
|
|
-
|
|
|
- if (this->RunMocFailed) {
|
|
|
- std::ostringstream err;
|
|
|
- err << "moc failed..." << std::endl;
|
|
|
- this->LogError(err.str());
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (this->RunUicFailed) {
|
|
|
- std::ostringstream err;
|
|
|
- err << "uic failed..." << std::endl;
|
|
|
- this->LogError(err.str());
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (this->RunRccFailed) {
|
|
|
- std::ostringstream err;
|
|
|
- err << "rcc failed..." << std::endl;
|
|
|
- this->LogError(err.str());
|
|
|
- return false;
|
|
|
+ if (!this->GenerateQrcFiles()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-void cmQtAutoGenerators::ParseCppFile(
|
|
|
+/**
|
|
|
+ * @return True on success
|
|
|
+ */
|
|
|
+bool cmQtAutoGenerators::ParseCppFile(
|
|
|
const std::string& absFilename,
|
|
|
const std::vector<std::string>& headerExtensions,
|
|
|
std::map<std::string, std::string>& includedMocs,
|
|
|
@@ -579,12 +613,12 @@ void cmQtAutoGenerators::ParseCppFile(
|
|
|
std::ostringstream err;
|
|
|
err << "AUTOGEN: warning: " << absFilename << ": file is empty\n"
|
|
|
<< std::endl;
|
|
|
- this->LogError(err.str());
|
|
|
- return;
|
|
|
+ this->LogWarning(err.str());
|
|
|
+ return true;
|
|
|
}
|
|
|
this->ParseForUic(absFilename, contentsString, includedUis);
|
|
|
if (this->MocExecutable.empty()) {
|
|
|
- return;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
const std::string absPath = cmsys::SystemTools::GetFilenamePath(
|
|
|
@@ -648,7 +682,7 @@ void cmQtAutoGenerators::ParseCppFile(
|
|
|
<< std::endl;
|
|
|
}
|
|
|
this->LogError(err.str());
|
|
|
- ::exit(EXIT_FAILURE);
|
|
|
+ return false;
|
|
|
}
|
|
|
} else {
|
|
|
std::string fileToMoc = absFilename;
|
|
|
@@ -670,7 +704,7 @@ void cmQtAutoGenerators::ParseCppFile(
|
|
|
<< ".cpp\" for a compatibility with "
|
|
|
"strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n"
|
|
|
<< std::endl;
|
|
|
- this->LogError(err.str());
|
|
|
+ this->LogWarning(err.str());
|
|
|
} else {
|
|
|
std::ostringstream err;
|
|
|
err << "AUTOGEN: warning: " << absFilename
|
|
|
@@ -683,7 +717,7 @@ void cmQtAutoGenerators::ParseCppFile(
|
|
|
<< ".cpp\" for compatibility with "
|
|
|
"strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n"
|
|
|
<< std::endl;
|
|
|
- this->LogError(err.str());
|
|
|
+ this->LogWarning(err.str());
|
|
|
}
|
|
|
} else {
|
|
|
std::ostringstream err;
|
|
|
@@ -696,7 +730,7 @@ void cmQtAutoGenerators::ParseCppFile(
|
|
|
"header.\n"
|
|
|
<< std::endl;
|
|
|
this->LogError(err.str());
|
|
|
- ::exit(EXIT_FAILURE);
|
|
|
+ return false;
|
|
|
}
|
|
|
} else {
|
|
|
dotMocIncluded = true;
|
|
|
@@ -727,7 +761,7 @@ void cmQtAutoGenerators::ParseCppFile(
|
|
|
<< ".moc\" for compatibility with "
|
|
|
"strict mode (see CMAKE_AUTOMOC_RELAXED_MODE).\n"
|
|
|
<< std::endl;
|
|
|
- this->LogError(err.str());
|
|
|
+ this->LogWarning(err.str());
|
|
|
|
|
|
includedMocs[absFilename] = ownMocUnderscoreFile;
|
|
|
includedMocs.erase(ownMocHeaderFile);
|
|
|
@@ -740,13 +774,17 @@ void cmQtAutoGenerators::ParseCppFile(
|
|
|
<< "\"" << scannedFileBasename << ".moc\" !\n"
|
|
|
<< std::endl;
|
|
|
this->LogError(err.str());
|
|
|
-
|
|
|
- ::exit(EXIT_FAILURE);
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
-void cmQtAutoGenerators::StrictParseCppFile(
|
|
|
+/**
|
|
|
+ * @return True on success
|
|
|
+ */
|
|
|
+bool cmQtAutoGenerators::StrictParseCppFile(
|
|
|
const std::string& absFilename,
|
|
|
const std::vector<std::string>& headerExtensions,
|
|
|
std::map<std::string, std::string>& includedMocs,
|
|
|
@@ -761,12 +799,12 @@ void cmQtAutoGenerators::StrictParseCppFile(
|
|
|
std::ostringstream err;
|
|
|
err << "AUTOGEN: warning: " << absFilename << ": file is empty\n"
|
|
|
<< std::endl;
|
|
|
- this->LogError(err.str());
|
|
|
- return;
|
|
|
+ this->LogWarning(err.str());
|
|
|
+ return true;
|
|
|
}
|
|
|
this->ParseForUic(absFilename, contentsString, includedUis);
|
|
|
if (this->MocExecutable.empty()) {
|
|
|
- return;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
const std::string absPath = cmsys::SystemTools::GetFilenamePath(
|
|
|
@@ -819,7 +857,7 @@ void cmQtAutoGenerators::StrictParseCppFile(
|
|
|
<< std::endl;
|
|
|
}
|
|
|
this->LogError(err.str());
|
|
|
- ::exit(EXIT_FAILURE);
|
|
|
+ return false;
|
|
|
}
|
|
|
} else {
|
|
|
if (basename != scannedFileBasename) {
|
|
|
@@ -835,7 +873,7 @@ void cmQtAutoGenerators::StrictParseCppFile(
|
|
|
"moc on this source file.\n"
|
|
|
<< std::endl;
|
|
|
this->LogError(err.str());
|
|
|
- ::exit(EXIT_FAILURE);
|
|
|
+ return false;
|
|
|
}
|
|
|
dotMocIncluded = true;
|
|
|
includedMocs[absFilename] = currentMoc;
|
|
|
@@ -857,8 +895,10 @@ void cmQtAutoGenerators::StrictParseCppFile(
|
|
|
<< "\"" << scannedFileBasename << ".moc\" !\n"
|
|
|
<< std::endl;
|
|
|
this->LogError(err.str());
|
|
|
- ::exit(EXIT_FAILURE);
|
|
|
+ return false;
|
|
|
}
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
void cmQtAutoGenerators::ParseForUic(
|
|
|
@@ -873,7 +913,7 @@ void cmQtAutoGenerators::ParseForUic(
|
|
|
std::ostringstream err;
|
|
|
err << "AUTOGEN: warning: " << absFilename << ": file is empty\n"
|
|
|
<< std::endl;
|
|
|
- this->LogError(err.str());
|
|
|
+ this->LogWarning(err.str());
|
|
|
return;
|
|
|
}
|
|
|
this->ParseForUic(absFilename, contentsString, includedUis);
|
|
|
@@ -950,8 +990,6 @@ void cmQtAutoGenerators::ParseHeaders(
|
|
|
std::map<std::string, std::string>& notIncludedMocs,
|
|
|
std::map<std::string, std::vector<std::string> >& includedUis)
|
|
|
{
|
|
|
- cmFilePathUuid fpathUuid(this->Srcdir, this->Builddir,
|
|
|
- this->ProjectSourceDir, this->ProjectBinaryDir);
|
|
|
for (std::set<std::string>::const_iterator hIt = absHeaders.begin();
|
|
|
hIt != absHeaders.end(); ++hIt) {
|
|
|
const std::string& headerName = *hIt;
|
|
|
@@ -967,8 +1005,10 @@ void cmQtAutoGenerators::ParseHeaders(
|
|
|
|
|
|
std::string macroName;
|
|
|
if (requiresMocing(contents, macroName)) {
|
|
|
- notIncludedMocs[headerName] =
|
|
|
- this->TargetBuildSubDir + fpathUuid.get(headerName, "moc_", ".cpp");
|
|
|
+ notIncludedMocs[headerName] = fpathCheckSum.getPart(headerName) +
|
|
|
+ "/moc_" +
|
|
|
+ cmsys::SystemTools::GetFilenameWithoutLastExtension(headerName) +
|
|
|
+ ".cpp";
|
|
|
}
|
|
|
}
|
|
|
this->ParseForUic(headerName, contents, includedUis);
|
|
|
@@ -994,44 +1034,52 @@ bool cmQtAutoGenerators::GenerateMocFiles(
|
|
|
<< "To avoid this error either" << std::endl
|
|
|
<< "- rename the source files or" << std::endl
|
|
|
<< "- do not include the (moc_NAME.cpp|NAME.moc) file" << std::endl;
|
|
|
- this->NameCollisionLog(err.str(), collisions);
|
|
|
- ::exit(EXIT_FAILURE);
|
|
|
+ this->LogErrorNameCollision(err.str(), collisions);
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// generate moc files that are included by source files.
|
|
|
- for (std::map<std::string, std::string>::const_iterator it =
|
|
|
- includedMocs.begin();
|
|
|
- it != includedMocs.end(); ++it) {
|
|
|
- if (!this->GenerateMoc(it->first, it->second)) {
|
|
|
- if (this->RunMocFailed) {
|
|
|
- return false;
|
|
|
+ {
|
|
|
+ const std::string subDirPrefix = "include/";
|
|
|
+ for (std::map<std::string, std::string>::const_iterator it =
|
|
|
+ includedMocs.begin();
|
|
|
+ it != includedMocs.end(); ++it) {
|
|
|
+ if (!this->GenerateMoc(it->first, it->second, subDirPrefix)) {
|
|
|
+ if (this->RunMocFailed) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// generate moc files that are _not_ included by source files.
|
|
|
bool automocCppChanged = false;
|
|
|
- for (std::map<std::string, std::string>::const_iterator it =
|
|
|
- notIncludedMocs.begin();
|
|
|
- it != notIncludedMocs.end(); ++it) {
|
|
|
- if (this->GenerateMoc(it->first, it->second)) {
|
|
|
- automocCppChanged = true;
|
|
|
- } else {
|
|
|
- if (this->RunMocFailed) {
|
|
|
- return false;
|
|
|
+ {
|
|
|
+ const std::string subDirPrefix;
|
|
|
+ for (std::map<std::string, std::string>::const_iterator it =
|
|
|
+ notIncludedMocs.begin();
|
|
|
+ it != notIncludedMocs.end(); ++it) {
|
|
|
+ if (this->GenerateMoc(it->first, it->second, subDirPrefix)) {
|
|
|
+ automocCppChanged = true;
|
|
|
+ } else {
|
|
|
+ if (this->RunMocFailed) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // compose _automoc.cpp content
|
|
|
+ // Compose moc_compilation.cpp content
|
|
|
std::string automocSource;
|
|
|
{
|
|
|
std::ostringstream outStream;
|
|
|
outStream << "/* This file is autogenerated, do not edit*/\n";
|
|
|
if (notIncludedMocs.empty()) {
|
|
|
+ // Dummy content
|
|
|
outStream << "enum some_compilers { need_more_than_nothing };\n";
|
|
|
} else {
|
|
|
+ // Valid content
|
|
|
for (std::map<std::string, std::string>::const_iterator it =
|
|
|
notIncludedMocs.begin();
|
|
|
it != notIncludedMocs.end(); ++it) {
|
|
|
@@ -1042,12 +1090,12 @@ bool cmQtAutoGenerators::GenerateMocFiles(
|
|
|
automocSource = outStream.str();
|
|
|
}
|
|
|
|
|
|
- // check if we even need to update _automoc.cpp
|
|
|
+ // Check if we even need to update moc_compilation.cpp
|
|
|
if (!automocCppChanged) {
|
|
|
- // compare contents of the _automoc.cpp file
|
|
|
+ // compare contents of the moc_compilation.cpp file
|
|
|
const std::string oldContents = ReadAll(this->OutMocCppFilenameAbs);
|
|
|
if (oldContents == automocSource) {
|
|
|
- // nothing changed: don't touch the _automoc.cpp file
|
|
|
+ // nothing changed: don't touch the moc_compilation.cpp file
|
|
|
if (this->Verbose) {
|
|
|
std::ostringstream err;
|
|
|
err << "AUTOGEN: " << this->OutMocCppFilenameRel << " still up to date"
|
|
|
@@ -1058,43 +1106,58 @@ bool cmQtAutoGenerators::GenerateMocFiles(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // actually write _automoc.cpp
|
|
|
+ // Actually write moc_compilation.cpp
|
|
|
{
|
|
|
- std::string msg = "Generating moc compilation ";
|
|
|
+ std::string msg = "Generating MOC compilation ";
|
|
|
msg += this->OutMocCppFilenameRel;
|
|
|
- cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue |
|
|
|
- cmsysTerminal_Color_ForegroundBold,
|
|
|
- msg.c_str(), true, this->ColorOutput);
|
|
|
+ this->LogBold(msg);
|
|
|
}
|
|
|
- {
|
|
|
+ // Make sure the parent directory exists
|
|
|
+ bool success = this->makeParentDirectory(this->OutMocCppFilenameAbs);
|
|
|
+ if (success) {
|
|
|
cmsys::ofstream outfile;
|
|
|
outfile.open(this->OutMocCppFilenameAbs.c_str(), std::ios::trunc);
|
|
|
- outfile << automocSource;
|
|
|
- outfile.close();
|
|
|
+ if (!outfile) {
|
|
|
+ success = false;
|
|
|
+ std::ostringstream err;
|
|
|
+ err << "AUTOGEN: error opening " << this->OutMocCppFilenameAbs << "\n";
|
|
|
+ this->LogError(err.str());
|
|
|
+ } else {
|
|
|
+ outfile << automocSource;
|
|
|
+ // Check for write errors
|
|
|
+ if (!outfile.good()) {
|
|
|
+ success = false;
|
|
|
+ std::ostringstream err;
|
|
|
+ err << "AUTOGEN: error writing " << this->OutMocCppFilenameAbs << "\n";
|
|
|
+ this->LogError(err.str());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- return true;
|
|
|
+ return success;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * @return True if a moc file was created. False may indicate an error.
|
|
|
+ */
|
|
|
bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
|
|
|
- const std::string& mocFileName)
|
|
|
+ const std::string& mocFileName,
|
|
|
+ const std::string& subDirPrefix)
|
|
|
{
|
|
|
- const std::string mocFilePath = this->Builddir + mocFileName;
|
|
|
+ const std::string mocFileRel =
|
|
|
+ this->AutogenBuildSubDir + subDirPrefix + mocFileName;
|
|
|
+ const std::string mocFileAbs = this->CurrentBinaryDir + mocFileRel;
|
|
|
int sourceNewerThanMoc = 0;
|
|
|
- bool success = cmsys::SystemTools::FileTimeCompare(sourceFile, mocFilePath,
|
|
|
+ bool success = cmsys::SystemTools::FileTimeCompare(sourceFile, mocFileAbs,
|
|
|
&sourceNewerThanMoc);
|
|
|
if (this->GenerateAll || !success || sourceNewerThanMoc >= 0) {
|
|
|
- // make sure the directory for the resulting moc file exists
|
|
|
- std::string mocDir = mocFilePath.substr(0, mocFilePath.rfind('/'));
|
|
|
- if (!cmsys::SystemTools::FileExists(mocDir.c_str(), false)) {
|
|
|
- cmsys::SystemTools::MakeDirectory(mocDir.c_str());
|
|
|
- }
|
|
|
+ // Log
|
|
|
+ this->LogBold("Generating MOC source " + mocFileRel);
|
|
|
|
|
|
- std::string msg = "Generating moc source ";
|
|
|
- msg += mocFileName;
|
|
|
- cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue |
|
|
|
- cmsysTerminal_Color_ForegroundBold,
|
|
|
- msg.c_str(), true, this->ColorOutput);
|
|
|
+ // 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);
|
|
|
@@ -1108,7 +1171,7 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
|
|
|
command.push_back("-DWIN32");
|
|
|
#endif
|
|
|
command.push_back("-o");
|
|
|
- command.push_back(mocFilePath);
|
|
|
+ command.push_back(mocFileAbs);
|
|
|
command.push_back(sourceFile);
|
|
|
|
|
|
if (this->Verbose) {
|
|
|
@@ -1120,12 +1183,15 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
|
|
|
bool result =
|
|
|
cmSystemTools::RunSingleCommand(command, &output, &output, &retVal);
|
|
|
if (!result || retVal) {
|
|
|
- std::ostringstream err;
|
|
|
- err << "AUTOGEN: error: process for " << mocFilePath << " failed:\n"
|
|
|
- << output << std::endl;
|
|
|
- this->LogError(err.str());
|
|
|
+ {
|
|
|
+ std::ostringstream err;
|
|
|
+ err << "AUTOGEN: error: moc process for " << mocFileRel << " failed:\n"
|
|
|
+ << output << std::endl;
|
|
|
+ this->LogError(err.str());
|
|
|
+ }
|
|
|
+ cmSystemTools::RemoveFile(mocFileAbs);
|
|
|
this->RunMocFailed = true;
|
|
|
- cmSystemTools::RemoveFile(mocFilePath);
|
|
|
+ return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
@@ -1166,8 +1232,8 @@ bool cmQtAutoGenerators::GenerateUiFiles(
|
|
|
"from different sources."
|
|
|
<< std::endl
|
|
|
<< "To avoid this error rename the source files." << std::endl;
|
|
|
- this->NameCollisionLog(err.str(), collisions);
|
|
|
- ::exit(EXIT_FAILURE);
|
|
|
+ this->LogErrorNameCollision(err.str(), collisions);
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|
|
|
testMap.clear();
|
|
|
@@ -1191,25 +1257,29 @@ bool cmQtAutoGenerators::GenerateUiFiles(
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * @return True if a uic file was created. False may indicate an error.
|
|
|
+ */
|
|
|
bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
|
|
|
const std::string& uiInputFile,
|
|
|
const std::string& uiOutputFile)
|
|
|
{
|
|
|
- if (!cmsys::SystemTools::FileExists(this->Builddir.c_str(), false)) {
|
|
|
- cmsys::SystemTools::MakeDirectory(this->Builddir.c_str());
|
|
|
- }
|
|
|
-
|
|
|
- const std::string uiBuildFile = this->Builddir + uiOutputFile;
|
|
|
+ const std::string uicFileRel =
|
|
|
+ this->AutogenBuildSubDir + "include/" + uiOutputFile;
|
|
|
+ const std::string uicFileAbs = this->CurrentBinaryDir + uicFileRel;
|
|
|
|
|
|
int sourceNewerThanUi = 0;
|
|
|
- bool success = cmsys::SystemTools::FileTimeCompare(uiInputFile, uiBuildFile,
|
|
|
+ bool success = cmsys::SystemTools::FileTimeCompare(uiInputFile, uicFileAbs,
|
|
|
&sourceNewerThanUi);
|
|
|
if (this->GenerateAll || !success || sourceNewerThanUi >= 0) {
|
|
|
- std::string msg = "Generating ui header ";
|
|
|
- msg += uiOutputFile;
|
|
|
- cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue |
|
|
|
- cmsysTerminal_Color_ForegroundBold,
|
|
|
- msg.c_str(), true, this->ColorOutput);
|
|
|
+ // Log
|
|
|
+ this->LogBold("Generating UIC header " + uicFileRel);
|
|
|
+
|
|
|
+ // Make sure the parent directory exists
|
|
|
+ if (!this->makeParentDirectory(uicFileAbs)) {
|
|
|
+ this->RunUicFailed = true;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
std::vector<std::string> command;
|
|
|
command.push_back(this->UicExecutable);
|
|
|
@@ -1226,7 +1296,7 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
|
|
|
command.insert(command.end(), opts.begin(), opts.end());
|
|
|
|
|
|
command.push_back("-o");
|
|
|
- command.push_back(uiBuildFile);
|
|
|
+ command.push_back(uicFileAbs);
|
|
|
command.push_back(uiInputFile);
|
|
|
|
|
|
if (this->Verbose) {
|
|
|
@@ -1237,13 +1307,15 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
|
|
|
bool result =
|
|
|
cmSystemTools::RunSingleCommand(command, &output, &output, &retVal);
|
|
|
if (!result || retVal) {
|
|
|
- std::ostringstream err;
|
|
|
- err << "AUTOUIC: error: process for " << uiOutputFile
|
|
|
- << " needed by\n \"" << realName << "\"\nfailed:\n"
|
|
|
- << output << std::endl;
|
|
|
- this->LogError(err.str());
|
|
|
+ {
|
|
|
+ std::ostringstream err;
|
|
|
+ err << "AUTOUIC: error: uic process for " << uicFileRel
|
|
|
+ << " needed by\n \"" << realName << "\"\nfailed:\n"
|
|
|
+ << output << std::endl;
|
|
|
+ this->LogError(err.str());
|
|
|
+ }
|
|
|
+ cmSystemTools::RemoveFile(uicFileAbs);
|
|
|
this->RunUicFailed = true;
|
|
|
- cmSystemTools::RemoveFile(uiOutputFile);
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
@@ -1271,18 +1343,13 @@ bool cmQtAutoGenerators::GenerateQrcFiles()
|
|
|
{
|
|
|
// generate single map with input / output names
|
|
|
std::map<std::string, std::string> qrcGenMap;
|
|
|
- {
|
|
|
- cmFilePathUuid fpathUuid(this->Srcdir, this->Builddir,
|
|
|
- this->ProjectSourceDir, this->ProjectBinaryDir);
|
|
|
- for (std::vector<std::string>::const_iterator si =
|
|
|
- this->RccSources.begin();
|
|
|
- si != this->RccSources.end(); ++si) {
|
|
|
- const std::string ext =
|
|
|
- cmsys::SystemTools::GetFilenameLastExtension(*si);
|
|
|
- if (ext == ".qrc") {
|
|
|
- qrcGenMap[*si] =
|
|
|
- (this->TargetBuildSubDir + fpathUuid.get(*si, "qrc_", ".cpp"));
|
|
|
- }
|
|
|
+ for (std::vector<std::string>::const_iterator si = this->RccSources.begin();
|
|
|
+ si != this->RccSources.end(); ++si) {
|
|
|
+ const std::string ext = cmsys::SystemTools::GetFilenameLastExtension(*si);
|
|
|
+ if (ext == ".qrc") {
|
|
|
+ qrcGenMap[*si] = this->AutogenBuildSubDir + fpathCheckSum.getPart(*si) +
|
|
|
+ "/qrc_" + cmsys::SystemTools::GetFilenameWithoutLastExtension(*si) +
|
|
|
+ ".cpp";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1295,8 +1362,8 @@ bool cmQtAutoGenerators::GenerateQrcFiles()
|
|
|
" will be generated from different sources."
|
|
|
<< std::endl
|
|
|
<< "To avoid this error rename the source .qrc files." << std::endl;
|
|
|
- this->NameCollisionLog(err.str(), collisions);
|
|
|
- ::exit(EXIT_FAILURE);
|
|
|
+ this->LogErrorNameCollision(err.str(), collisions);
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1314,25 +1381,24 @@ bool cmQtAutoGenerators::GenerateQrcFiles()
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * @return True if a rcc file was created. False may indicate an error.
|
|
|
+ */
|
|
|
bool cmQtAutoGenerators::GenerateQrc(const std::string& qrcInputFile,
|
|
|
const std::string& qrcOutputFile,
|
|
|
bool unique_n)
|
|
|
{
|
|
|
- std::string symbolName;
|
|
|
- if (unique_n) {
|
|
|
- symbolName =
|
|
|
- cmsys::SystemTools::GetFilenameWithoutLastExtension(qrcInputFile);
|
|
|
- } else {
|
|
|
- symbolName =
|
|
|
- cmsys::SystemTools::GetFilenameWithoutLastExtension(qrcOutputFile);
|
|
|
- // Remove "qrc_" at string begin
|
|
|
- symbolName.erase(0, 4);
|
|
|
+ std::string symbolName =
|
|
|
+ cmsys::SystemTools::GetFilenameWithoutLastExtension(qrcInputFile);
|
|
|
+ if (!unique_n) {
|
|
|
+ symbolName += "_";
|
|
|
+ symbolName += fpathCheckSum.getPart(qrcInputFile);
|
|
|
}
|
|
|
// Replace '-' with '_'. The former is valid for
|
|
|
// file names but not for symbol names.
|
|
|
std::replace(symbolName.begin(), symbolName.end(), '-', '_');
|
|
|
|
|
|
- const std::string qrcBuildFile = this->Builddir + qrcOutputFile;
|
|
|
+ const std::string qrcBuildFile = this->CurrentBinaryDir + qrcOutputFile;
|
|
|
|
|
|
int sourceNewerThanQrc = 0;
|
|
|
bool generateQrc = !cmsys::SystemTools::FileTimeCompare(
|
|
|
@@ -1342,21 +1408,27 @@ bool cmQtAutoGenerators::GenerateQrc(const std::string& qrcInputFile,
|
|
|
generateQrc || this->InputFilesNewerThanQrc(qrcInputFile, qrcBuildFile);
|
|
|
|
|
|
if (this->GenerateAll || generateQrc) {
|
|
|
- std::string msg = "Generating qrc source ";
|
|
|
- msg += qrcOutputFile;
|
|
|
- cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue |
|
|
|
- cmsysTerminal_Color_ForegroundBold,
|
|
|
- msg.c_str(), true, this->ColorOutput);
|
|
|
+ {
|
|
|
+ std::string msg = "Generating RCC source ";
|
|
|
+ msg += qrcOutputFile;
|
|
|
+ this->LogBold(msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Make sure the parent directory exists
|
|
|
+ if (!this->makeParentDirectory(qrcOutputFile)) {
|
|
|
+ this->RunRccFailed = true;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
std::vector<std::string> command;
|
|
|
command.push_back(this->RccExecutable);
|
|
|
-
|
|
|
- std::map<std::string, std::string>::const_iterator optionIt =
|
|
|
- this->RccOptions.find(qrcInputFile);
|
|
|
- if (optionIt != this->RccOptions.end()) {
|
|
|
- cmSystemTools::ExpandListArgument(optionIt->second, command);
|
|
|
+ {
|
|
|
+ std::map<std::string, std::string>::const_iterator optionIt =
|
|
|
+ this->RccOptions.find(qrcInputFile);
|
|
|
+ if (optionIt != this->RccOptions.end()) {
|
|
|
+ cmSystemTools::ExpandListArgument(optionIt->second, command);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
command.push_back("-name");
|
|
|
command.push_back(symbolName);
|
|
|
command.push_back("-o");
|
|
|
@@ -1371,16 +1443,20 @@ bool cmQtAutoGenerators::GenerateQrc(const std::string& qrcInputFile,
|
|
|
bool result =
|
|
|
cmSystemTools::RunSingleCommand(command, &output, &output, &retVal);
|
|
|
if (!result || retVal) {
|
|
|
- std::ostringstream err;
|
|
|
- err << "AUTORCC: error: process for " << qrcOutputFile << " failed:\n"
|
|
|
- << output << std::endl;
|
|
|
- this->LogError(err.str());
|
|
|
- this->RunRccFailed = true;
|
|
|
+ {
|
|
|
+ std::ostringstream err;
|
|
|
+ err << "AUTORCC: error: rcc process for " << qrcOutputFile
|
|
|
+ << " failed:\n"
|
|
|
+ << output << std::endl;
|
|
|
+ this->LogError(err.str());
|
|
|
+ }
|
|
|
cmSystemTools::RemoveFile(qrcBuildFile);
|
|
|
+ this->RunRccFailed = true;
|
|
|
return false;
|
|
|
}
|
|
|
+ return true;
|
|
|
}
|
|
|
- return true;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1413,7 +1489,7 @@ bool cmQtAutoGenerators::NameCollisionTest(
|
|
|
return !collisions.empty();
|
|
|
}
|
|
|
|
|
|
-void cmQtAutoGenerators::NameCollisionLog(
|
|
|
+void cmQtAutoGenerators::LogErrorNameCollision(
|
|
|
const std::string& message,
|
|
|
const std::multimap<std::string, std::string>& collisions)
|
|
|
{
|
|
|
@@ -1429,14 +1505,30 @@ void cmQtAutoGenerators::NameCollisionLog(
|
|
|
this->LogError(err.str());
|
|
|
}
|
|
|
|
|
|
+void cmQtAutoGenerators::LogBold(const std::string& message)
|
|
|
+{
|
|
|
+ cmSystemTools::MakefileColorEcho(cmsysTerminal_Color_ForegroundBlue |
|
|
|
+ cmsysTerminal_Color_ForegroundBold,
|
|
|
+ message.c_str(), true, this->ColorOutput);
|
|
|
+}
|
|
|
+
|
|
|
void cmQtAutoGenerators::LogInfo(const std::string& message)
|
|
|
{
|
|
|
- std::cout << message;
|
|
|
+ std::cout << message.c_str();
|
|
|
+}
|
|
|
+
|
|
|
+void cmQtAutoGenerators::LogWarning(const std::string& message)
|
|
|
+{
|
|
|
+ std::ostringstream ostr;
|
|
|
+ ostr << message << "\n";
|
|
|
+ std::cout << message.c_str();
|
|
|
}
|
|
|
|
|
|
void cmQtAutoGenerators::LogError(const std::string& message)
|
|
|
{
|
|
|
- std::cerr << message;
|
|
|
+ std::ostringstream ostr;
|
|
|
+ ostr << message << "\n\n";
|
|
|
+ std::cerr << ostr.str();
|
|
|
}
|
|
|
|
|
|
void cmQtAutoGenerators::LogCommand(const std::vector<std::string>& command)
|
|
|
@@ -1455,6 +1547,25 @@ void cmQtAutoGenerators::LogCommand(const std::vector<std::string>& command)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * @brief Generates the parent directory of the given file on demand
|
|
|
+ * @return True on success
|
|
|
+ */
|
|
|
+bool cmQtAutoGenerators::makeParentDirectory(const std::string& filename)
|
|
|
+{
|
|
|
+ bool success = true;
|
|
|
+ const std::string dirName = cmSystemTools::GetFilenamePath(filename);
|
|
|
+ if (!dirName.empty()) {
|
|
|
+ success = cmsys::SystemTools::MakeDirectory(dirName);
|
|
|
+ if (!success) {
|
|
|
+ std::ostringstream err;
|
|
|
+ err << "AUTOGEN: Directory creation failed: " << dirName << std::endl;
|
|
|
+ this->LogError(err.str());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return success;
|
|
|
+}
|
|
|
+
|
|
|
std::string cmQtAutoGenerators::JoinExts(const std::vector<std::string>& lst)
|
|
|
{
|
|
|
if (lst.empty()) {
|