summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-02-26 16:05:59 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-02-26 16:06:10 (GMT)
commit5ac1c809f7cc257807afc1fa779150aa1738fe4a (patch)
tree6c592d48f64fe64ee6fc7899813807e3cfdd874e
parentc24392eec1ae3d97bad99039cdb818ecd1e6263f (diff)
parent747463d1b36a8bea31764db88ed4d9677b76f27f (diff)
downloadCMake-5ac1c809f7cc257807afc1fa779150aa1738fe4a.zip
CMake-5ac1c809f7cc257807afc1fa779150aa1738fe4a.tar.gz
CMake-5ac1c809f7cc257807afc1fa779150aa1738fe4a.tar.bz2
Merge topic 'autogen_headers_at_configure_time'
747463d1b3 Autogen: Move additional source header search to configuration stage 16c687825d Autogen: Refactor file lists computation 2d29166758 Autogen: Use cm::make_unique to allocate jobs 8182c21d2d Autogen: Use std::unordered_set instead of std::set for skip lists 84819c79e7 Autogen: Refactor cmQtAutoGenInitializer::AddGeneratedSource method d9893fb594 Autogen: Refactor Qt executable name computation 5e36209f71 Autogen: Rename cmQtAutoGen::GeneratorT enum to cmQtAutoGen::GenT 14ae19c327 Autogen: cmQtAutoGen: Store generator names in class static const strings Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3001
-rw-r--r--Source/cmQtAutoGen.cxx55
-rw-r--r--Source/cmQtAutoGen.h41
-rw-r--r--Source/cmQtAutoGenInitializer.cxx804
-rw-r--r--Source/cmQtAutoGenInitializer.h98
-rw-r--r--Source/cmQtAutoGenerator.cxx22
-rw-r--r--Source/cmQtAutoGenerator.h20
-rw-r--r--Source/cmQtAutoGeneratorMocUic.cxx242
-rw-r--r--Source/cmQtAutoGeneratorMocUic.h28
-rw-r--r--Source/cmQtAutoGeneratorRcc.cxx78
9 files changed, 762 insertions, 626 deletions
diff --git a/Source/cmQtAutoGen.cxx b/Source/cmQtAutoGen.cxx
index f437138..25ef4fc 100644
--- a/Source/cmQtAutoGen.cxx
+++ b/Source/cmQtAutoGen.cxx
@@ -11,13 +11,6 @@
#include <sstream>
#include <utility>
-// - Static variables
-
-std::string const genNameGen = "AutoGen";
-std::string const genNameMoc = "AutoMoc";
-std::string const genNameUic = "AutoUic";
-std::string const genNameRcc = "AutoRcc";
-
// - Static functions
/// @brief Merges newOpts into baseOpts
@@ -77,27 +70,47 @@ void MergeOptions(std::vector<std::string>& baseOpts,
// - Class definitions
-std::string const cmQtAutoGen::ListSep = "<<<S>>>";
unsigned int const cmQtAutoGen::ParallelMax = 64;
+std::string const cmQtAutoGen::ListSep = "<<<S>>>";
-std::string const& cmQtAutoGen::GeneratorName(GeneratorT type)
+std::string const cmQtAutoGen::GenNameGen = "AutoGen";
+std::string const cmQtAutoGen::GenNameMoc = "AutoMoc";
+std::string const cmQtAutoGen::GenNameUic = "AutoUic";
+std::string const cmQtAutoGen::GenNameRcc = "AutoRcc";
+
+std::string const cmQtAutoGen::GenNameGenUpper = "AUTOGEN";
+std::string const cmQtAutoGen::GenNameMocUpper = "AUTOMOC";
+std::string const cmQtAutoGen::GenNameUicUpper = "AUTOUIC";
+std::string const cmQtAutoGen::GenNameRccUpper = "AUTORCC";
+
+std::string const& cmQtAutoGen::GeneratorName(GenT genType)
{
- switch (type) {
- case GeneratorT::GEN:
- return genNameGen;
- case GeneratorT::MOC:
- return genNameMoc;
- case GeneratorT::UIC:
- return genNameUic;
- case GeneratorT::RCC:
- return genNameRcc;
+ switch (genType) {
+ case GenT::GEN:
+ return GenNameGen;
+ case GenT::MOC:
+ return GenNameMoc;
+ case GenT::UIC:
+ return GenNameUic;
+ case GenT::RCC:
+ return GenNameRcc;
}
- return genNameGen;
+ return GenNameGen;
}
-std::string cmQtAutoGen::GeneratorNameUpper(GeneratorT genType)
+std::string const& cmQtAutoGen::GeneratorNameUpper(GenT genType)
{
- return cmSystemTools::UpperCase(cmQtAutoGen::GeneratorName(genType));
+ switch (genType) {
+ case GenT::GEN:
+ return GenNameGenUpper;
+ case GenT::MOC:
+ return GenNameMocUpper;
+ case GenT::UIC:
+ return GenNameUicUpper;
+ case GenT::RCC:
+ return GenNameRccUpper;
+ }
+ return GenNameGenUpper;
}
std::string cmQtAutoGen::Tools(bool moc, bool uic, bool rcc)
diff --git a/Source/cmQtAutoGen.h b/Source/cmQtAutoGen.h
index 96d1946..e62a947 100644
--- a/Source/cmQtAutoGen.h
+++ b/Source/cmQtAutoGen.h
@@ -14,20 +14,6 @@
class cmQtAutoGen
{
public:
- /// @brief Nested lists separator
- static std::string const ListSep;
- /// @brief Maximum number of parallel threads/processes in a generator
- static unsigned int const ParallelMax;
-
- /// @brief AutoGen generator type
- enum class GeneratorT
- {
- GEN, // General
- MOC,
- UIC,
- RCC
- };
-
/// @brief Integer version
struct IntegerVersion
{
@@ -54,11 +40,34 @@ public:
}
};
+ /// @brief AutoGen generator type
+ enum class GenT
+ {
+ GEN, // AUTOGEN
+ MOC, // AUTOMOC
+ UIC, // AUTOUIC
+ RCC // AUTORCC
+ };
+
+ /// @brief Nested lists separator
+ static std::string const ListSep;
+ // Generator names
+ static std::string const GenNameGen;
+ static std::string const GenNameMoc;
+ static std::string const GenNameUic;
+ static std::string const GenNameRcc;
+ static std::string const GenNameGenUpper;
+ static std::string const GenNameMocUpper;
+ static std::string const GenNameUicUpper;
+ static std::string const GenNameRccUpper;
+ /// @brief Maximum number of parallel threads/processes in a generator
+ static unsigned int const ParallelMax;
+
public:
/// @brief Returns the generator name
- static std::string const& GeneratorName(GeneratorT genType);
+ static std::string const& GeneratorName(GenT genType);
/// @brief Returns the generator name in upper case
- static std::string GeneratorNameUpper(GeneratorT genType);
+ static std::string const& GeneratorNameUpper(GenT genType);
/// @brief Returns a string with the requested tool names
static std::string Tools(bool moc, bool uic, bool rcc);
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index 614a88b..2fb6fdf 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -21,11 +21,13 @@
#include "cmPolicies.h"
#include "cmProcessOutput.h"
#include "cmSourceFile.h"
+#include "cmSourceFileLocationKind.h"
#include "cmSourceGroup.h"
#include "cmState.h"
#include "cmStateTypes.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
+#include "cmake.h"
#include "cmsys/FStream.hxx"
#include "cmsys/SystemInformation.hxx"
@@ -36,25 +38,9 @@
#include <set>
#include <sstream>
#include <string>
-#include <type_traits>
#include <utility>
#include <vector>
-std::string GetQtExecutableTargetName(
- const cmQtAutoGen::IntegerVersion& qtVersion, std::string const& executable)
-{
- if (qtVersion.Major == 6) {
- return ("Qt6::" + executable);
- }
- if (qtVersion.Major == 5) {
- return ("Qt5::" + executable);
- }
- if (qtVersion.Major == 4) {
- return ("Qt4::" + executable);
- }
- return ("");
-}
-
static std::size_t GetParallelCPUCount()
{
static std::size_t count = 0;
@@ -69,58 +55,6 @@ static std::size_t GetParallelCPUCount()
return count;
}
-static bool AddToSourceGroup(cmMakefile* makefile, std::string const& fileName,
- cmQtAutoGen::GeneratorT genType)
-{
- cmSourceGroup* sourceGroup = nullptr;
- // Acquire source group
- {
- std::string property;
- std::string groupName;
- {
- std::array<std::string, 2> props;
- // Use generator specific group name
- switch (genType) {
- case cmQtAutoGen::GeneratorT::MOC:
- props[0] = "AUTOMOC_SOURCE_GROUP";
- break;
- case cmQtAutoGen::GeneratorT::RCC:
- props[0] = "AUTORCC_SOURCE_GROUP";
- break;
- default:
- props[0] = "AUTOGEN_SOURCE_GROUP";
- break;
- }
- props[1] = "AUTOGEN_SOURCE_GROUP";
- for (std::string& prop : props) {
- const char* propName = makefile->GetState()->GetGlobalProperty(prop);
- if ((propName != nullptr) && (*propName != '\0')) {
- groupName = propName;
- property = std::move(prop);
- break;
- }
- }
- }
- // Generate a source group on demand
- if (!groupName.empty()) {
- sourceGroup = makefile->GetOrCreateSourceGroup(groupName);
- if (sourceGroup == nullptr) {
- std::ostringstream ost;
- ost << cmQtAutoGen::GeneratorNameUpper(genType);
- ost << ": " << property;
- ost << ": Could not find or create the source group ";
- ost << cmQtAutoGen::Quoted(groupName);
- cmSystemTools::Error(ost.str());
- return false;
- }
- }
- }
- if (sourceGroup != nullptr) {
- sourceGroup->AddGroupFile(fileName);
- }
- return true;
-}
-
static void AddCleanFile(cmMakefile* makefile, std::string const& fileName)
{
makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", fileName.c_str(),
@@ -343,6 +277,26 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
}
}
+ // Check status of policy CMP0071
+ {
+ cmPolicies::PolicyStatus const CMP0071_status =
+ makefile->GetPolicyStatus(cmPolicies::CMP0071);
+ switch (CMP0071_status) {
+ case cmPolicies::WARN:
+ this->CMP0071Warn = true;
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ // Ignore GENERATED file
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ // Process GENERATED file
+ this->CMP0071Accept = true;
+ break;
+ }
+ }
+
// Common directories
{
// Collapsed current binary directory
@@ -392,23 +346,15 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
}
// Moc, Uic and _autogen target settings
- if (this->Moc.Enabled || this->Uic.Enabled) {
+ if (this->MocOrUicEnabled()) {
// Init moc specific settings
if (this->Moc.Enabled && !InitMoc()) {
return false;
}
// Init uic specific settings
- if (this->Uic.Enabled) {
- if (InitUic()) {
- auto* uicTarget = makefile->FindTargetToUse(
- GetQtExecutableTargetName(this->QtVersion, "uic"));
- if (uicTarget != nullptr) {
- this->AutogenTarget.DependTargets.insert(uicTarget);
- }
- } else {
- return false;
- }
+ if (this->Uic.Enabled && !InitUic()) {
+ return false;
}
// Autogen target name
@@ -449,12 +395,6 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
this->AutogenTarget.DependOrigin =
this->Target->GetPropertyAsBool("AUTOGEN_ORIGIN_DEPENDS");
- auto* mocTarget = makefile->FindTargetToUse(
- GetQtExecutableTargetName(this->QtVersion, "moc"));
- if (mocTarget != nullptr) {
- this->AutogenTarget.DependTargets.insert(mocTarget);
- }
-
std::string const deps =
this->Target->GetSafeProperty("AUTOGEN_TARGET_DEPENDS");
if (!deps.empty()) {
@@ -479,8 +419,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
}
// Add autogen include directory to the origin target INCLUDE_DIRECTORIES
- if (this->Moc.Enabled || this->Uic.Enabled ||
- (this->Rcc.Enabled && this->MultiConfig)) {
+ if (this->MocOrUicEnabled() || (this->Rcc.Enabled && this->MultiConfig)) {
this->Target->AddIncludeDirectory(this->Dir.Include, true);
}
@@ -490,7 +429,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
}
// Create autogen target
- if ((this->Moc.Enabled || this->Uic.Enabled) && !this->InitAutogenTarget()) {
+ if (this->MocOrUicEnabled() && !this->InitAutogenTarget()) {
return false;
}
@@ -575,7 +514,18 @@ bool cmQtAutoGenInitializer::InitMoc()
}
// Moc executable
- return GetMocExecutable();
+ {
+ if (!this->GetQtExecutable(this->Moc, "moc", false, nullptr)) {
+ return false;
+ }
+ // Let the _autogen target depend on the moc executable
+ if (this->Moc.ExecutableTarget != nullptr) {
+ this->AutogenTarget.DependTargets.insert(
+ this->Moc.ExecutableTarget->Target);
+ }
+ }
+
+ return true;
}
bool cmQtAutoGenInitializer::InitUic()
@@ -618,12 +568,39 @@ bool cmQtAutoGenInitializer::InitUic()
}
// Uic executable
- return GetUicExecutable();
+ {
+ if (!this->GetQtExecutable(this->Uic, "uic", true, nullptr)) {
+ return false;
+ }
+ // Let the _autogen target depend on the uic executable
+ if (this->Uic.ExecutableTarget != nullptr) {
+ this->AutogenTarget.DependTargets.insert(
+ this->Uic.ExecutableTarget->Target);
+ }
+ }
+
+ return true;
}
bool cmQtAutoGenInitializer::InitRcc()
{
- return GetRccExecutable();
+ // Rcc executable
+ {
+ std::string stdOut;
+ if (!this->GetQtExecutable(this->Rcc, "rcc", false, &stdOut)) {
+ return false;
+ }
+ // Evaluate test output
+ if (this->QtVersion.Major == 5 || this->QtVersion.Major == 6) {
+ if (stdOut.find("--list") != std::string::npos) {
+ this->Rcc.ListOptions.emplace_back("--list");
+ } else {
+ this->Rcc.ListOptions.emplace_back("-list");
+ }
+ }
+ }
+
+ return true;
}
bool cmQtAutoGenInitializer::InitScanFiles()
@@ -634,61 +611,78 @@ bool cmQtAutoGenInitializer::InitScanFiles()
std::string const SKIP_AUTOGEN_str = "SKIP_AUTOGEN";
std::string const SKIP_AUTOMOC_str = "SKIP_AUTOMOC";
std::string const SKIP_AUTOUIC_str = "SKIP_AUTOUIC";
+ std::string const SKIP_AUTORCC_str = "SKIP_AUTORCC";
+ std::string const AUTOUIC_OPTIONS_str = "AUTOUIC_OPTIONS";
+ std::string const AUTORCC_OPTIONS_str = "AUTORCC_OPTIONS";
+ std::string const qrc_str = "qrc";
+ std::string const ui_str = "ui";
+
+ auto makeMUFile = [&](cmSourceFile* sf, std::string const& fullPath,
+ bool muIt) -> MUFileHandle {
+ MUFileHandle muf = cm::make_unique<MUFile>();
+ muf->RealPath = cmSystemTools::GetRealPath(fullPath);
+ muf->SF = sf;
+ muf->Generated = sf->GetIsGenerated();
+ bool const skipAutogen = sf->GetPropertyAsBool(SKIP_AUTOGEN_str);
+ muf->SkipMoc = this->Moc.Enabled &&
+ (skipAutogen || sf->GetPropertyAsBool(SKIP_AUTOMOC_str));
+ muf->SkipUic = this->Uic.Enabled &&
+ (skipAutogen || sf->GetPropertyAsBool(SKIP_AUTOUIC_str));
+ if (muIt) {
+ muf->MocIt = this->Moc.Enabled && !muf->SkipMoc;
+ muf->UicIt = this->Uic.Enabled && !muf->SkipUic;
+ }
+ return muf;
+ };
+
+ auto addMUFile = [&](MUFileHandle&& muf, bool isHeader) {
+ if ((muf->MocIt || muf->UicIt) && muf->Generated) {
+ this->AutogenTarget.FilesGenerated.emplace_back(muf.get());
+ }
+ if (isHeader) {
+ this->AutogenTarget.Headers.emplace(muf->SF, std::move(muf));
+ } else {
+ this->AutogenTarget.Sources.emplace(muf->SF, std::move(muf));
+ }
+ };
// Scan through target files
{
- // String constants
- std::string const qrc_str = "qrc";
- std::string const SKIP_AUTORCC_str = "SKIP_AUTORCC";
- std::string const AUTORCC_OPTIONS_str = "AUTORCC_OPTIONS";
-
// Scan through target files
std::vector<cmSourceFile*> srcFiles;
this->Target->GetConfigCommonSourceFiles(srcFiles);
for (cmSourceFile* sf : srcFiles) {
- if (sf->GetPropertyAsBool(SKIP_AUTOGEN_str)) {
+ // sf->GetExtension() is only valid after sf->GetFullPath() ...
+ // Since we're iterating over source files that might be not in the
+ // target we need to check for path errors (not existing files).
+ std::string pathError;
+ std::string const& fullPath = sf->GetFullPath(&pathError);
+ if (!pathError.empty() || fullPath.empty()) {
continue;
}
-
- // sf->GetExtension() is only valid after sf->GetFullPath() ...
- std::string const& fPath = sf->GetFullPath();
std::string const& ext = sf->GetExtension();
- // Register generated files that will be scanned by moc or uic
- if (this->Moc.Enabled || this->Uic.Enabled) {
- cmSystemTools::FileFormat const fileType =
- cmSystemTools::GetFileFormat(ext);
- if ((fileType == cmSystemTools::CXX_FILE_FORMAT) ||
- (fileType == cmSystemTools::HEADER_FILE_FORMAT)) {
- std::string const absPath = cmSystemTools::GetRealPath(fPath);
- if ((this->Moc.Enabled &&
- !sf->GetPropertyAsBool(SKIP_AUTOMOC_str)) ||
- (this->Uic.Enabled &&
- !sf->GetPropertyAsBool(SKIP_AUTOUIC_str))) {
- // Register source
- const bool generated = sf->GetIsGenerated();
- if (fileType == cmSystemTools::HEADER_FILE_FORMAT) {
- if (generated) {
- this->AutogenTarget.HeadersGenerated.push_back(absPath);
- } else {
- this->AutogenTarget.Headers.push_back(absPath);
- }
- } else {
- if (generated) {
- this->AutogenTarget.SourcesGenerated.push_back(absPath);
- } else {
- this->AutogenTarget.Sources.push_back(absPath);
- }
- }
- }
+ // Register files that will be scanned by moc or uic
+ if (this->MocOrUicEnabled()) {
+ switch (cmSystemTools::GetFileFormat(ext)) {
+ case cmSystemTools::HEADER_FILE_FORMAT:
+ addMUFile(makeMUFile(sf, fullPath, true), true);
+ break;
+ case cmSystemTools::CXX_FILE_FORMAT:
+ addMUFile(makeMUFile(sf, fullPath, true), false);
+ break;
+ default:
+ break;
}
}
+
// Register rcc enabled files
if (this->Rcc.Enabled) {
- if ((ext == qrc_str) && !sf->GetPropertyAsBool(SKIP_AUTORCC_str)) {
+ if ((ext == qrc_str) && !sf->GetPropertyAsBool(SKIP_AUTOGEN_str) &&
+ !sf->GetPropertyAsBool(SKIP_AUTORCC_str)) {
// Register qrc file
Qrc qrc;
- qrc.QrcFile = cmSystemTools::GetRealPath(fPath);
+ qrc.QrcFile = cmSystemTools::GetRealPath(fullPath);
qrc.QrcName =
cmSystemTools::GetFilenameWithoutLastExtension(qrc.QrcFile);
qrc.Generated = sf->GetIsGenerated();
@@ -710,15 +704,72 @@ bool cmQtAutoGenInitializer::InitScanFiles()
// mocs_compilation.cpp source acknowledged by this target.
this->Target->ClearSourcesCache();
+ // For source files find additional headers and private headers
+ if (this->MocOrUicEnabled()) {
+ std::vector<MUFileHandle> extraHeaders;
+ extraHeaders.reserve(this->AutogenTarget.Sources.size() * 2);
+ // Header search suffixes and extensions
+ std::array<std::string, 2> const suffixes{ { "", "_p" } };
+ auto const& exts = makefile->GetCMakeInstance()->GetHeaderExtensions();
+ // Scan through sources
+ for (auto const& pair : this->AutogenTarget.Sources) {
+ MUFile const& muf = *pair.second;
+ if (muf.MocIt || muf.UicIt) {
+ // Search for the default header file and a private header
+ std::string const& realPath = muf.RealPath;
+ std::string basePath = cmQtAutoGen::SubDirPrefix(realPath);
+ basePath += cmSystemTools::GetFilenameWithoutLastExtension(realPath);
+ for (auto const& suffix : suffixes) {
+ std::string const suffixedPath = basePath + suffix;
+ for (auto const& ext : exts) {
+ std::string fullPath = suffixedPath;
+ fullPath += '.';
+ fullPath += ext;
+
+ auto constexpr locationKind = cmSourceFileLocationKind::Known;
+ cmSourceFile* sf = makefile->GetSource(fullPath, locationKind);
+ if (sf != nullptr) {
+ // Check if we know about this header already
+ if (this->AutogenTarget.Headers.find(sf) !=
+ this->AutogenTarget.Headers.end()) {
+ continue;
+ }
+ // We only accept not-GENERATED files that do exist.
+ if (!sf->GetIsGenerated() &&
+ !cmSystemTools::FileExists(fullPath)) {
+ continue;
+ }
+ } else if (cmSystemTools::FileExists(fullPath)) {
+ // Create a new source file for the existing file
+ sf = makefile->CreateSource(fullPath, false, locationKind);
+ }
+
+ if (sf != nullptr) {
+ auto eMuf = makeMUFile(sf, fullPath, true);
+ // Ony process moc/uic when the parent is processed as well
+ if (!muf.MocIt) {
+ eMuf->MocIt = false;
+ }
+ if (!muf.UicIt) {
+ eMuf->UicIt = false;
+ }
+ extraHeaders.emplace_back(std::move(eMuf));
+ }
+ }
+ }
+ }
+ }
+ // Move generated files to main headers list
+ for (auto& eMuf : extraHeaders) {
+ addMUFile(std::move(eMuf), true);
+ }
+ }
+
// Scan through all source files in the makefile to extract moc and uic
// parameters. Historically we support non target source file parameters.
// The reason is that their file names might be discovered from source files
// at generation time.
- if (this->Moc.Enabled || this->Uic.Enabled) {
- // String constants
- std::string const ui_str = "ui";
- std::string const AUTOUIC_OPTIONS_str = "AUTOUIC_OPTIONS";
-
+ if (this->MocOrUicEnabled()) {
for (cmSourceFile* sf : makefile->GetSourceFiles()) {
// sf->GetExtension() is only valid after sf->GetFullPath() ...
// Since we're iterating over source files that might be not in the
@@ -728,132 +779,87 @@ bool cmQtAutoGenInitializer::InitScanFiles()
if (!pathError.empty() || fullPath.empty()) {
continue;
}
+ std::string const& ext = sf->GetExtension();
- // Check file type
- auto const fileType = cmSystemTools::GetFileFormat(sf->GetExtension());
- bool const isSource = (fileType == cmSystemTools::CXX_FILE_FORMAT) ||
- (fileType == cmSystemTools::HEADER_FILE_FORMAT);
- bool const isUi = (this->Moc.Enabled && sf->GetExtension() == ui_str);
-
- // Process only certain file types
- if (isSource || isUi) {
- std::string const absFile = cmSystemTools::GetRealPath(fullPath);
- // Acquire file properties
- bool const skipAUTOGEN = sf->GetPropertyAsBool(SKIP_AUTOGEN_str);
- bool const skipMoc = (this->Moc.Enabled && isSource) &&
- (skipAUTOGEN || sf->GetPropertyAsBool(SKIP_AUTOMOC_str));
- bool const skipUic = this->Uic.Enabled &&
- (skipAUTOGEN || sf->GetPropertyAsBool(SKIP_AUTOUIC_str));
-
- // Register moc and uic skipped file
- if (skipMoc) {
- this->Moc.Skip.insert(absFile);
+ auto const fileFormat = cmSystemTools::GetFileFormat(ext);
+ if (fileFormat == cmSystemTools::HEADER_FILE_FORMAT) {
+ if (this->AutogenTarget.Headers.find(sf) ==
+ this->AutogenTarget.Headers.end()) {
+ auto muf = makeMUFile(sf, fullPath, false);
+ if (muf->SkipMoc || muf->SkipUic) {
+ this->AutogenTarget.Headers.emplace(sf, std::move(muf));
+ }
}
- if (skipUic) {
- this->Uic.Skip.insert(absFile);
+ } else if (fileFormat == cmSystemTools::CXX_FILE_FORMAT) {
+ if (this->AutogenTarget.Sources.find(sf) ==
+ this->AutogenTarget.Sources.end()) {
+ auto muf = makeMUFile(sf, fullPath, false);
+ if (muf->SkipMoc || muf->SkipUic) {
+ this->AutogenTarget.Sources.emplace(sf, std::move(muf));
+ }
}
-
- // Check if the .ui file has uic options
- if (isUi && !skipUic) {
+ } else if (this->Uic.Enabled && (ext == ui_str)) {
+ // .ui file
+ std::string realPath = cmSystemTools::GetRealPath(fullPath);
+ bool const skipAutogen = sf->GetPropertyAsBool(SKIP_AUTOGEN_str);
+ bool const skipUic =
+ (skipAutogen || sf->GetPropertyAsBool(SKIP_AUTOUIC_str));
+ if (!skipUic) {
+ // Check if the .ui file has uic options
std::string const uicOpts = sf->GetSafeProperty(AUTOUIC_OPTIONS_str);
if (!uicOpts.empty()) {
- this->Uic.FileFiles.push_back(absFile);
+ this->Uic.FileFiles.push_back(std::move(realPath));
std::vector<std::string> optsVec;
cmSystemTools::ExpandListArgument(uicOpts, optsVec);
this->Uic.FileOptions.push_back(std::move(optsVec));
}
+ } else {
+ // Register skipped .ui file
+ this->Uic.SkipUi.insert(std::move(realPath));
}
}
}
}
// Process GENERATED sources and headers
- if (this->Moc.Enabled || this->Uic.Enabled) {
- if (!this->AutogenTarget.SourcesGenerated.empty() ||
- !this->AutogenTarget.HeadersGenerated.empty()) {
- // Check status of policy CMP0071
- bool policyAccept = false;
- bool policyWarn = false;
- cmPolicies::PolicyStatus const CMP0071_status =
- makefile->GetPolicyStatus(cmPolicies::CMP0071);
- switch (CMP0071_status) {
- case cmPolicies::WARN:
- policyWarn = true;
- CM_FALLTHROUGH;
- case cmPolicies::OLD:
- // Ignore GENERATED file
- break;
- case cmPolicies::REQUIRED_IF_USED:
- case cmPolicies::REQUIRED_ALWAYS:
- case cmPolicies::NEW:
- // Process GENERATED file
- policyAccept = true;
- break;
+ if (this->MocOrUicEnabled() && !this->AutogenTarget.FilesGenerated.empty()) {
+ if (this->CMP0071Accept) {
+ // Let the autogen target depend on the GENERATED files
+ for (MUFile* muf : this->AutogenTarget.FilesGenerated) {
+ this->AutogenTarget.DependFiles.insert(muf->RealPath);
}
-
- if (policyAccept) {
- // Accept GENERATED sources
- for (std::string const& absFile :
- this->AutogenTarget.HeadersGenerated) {
- this->AutogenTarget.Headers.push_back(absFile);
- this->AutogenTarget.DependFiles.insert(absFile);
- }
- for (std::string const& absFile :
- this->AutogenTarget.SourcesGenerated) {
- this->AutogenTarget.Sources.push_back(absFile);
- this->AutogenTarget.DependFiles.insert(absFile);
- }
- } else {
- if (policyWarn) {
- std::string msg;
- msg += cmPolicies::GetPolicyWarning(cmPolicies::CMP0071);
- msg += "\n";
- std::string tools;
- std::string property;
- if (this->Moc.Enabled && this->Uic.Enabled) {
- tools = "AUTOMOC and AUTOUIC";
- property = "SKIP_AUTOGEN";
- } else if (this->Moc.Enabled) {
- tools = "AUTOMOC";
- property = "SKIP_AUTOMOC";
- } else if (this->Uic.Enabled) {
- tools = "AUTOUIC";
- property = "SKIP_AUTOUIC";
- }
- msg += "For compatibility, CMake is excluding the GENERATED source "
- "file(s):\n";
- for (const std::string& absFile :
- this->AutogenTarget.HeadersGenerated) {
- msg.append(" ").append(Quoted(absFile)).append("\n");
- }
- for (const std::string& absFile :
- this->AutogenTarget.SourcesGenerated) {
- msg.append(" ").append(Quoted(absFile)).append("\n");
- }
- msg += "from processing by ";
- msg += tools;
- msg +=
- ". If any of the files should be processed, set CMP0071 to NEW. "
- "If any of the files should not be processed, "
- "explicitly exclude them by setting the source file property ";
- msg += property;
- msg += ":\n set_property(SOURCE file.h PROPERTY ";
- msg += property;
- msg += " ON)\n";
- makefile->IssueMessage(MessageType::AUTHOR_WARNING, msg);
- }
+ } else if (this->CMP0071Warn) {
+ std::string msg;
+ msg += cmPolicies::GetPolicyWarning(cmPolicies::CMP0071);
+ msg += '\n';
+ std::string property;
+ if (this->Moc.Enabled && this->Uic.Enabled) {
+ property = "SKIP_AUTOGEN";
+ } else if (this->Moc.Enabled) {
+ property = "SKIP_AUTOMOC";
+ } else if (this->Uic.Enabled) {
+ property = "SKIP_AUTOUIC";
+ }
+ msg += "For compatibility, CMake is excluding the GENERATED source "
+ "file(s):\n";
+ for (MUFile* muf : this->AutogenTarget.FilesGenerated) {
+ msg += " ";
+ msg += Quoted(muf->RealPath);
+ msg += '\n';
}
+ msg += "from processing by ";
+ msg += cmQtAutoGen::Tools(this->Moc.Enabled, this->Uic.Enabled, false);
+ msg += ". If any of the files should be processed, set CMP0071 to NEW. "
+ "If any of the files should not be processed, "
+ "explicitly exclude them by setting the source file property ";
+ msg += property;
+ msg += ":\n set_property(SOURCE file.h PROPERTY ";
+ msg += property;
+ msg += " ON)\n";
+ makefile->IssueMessage(MessageType::AUTHOR_WARNING, msg);
}
}
- // Sort headers and sources
- if (this->Moc.Enabled || this->Uic.Enabled) {
- std::sort(this->AutogenTarget.Headers.begin(),
- this->AutogenTarget.Headers.end());
- std::sort(this->AutogenTarget.Sources.begin(),
- this->AutogenTarget.Sources.end());
- }
-
// Process qrc files
if (!this->Rcc.Qrcs.empty()) {
const bool modernQt = (this->QtVersion.Major >= 5);
@@ -961,7 +967,7 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
// Files provided by the autogen target
std::vector<std::string> autogenProvides;
if (this->Moc.Enabled) {
- this->AddGeneratedSource(this->Moc.MocsCompilation, GeneratorT::MOC, true);
+ this->AddGeneratedSource(this->Moc.MocsCompilation, this->Moc, true);
autogenProvides.push_back(this->Moc.MocsCompilation);
}
@@ -1109,13 +1115,12 @@ bool cmQtAutoGenInitializer::InitRccTargets()
{
cmMakefile* makefile = this->Target->Target->GetMakefile();
cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
- auto rccTargetName = GetQtExecutableTargetName(this->QtVersion, "rcc");
for (Qrc const& qrc : this->Rcc.Qrcs) {
// Register info file as generated by CMake
makefile->AddCMakeOutputFile(qrc.InfoFile);
// Register file at target
- this->AddGeneratedSource(qrc.RccFile, GeneratorT::RCC);
+ this->AddGeneratedSource(qrc.RccFile, this->Rcc);
std::vector<std::string> ccOutput;
ccOutput.push_back(qrc.RccFile);
@@ -1174,8 +1179,8 @@ bool cmQtAutoGenInitializer::InitRccTargets()
if (!this->TargetsFolder.empty()) {
autoRccTarget->SetProperty("FOLDER", this->TargetsFolder.c_str());
}
- if (!rccTargetName.empty()) {
- autoRccTarget->AddUtility(rccTargetName, makefile);
+ if (!this->Rcc.ExecutableTargetName.empty()) {
+ autoRccTarget->AddUtility(this->Rcc.ExecutableTargetName, makefile);
}
}
// Add autogen target to the origin target dependencies
@@ -1195,8 +1200,8 @@ bool cmQtAutoGenInitializer::InitRccTargets()
// Add resource file to the custom command dependencies
ccDepends.push_back(fileName);
}
- if (!rccTargetName.empty()) {
- ccDepends.push_back(rccTargetName);
+ if (!this->Rcc.ExecutableTargetName.empty()) {
+ ccDepends.push_back(this->Rcc.ExecutableTargetName);
}
makefile->AddCustomCommandToOutput(ccOutput, ccByproducts, ccDepends,
/*main_dependency*/ std::string(),
@@ -1222,7 +1227,7 @@ bool cmQtAutoGenInitializer::SetupCustomTargets()
}
// Generate autogen target info file
- if (this->Moc.Enabled || this->Uic.Enabled) {
+ if (this->MocOrUicEnabled()) {
// Write autogen target info files
if (!this->SetupWriteAutogenInfo()) {
return false;
@@ -1262,22 +1267,74 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
ofs.Write("AM_INCLUDE_DIR", this->Dir.Include);
ofs.WriteConfig("AM_INCLUDE_DIR", this->Dir.ConfigInclude);
- ofs.Write("# Files\n");
- ofs.WriteStrings("AM_SOURCES", this->AutogenTarget.Sources);
- ofs.WriteStrings("AM_HEADERS", this->AutogenTarget.Headers);
- ofs.Write("AM_SETTINGS_FILE", this->AutogenTarget.SettingsFile);
- ofs.WriteConfig("AM_SETTINGS_FILE",
- this->AutogenTarget.ConfigSettingsFile);
+ // Use sorted sets
+ std::set<std::string> headers;
+ std::set<std::string> sources;
+ std::set<std::string> moc_headers;
+ std::set<std::string> moc_sources;
+ std::set<std::string> moc_skip;
+ std::set<std::string> uic_headers;
+ std::set<std::string> uic_sources;
+ std::set<std::string> uic_skip;
+ // Filter headers
+ for (auto const& pair : this->AutogenTarget.Headers) {
+ MUFile const& muf = *pair.second;
+ if (muf.Generated && !this->CMP0071Accept) {
+ continue;
+ }
+ if (muf.SkipMoc) {
+ moc_skip.insert(muf.RealPath);
+ }
+ if (muf.SkipUic) {
+ uic_skip.insert(muf.RealPath);
+ }
+ if (muf.MocIt && muf.UicIt) {
+ headers.insert(muf.RealPath);
+ } else if (muf.MocIt) {
+ moc_headers.insert(muf.RealPath);
+ } else if (muf.UicIt) {
+ uic_headers.insert(muf.RealPath);
+ }
+ }
+ // Filter sources
+ for (auto const& pair : this->AutogenTarget.Sources) {
+ MUFile const& muf = *pair.second;
+ if (muf.Generated && !this->CMP0071Accept) {
+ continue;
+ }
+ if (muf.SkipMoc) {
+ moc_skip.insert(muf.RealPath);
+ }
+ if (muf.SkipUic) {
+ uic_skip.insert(muf.RealPath);
+ }
+ if (muf.MocIt && muf.UicIt) {
+ sources.insert(muf.RealPath);
+ } else if (muf.MocIt) {
+ moc_sources.insert(muf.RealPath);
+ } else if (muf.UicIt) {
+ uic_sources.insert(muf.RealPath);
+ }
+ }
ofs.Write("# Qt\n");
ofs.WriteUInt("AM_QT_VERSION_MAJOR", this->QtVersion.Major);
ofs.Write("AM_QT_MOC_EXECUTABLE", this->Moc.Executable);
ofs.Write("AM_QT_UIC_EXECUTABLE", this->Uic.Executable);
+ ofs.Write("# Files\n");
+ ofs.Write("AM_SETTINGS_FILE", this->AutogenTarget.SettingsFile);
+ ofs.WriteConfig("AM_SETTINGS_FILE",
+ this->AutogenTarget.ConfigSettingsFile);
+ ofs.WriteStrings("AM_HEADERS", headers);
+ ofs.WriteStrings("AM_SOURCES", sources);
+
// Write moc settings
if (this->Moc.Enabled) {
ofs.Write("# MOC settings\n");
- ofs.WriteStrings("AM_MOC_SKIP", this->Moc.Skip);
+ ofs.WriteStrings("AM_MOC_HEADERS", moc_headers);
+ ofs.WriteStrings("AM_MOC_SOURCES", moc_sources);
+ ofs.WriteStrings("AM_MOC_SKIP", moc_skip);
ofs.WriteStrings("AM_MOC_DEFINITIONS", this->Moc.Defines);
ofs.WriteConfigStrings("AM_MOC_DEFINITIONS", this->Moc.ConfigDefines);
ofs.WriteStrings("AM_MOC_INCLUDES", this->Moc.Includes);
@@ -1294,8 +1351,13 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
// Write uic settings
if (this->Uic.Enabled) {
+ // Add skipped .ui files
+ uic_skip.insert(this->Uic.SkipUi.begin(), this->Uic.SkipUi.end());
+
ofs.Write("# UIC settings\n");
- ofs.WriteStrings("AM_UIC_SKIP", this->Uic.Skip);
+ ofs.WriteStrings("AM_UIC_HEADERS", uic_headers);
+ ofs.WriteStrings("AM_UIC_SOURCES", uic_sources);
+ ofs.WriteStrings("AM_UIC_SKIP", uic_skip);
ofs.WriteStrings("AM_UIC_TARGET_OPTIONS", this->Uic.Options);
ofs.WriteConfigStrings("AM_UIC_TARGET_OPTIONS", this->Uic.ConfigOptions);
ofs.WriteStrings("AM_UIC_OPTIONS_FILES", this->Uic.FileFiles);
@@ -1353,23 +1415,68 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo()
return true;
}
-void cmQtAutoGenInitializer::AddGeneratedSource(std::string const& filename,
- GeneratorT genType,
- bool prepend)
+void cmQtAutoGenInitializer::RegisterGeneratedSource(
+ std::string const& filename)
{
- // Register source file in makefile
cmMakefile* makefile = this->Target->Target->GetMakefile();
- {
- cmSourceFile* gFile = makefile->GetOrCreateSource(filename, true);
- gFile->SetProperty("GENERATED", "1");
- gFile->SetProperty("SKIP_AUTOGEN", "On");
- }
-
- // Add source file to source group
- AddToSourceGroup(makefile, filename, genType);
+ cmSourceFile* gFile = makefile->GetOrCreateSource(filename, true);
+ gFile->SetProperty("GENERATED", "1");
+ gFile->SetProperty("SKIP_AUTOGEN", "1");
+}
+bool cmQtAutoGenInitializer::AddGeneratedSource(std::string const& filename,
+ GenVarsT const& genVars,
+ bool prepend)
+{
+ // Register source at makefile
+ this->RegisterGeneratedSource(filename);
// Add source file to target
this->Target->AddSource(filename, prepend);
+ // Add source file to source group
+ return this->AddToSourceGroup(filename, genVars.GenNameUpper);
+}
+
+bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName,
+ std::string const& genNameUpper)
+{
+ cmMakefile* makefile = this->Target->Target->GetMakefile();
+ cmSourceGroup* sourceGroup = nullptr;
+ // Acquire source group
+ {
+ std::string property;
+ std::string groupName;
+ {
+ // Prefer generator specific source group name
+ std::array<std::string, 2> props{ { genNameUpper + "_SOURCE_GROUP",
+ "AUTOGEN_SOURCE_GROUP" } };
+ for (std::string& prop : props) {
+ const char* propName = makefile->GetState()->GetGlobalProperty(prop);
+ if ((propName != nullptr) && (*propName != '\0')) {
+ groupName = propName;
+ property = std::move(prop);
+ break;
+ }
+ }
+ }
+ // Generate a source group on demand
+ if (!groupName.empty()) {
+ sourceGroup = makefile->GetOrCreateSourceGroup(groupName);
+ if (sourceGroup == nullptr) {
+ std::string err;
+ err += genNameUpper;
+ err += " error in ";
+ err += property;
+ err += ": Could not find or create the source group ";
+ err += cmQtAutoGen::Quoted(groupName);
+ cmSystemTools::Error(err);
+ return false;
+ }
+ }
+ }
+ if (sourceGroup != nullptr) {
+ sourceGroup->AddGroupFile(fileName);
+ }
+ return true;
}
static unsigned int CharPtrToUInt(const char* const input)
@@ -1384,8 +1491,12 @@ static unsigned int CharPtrToUInt(const char* const input)
static std::vector<cmQtAutoGen::IntegerVersion> GetKnownQtVersions(
cmGeneratorTarget const* target)
{
- cmMakefile* makefile = target->Target->GetMakefile();
+ // Qt version variable prefixes
+ static std::array<std::string, 3> const prefixes{ { "Qt6Core", "Qt5Core",
+ "QT" } };
+
std::vector<cmQtAutoGen::IntegerVersion> result;
+ result.reserve(prefixes.size() * 2);
// Adds a version to the result (nullptr safe)
auto addVersion = [&result](const char* major, const char* minor) {
cmQtAutoGen::IntegerVersion ver(CharPtrToUInt(major),
@@ -1394,8 +1505,7 @@ static std::vector<cmQtAutoGen::IntegerVersion> GetKnownQtVersions(
result.emplace_back(ver);
}
};
- // Qt version variable prefixes
- std::array<std::string, 3> const prefixes{ { "Qt6Core", "Qt5Core", "QT" } };
+ cmMakefile* makefile = target->Target->GetMakefile();
// Read versions from variables
for (const std::string& prefix : prefixes) {
@@ -1439,99 +1549,89 @@ cmQtAutoGenInitializer::GetQtVersion(cmGeneratorTarget const* target)
return res;
}
-std::pair<bool, std::string> cmQtAutoGenInitializer::GetQtExecutable(
- const std::string& executable, bool ignoreMissingTarget, std::string* output)
+bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars,
+ const std::string& executable,
+ bool ignoreMissingTarget,
+ std::string* output) const
{
- const std::string upperExecutable = cmSystemTools::UpperCase(executable);
- std::string result = this->Target->Target->GetSafeProperty(
- "AUTO" + upperExecutable + "_EXECUTABLE");
- if (!result.empty()) {
- cmListFileBacktrace lfbt =
- this->Target->Target->GetMakefile()->GetBacktrace();
- cmGeneratorExpression ge(lfbt);
- std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(result);
- result = cge->Evaluate(this->Target->GetLocalGenerator(), "");
-
- return std::make_pair(true, result);
- }
+ auto print_err = [this, &genVars](std::string const& err) {
+ std::string msg = genVars.GenNameUpper;
+ msg += " for target ";
+ msg += this->Target->GetName();
+ msg += ": ";
+ msg += err;
+ cmSystemTools::Error(msg);
+ };
- std::string err;
+ // Custom executable
+ {
+ std::string const prop = genVars.GenNameUpper + "_EXECUTABLE";
+ std::string const val = this->Target->Target->GetSafeProperty(prop);
+ if (!val.empty()) {
+ // Evaluate generator expression
+ {
+ cmListFileBacktrace lfbt =
+ this->Target->Target->GetMakefile()->GetBacktrace();
+ cmGeneratorExpression ge(lfbt);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(val);
+ genVars.Executable =
+ cge->Evaluate(this->Target->GetLocalGenerator(), "");
+ }
+ if (genVars.Executable.empty() && !ignoreMissingTarget) {
+ print_err(prop + " evaluates to an empty value");
+ return false;
+ }
+ return true;
+ }
+ }
- // Find executable
+ // Find executable target
{
- const std::string targetName =
- GetQtExecutableTargetName(this->QtVersion, executable);
- if (targetName.empty()) {
- err = "The AUTO" + upperExecutable + " feature ";
- err += "supports only Qt 4, Qt 5 and Qt 6.";
- } else {
- cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
- cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse(targetName);
- if (tgt != nullptr) {
- if (tgt->IsImported()) {
- result = tgt->ImportedGetLocation("");
- } else {
- result = tgt->GetLocation("");
- }
+ // Find executable target name
+ std::string targetName;
+ if (this->QtVersion.Major == 4) {
+ targetName = "Qt4::";
+ } else if (this->QtVersion.Major == 5) {
+ targetName = "Qt5::";
+ } else if (this->QtVersion.Major == 6) {
+ targetName = "Qt6::";
+ }
+ targetName += executable;
+
+ // Find target
+ cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
+ cmGeneratorTarget* target = localGen->FindGeneratorTargetToUse(targetName);
+ if (target != nullptr) {
+ genVars.ExecutableTargetName = targetName;
+ genVars.ExecutableTarget = target;
+ if (target->IsImported()) {
+ genVars.Executable = target->ImportedGetLocation("");
} else {
- if (ignoreMissingTarget) {
- return std::make_pair(true, "");
- }
-
- err = "Could not find target " + targetName;
+ genVars.Executable = target->GetLocation("");
}
+ } else {
+ if (ignoreMissingTarget) {
+ return true;
+ }
+ std::string err = "Could not find ";
+ err += executable;
+ err += " executable target ";
+ err += targetName;
+ print_err(err);
+ return false;
}
}
// Test executable
- if (err.empty()) {
- this->GlobalInitializer->GetExecutableTestOutput(executable, result, err,
- output);
- }
-
- // Print error
- if (!err.empty()) {
- std::string msg = "AutoGen (";
- msg += this->Target->GetName();
- msg += "): ";
- msg += err;
- cmSystemTools::Error(msg);
- return std::make_pair(false, "");
- }
-
- return std::make_pair(true, result);
-}
-
-bool cmQtAutoGenInitializer::GetMocExecutable()
-{
- const auto result = this->GetQtExecutable("moc", false, nullptr);
- this->Moc.Executable = result.second;
- return result.first;
-}
-
-bool cmQtAutoGenInitializer::GetUicExecutable()
-{
- const auto result = this->GetQtExecutable("uic", true, nullptr);
- this->Uic.Executable = result.second;
- return result.first;
-}
-
-bool cmQtAutoGenInitializer::GetRccExecutable()
-{
- std::string stdOut;
- const auto result = this->GetQtExecutable("rcc", false, &stdOut);
- this->Rcc.Executable = result.second;
- if (!result.first) {
- return false;
- }
-
- if (this->QtVersion.Major == 5 || this->QtVersion.Major == 6) {
- if (stdOut.find("--list") != std::string::npos) {
- this->Rcc.ListOptions.emplace_back("--list");
- } else {
- this->Rcc.ListOptions.emplace_back("-list");
+ {
+ std::string err;
+ if (!this->GlobalInitializer->GetExecutableTestOutput(
+ executable, genVars.Executable, err, output)) {
+ print_err(err);
+ return false;
}
}
+
return true;
}
diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h
index 781dd15..a8c7960 100644
--- a/Source/cmQtAutoGenInitializer.h
+++ b/Source/cmQtAutoGenInitializer.h
@@ -8,15 +8,18 @@
#include "cmQtAutoGen.h"
#include <map>
+#include <memory> // IWYU pragma: keep
#include <ostream>
#include <set>
#include <string>
+#include <unordered_map>
#include <utility>
#include <vector>
class cmGeneratorTarget;
class cmTarget;
class cmQtAutoGenGlobalInitializer;
+class cmSourceFile;
/// @brief Initializes the QtAutoGen generators
class cmQtAutoGenInitializer : public cmQtAutoGen
@@ -40,6 +43,40 @@ public:
std::vector<std::string> Resources;
};
+ /// @brief Moc/Uic file
+ struct MUFile
+ {
+ std::string RealPath;
+ cmSourceFile* SF = nullptr;
+ bool Generated = false;
+ bool SkipMoc = false;
+ bool SkipUic = false;
+ bool MocIt = false;
+ bool UicIt = false;
+ };
+ typedef std::unique_ptr<MUFile> MUFileHandle;
+
+ /// @brief Abstract moc/uic/rcc generator variables base class
+ struct GenVarsT
+ {
+ bool Enabled = false;
+ // Generator type/name
+ GenT Gen;
+ std::string const& GenName;
+ std::string const& GenNameUpper;
+ // Executable
+ std::string ExecutableTargetName;
+ cmGeneratorTarget* ExecutableTarget = nullptr;
+ std::string Executable;
+
+ /// @brief Constructor
+ GenVarsT(GenT gen, std::string const& genName,
+ std::string const& genNameUpper)
+ : Gen(gen)
+ , GenName(genName)
+ , GenNameUpper(genNameUpper){};
+ };
+
/// @brief Writes a CMake info file
class InfoWriter
{
@@ -88,6 +125,12 @@ public:
bool SetupCustomTargets();
private:
+ /// @brief If moc or uic is enabled, the autogen target will be generated
+ bool MocOrUicEnabled() const
+ {
+ return (this->Moc.Enabled || this->Uic.Enabled);
+ }
+
bool InitMoc();
bool InitUic();
bool InitRcc();
@@ -99,21 +142,19 @@ private:
bool SetupWriteAutogenInfo();
bool SetupWriteRccInfo();
- void AddGeneratedSource(std::string const& filename, GeneratorT genType,
+ void RegisterGeneratedSource(std::string const& filename);
+ bool AddGeneratedSource(std::string const& filename, GenVarsT const& genVars,
bool prepend = false);
+ bool AddToSourceGroup(std::string const& fileName,
+ std::string const& genNameUpper);
- bool GetMocExecutable();
- bool GetUicExecutable();
- bool GetRccExecutable();
+ bool GetQtExecutable(GenVarsT& genVars, const std::string& executable,
+ bool ignoreMissingTarget, std::string* output) const;
bool RccListInputs(std::string const& fileName,
std::vector<std::string>& files,
std::string& errorMessage);
- std::pair<bool, std::string> GetQtExecutable(const std::string& executable,
- bool ignoreMissingTarget,
- std::string* output);
-
private:
cmQtAutoGenGlobalInitializer* GlobalInitializer;
cmGeneratorTarget* Target;
@@ -125,6 +166,8 @@ private:
std::vector<std::string> ConfigsList;
std::string Verbosity;
std::string TargetsFolder;
+ bool CMP0071Accept = false;
+ bool CMP0071Warn = false;
/// @brief Common directories
struct
@@ -152,47 +195,54 @@ private:
std::set<std::string> DependFiles;
std::set<cmTarget*> DependTargets;
// Sources to process
- std::vector<std::string> Headers;
- std::vector<std::string> Sources;
- std::vector<std::string> HeadersGenerated;
- std::vector<std::string> SourcesGenerated;
+ std::unordered_map<cmSourceFile*, MUFileHandle> Headers;
+ std::unordered_map<cmSourceFile*, MUFileHandle> Sources;
+ std::vector<MUFile*> FilesGenerated;
} AutogenTarget;
/// @brief Moc only variables
- struct
+ struct MocT : public GenVarsT
{
- bool Enabled = false;
- std::string Executable;
std::string PredefsCmd;
- std::set<std::string> Skip;
std::vector<std::string> Includes;
std::map<std::string, std::vector<std::string>> ConfigIncludes;
std::set<std::string> Defines;
std::map<std::string, std::set<std::string>> ConfigDefines;
std::string MocsCompilation;
+
+ /// @brief Constructor
+ MocT()
+ : GenVarsT(cmQtAutoGen::GenT::MOC, cmQtAutoGen::GenNameMoc,
+ cmQtAutoGen::GenNameMocUpper){};
} Moc;
- ///@brief Uic only variables
- struct
+ /// @brief Uic only variables
+ struct UicT : public GenVarsT
{
- bool Enabled = false;
- std::string Executable;
- std::set<std::string> Skip;
+ std::set<std::string> SkipUi;
std::vector<std::string> SearchPaths;
std::vector<std::string> Options;
std::map<std::string, std::vector<std::string>> ConfigOptions;
std::vector<std::string> FileFiles;
std::vector<std::vector<std::string>> FileOptions;
+
+ /// @brief Constructor
+ UicT()
+ : GenVarsT(cmQtAutoGen::GenT::UIC, cmQtAutoGen::GenNameUic,
+ cmQtAutoGen::GenNameUicUpper){};
} Uic;
/// @brief Rcc only variables
- struct
+ struct RccT : public GenVarsT
{
- bool Enabled = false;
bool GlobalTarget = false;
- std::string Executable;
std::vector<std::string> ListOptions;
std::vector<Qrc> Qrcs;
+
+ /// @brief Constructor
+ RccT()
+ : GenVarsT(cmQtAutoGen::GenT::RCC, cmQtAutoGen::GenNameRcc,
+ cmQtAutoGen::GenNameRccUpper){};
} Rcc;
};
diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx
index fbb9df3..af50c1d 100644
--- a/Source/cmQtAutoGenerator.cxx
+++ b/Source/cmQtAutoGenerator.cxx
@@ -43,8 +43,7 @@ std::string cmQtAutoGenerator::Logger::HeadLine(std::string const& title)
return head;
}
-void cmQtAutoGenerator::Logger::Info(GeneratorT genType,
- std::string const& message)
+void cmQtAutoGenerator::Logger::Info(GenT genType, std::string const& message)
{
std::string msg = GeneratorName(genType);
msg += ": ";
@@ -58,7 +57,7 @@ void cmQtAutoGenerator::Logger::Info(GeneratorT genType,
}
}
-void cmQtAutoGenerator::Logger::Warning(GeneratorT genType,
+void cmQtAutoGenerator::Logger::Warning(GenT genType,
std::string const& message)
{
std::string msg;
@@ -82,7 +81,7 @@ void cmQtAutoGenerator::Logger::Warning(GeneratorT genType,
}
}
-void cmQtAutoGenerator::Logger::WarningFile(GeneratorT genType,
+void cmQtAutoGenerator::Logger::WarningFile(GenT genType,
std::string const& filename,
std::string const& message)
{
@@ -94,8 +93,7 @@ void cmQtAutoGenerator::Logger::WarningFile(GeneratorT genType,
Warning(genType, msg);
}
-void cmQtAutoGenerator::Logger::Error(GeneratorT genType,
- std::string const& message)
+void cmQtAutoGenerator::Logger::Error(GenT genType, std::string const& message)
{
std::string msg;
msg += HeadLine(GeneratorName(genType) + " error");
@@ -111,7 +109,7 @@ void cmQtAutoGenerator::Logger::Error(GeneratorT genType,
}
}
-void cmQtAutoGenerator::Logger::ErrorFile(GeneratorT genType,
+void cmQtAutoGenerator::Logger::ErrorFile(GenT genType,
std::string const& filename,
std::string const& message)
{
@@ -124,7 +122,7 @@ void cmQtAutoGenerator::Logger::ErrorFile(GeneratorT genType,
}
void cmQtAutoGenerator::Logger::ErrorCommand(
- GeneratorT genType, std::string const& message,
+ GenT genType, std::string const& message,
std::vector<std::string> const& command, std::string const& output)
{
std::string msg;
@@ -297,7 +295,7 @@ bool cmQtAutoGenerator::FileSystem::FileRead(std::string& content,
return success;
}
-bool cmQtAutoGenerator::FileSystem::FileRead(GeneratorT genType,
+bool cmQtAutoGenerator::FileSystem::FileRead(GenT genType,
std::string& content,
std::string const& filename)
{
@@ -343,7 +341,7 @@ bool cmQtAutoGenerator::FileSystem::FileWrite(std::string const& filename,
return success;
}
-bool cmQtAutoGenerator::FileSystem::FileWrite(GeneratorT genType,
+bool cmQtAutoGenerator::FileSystem::FileWrite(GenT genType,
std::string const& filename,
std::string const& content)
{
@@ -387,7 +385,7 @@ bool cmQtAutoGenerator::FileSystem::MakeDirectory(std::string const& dirname)
return cmSystemTools::MakeDirectory(dirname);
}
-bool cmQtAutoGenerator::FileSystem::MakeDirectory(GeneratorT genType,
+bool cmQtAutoGenerator::FileSystem::MakeDirectory(GenT genType,
std::string const& dirname)
{
if (!MakeDirectory(dirname)) {
@@ -409,7 +407,7 @@ bool cmQtAutoGenerator::FileSystem::MakeParentDirectory(
}
bool cmQtAutoGenerator::FileSystem::MakeParentDirectory(
- GeneratorT genType, std::string const& filename)
+ GenT genType, std::string const& filename)
{
if (!MakeParentDirectory(filename)) {
Log()->ErrorFile(genType, filename, "Could not create parent directory");
diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h
index 9956a99..6771dd8 100644
--- a/Source/cmQtAutoGenerator.h
+++ b/Source/cmQtAutoGenerator.h
@@ -40,16 +40,16 @@ public:
bool ColorOutput() const { return this->ColorOutput_; }
void SetColorOutput(bool value);
// -- Log info
- void Info(GeneratorT genType, std::string const& message);
+ void Info(GenT genType, std::string const& message);
// -- Log warning
- void Warning(GeneratorT genType, std::string const& message);
- void WarningFile(GeneratorT genType, std::string const& filename,
+ void Warning(GenT genType, std::string const& message);
+ void WarningFile(GenT genType, std::string const& filename,
std::string const& message);
// -- Log error
- void Error(GeneratorT genType, std::string const& message);
- void ErrorFile(GeneratorT genType, std::string const& filename,
+ void Error(GenT genType, std::string const& message);
+ void ErrorFile(GenT genType, std::string const& filename,
std::string const& message);
- void ErrorCommand(GeneratorT genType, std::string const& message,
+ void ErrorCommand(GenT genType, std::string const& message,
std::vector<std::string> const& command,
std::string const& output);
@@ -114,13 +114,13 @@ public:
bool FileRead(std::string& content, std::string const& filename,
std::string* error = nullptr);
/// @brief Error logging version
- bool FileRead(GeneratorT genType, std::string& content,
+ bool FileRead(GenT genType, std::string& content,
std::string const& filename);
bool FileWrite(std::string const& filename, std::string const& content,
std::string* error = nullptr);
/// @brief Error logging version
- bool FileWrite(GeneratorT genType, std::string const& filename,
+ bool FileWrite(GenT genType, std::string const& filename,
std::string const& content);
bool FileDiffers(std::string const& filename, std::string const& content);
@@ -131,11 +131,11 @@ public:
// -- Directory access
bool MakeDirectory(std::string const& dirname);
/// @brief Error logging version
- bool MakeDirectory(GeneratorT genType, std::string const& dirname);
+ bool MakeDirectory(GenT genType, std::string const& dirname);
bool MakeParentDirectory(std::string const& filename);
/// @brief Error logging version
- bool MakeParentDirectory(GeneratorT genType, std::string const& filename);
+ bool MakeParentDirectory(GenT genType, std::string const& filename);
private:
std::mutex Mutex_;
diff --git a/Source/cmQtAutoGeneratorMocUic.cxx b/Source/cmQtAutoGeneratorMocUic.cxx
index 2959b7d..b02cd44 100644
--- a/Source/cmQtAutoGeneratorMocUic.cxx
+++ b/Source/cmQtAutoGeneratorMocUic.cxx
@@ -5,7 +5,6 @@
#include <algorithm>
#include <array>
#include <cstddef>
-#include <functional>
#include <list>
#include <memory>
#include <set>
@@ -184,11 +183,10 @@ void cmQtAutoGeneratorMocUic::JobParseT::Process(WorkerT& wrk)
ParseUic(wrk, meta);
}
} else {
- wrk.LogFileWarning(GeneratorT::GEN, FileName,
- "The source file is empty");
+ wrk.LogFileWarning(GenT::GEN, FileName, "The source file is empty");
}
} else {
- wrk.LogFileError(GeneratorT::GEN, FileName,
+ wrk.LogFileError(GenT::GEN, FileName,
"Could not read the file: " + error);
}
}
@@ -275,7 +273,7 @@ bool cmQtAutoGeneratorMocUic::JobParseT::ParseMocSource(WorkerT& wrk,
emsg += ", but the header ";
emsg += Quoted(MocStringHeaders(wrk, mocInc.Base));
emsg += " could not be found.";
- wrk.LogFileError(GeneratorT::MOC, FileName, emsg);
+ wrk.LogFileError(GenT::MOC, FileName, emsg);
}
return false;
}
@@ -314,7 +312,7 @@ bool cmQtAutoGeneratorMocUic::JobParseT::ParseMocSource(WorkerT& wrk,
emsg += Quoted("moc_" + mocInc.Base + ".cpp");
emsg += " for a compatibility with strict mode.\n"
"(CMAKE_AUTOMOC_RELAXED_MODE warning)\n";
- wrk.LogFileWarning(GeneratorT::MOC, FileName, emsg);
+ wrk.LogFileWarning(GenT::MOC, FileName, emsg);
} else {
std::string emsg = "The file includes the moc file ";
emsg += Quoted(mocInc.Inc);
@@ -326,7 +324,7 @@ bool cmQtAutoGeneratorMocUic::JobParseT::ParseMocSource(WorkerT& wrk,
emsg += Quoted("moc_" + mocInc.Base + ".cpp");
emsg += " for compatibility with strict mode.\n"
"(CMAKE_AUTOMOC_RELAXED_MODE warning)\n";
- wrk.LogFileWarning(GeneratorT::MOC, FileName, emsg);
+ wrk.LogFileWarning(GenT::MOC, FileName, emsg);
}
}
} else {
@@ -338,7 +336,7 @@ bool cmQtAutoGeneratorMocUic::JobParseT::ParseMocSource(WorkerT& wrk,
"matching header ";
emsg += Quoted(MocStringHeaders(wrk, mocInc.Base));
emsg += " could not be found.";
- wrk.LogFileError(GeneratorT::MOC, FileName, emsg);
+ wrk.LogFileError(GenT::MOC, FileName, emsg);
}
return false;
}
@@ -356,7 +354,7 @@ bool cmQtAutoGeneratorMocUic::JobParseT::ParseMocSource(WorkerT& wrk,
emsg += ", but does not contain a ";
emsg += wrk.Moc().MacrosString();
emsg += " macro.";
- wrk.LogFileWarning(GeneratorT::MOC, FileName, emsg);
+ wrk.LogFileWarning(GenT::MOC, FileName, emsg);
}
} else {
// Don't allow <BASE>.moc include other than self in strict mode
@@ -367,7 +365,7 @@ bool cmQtAutoGeneratorMocUic::JobParseT::ParseMocSource(WorkerT& wrk,
"source file.\nThis is not supported. Include ";
emsg += Quoted(meta.FileBase + ".moc");
emsg += " to run moc on this source file.";
- wrk.LogFileError(GeneratorT::MOC, FileName, emsg);
+ wrk.LogFileError(GenT::MOC, FileName, emsg);
}
return false;
}
@@ -410,7 +408,7 @@ bool cmQtAutoGeneratorMocUic::JobParseT::ParseMocSource(WorkerT& wrk,
emsg += Quoted(meta.FileBase + ".moc");
emsg += " for compatibility with strict mode.\n"
"(CMAKE_AUTOMOC_RELAXED_MODE warning)";
- wrk.LogFileWarning(GeneratorT::MOC, FileName, emsg);
+ wrk.LogFileWarning(GenT::MOC, FileName, emsg);
}
// Add own source job
jobs.emplace_back(
@@ -425,7 +423,7 @@ bool cmQtAutoGeneratorMocUic::JobParseT::ParseMocSource(WorkerT& wrk,
emsg += "!\nConsider to\n - add #include \"";
emsg += meta.FileBase;
emsg += ".moc\"\n - enable SKIP_AUTOMOC for this file";
- wrk.LogFileError(GeneratorT::MOC, FileName, emsg);
+ wrk.LogFileError(GenT::MOC, FileName, emsg);
}
return false;
}
@@ -433,8 +431,8 @@ bool cmQtAutoGeneratorMocUic::JobParseT::ParseMocSource(WorkerT& wrk,
// Convert pre jobs to actual jobs
for (JobPre& jobPre : jobs) {
- JobHandleT jobHandle(new JobMocT(std::move(jobPre.SourceFile), FileName,
- std::move(jobPre.IncludeString)));
+ JobHandleT jobHandle = cm::make_unique<JobMocT>(
+ std::move(jobPre.SourceFile), FileName, std::move(jobPre.IncludeString));
if (jobPre.self) {
// Read dependencies from this source
static_cast<JobMocT&>(*jobHandle).FindDependencies(wrk, meta.Content);
@@ -452,8 +450,8 @@ bool cmQtAutoGeneratorMocUic::JobParseT::ParseMocHeader(WorkerT& wrk,
bool success = true;
std::string const macroName = wrk.Moc().FindMacro(meta.Content);
if (!macroName.empty()) {
- JobHandleT jobHandle(
- new JobMocT(std::string(FileName), std::string(), std::string()));
+ JobHandleT jobHandle = cm::make_unique<JobMocT>(
+ std::string(FileName), std::string(), std::string());
// Read dependencies from this source
static_cast<JobMocT&>(*jobHandle).FindDependencies(wrk, meta.Content);
success = wrk.Gen().ParallelJobPushMoc(jobHandle);
@@ -519,8 +517,8 @@ bool cmQtAutoGeneratorMocUic::JobParseT::ParseUicInclude(
std::string uiInputFile = UicFindIncludedFile(wrk, meta, includeString);
if (!uiInputFile.empty()) {
if (!wrk.Uic().skipped(uiInputFile)) {
- JobHandleT jobHandle(new JobUicT(std::move(uiInputFile), FileName,
- std::move(includeString)));
+ JobHandleT jobHandle = cm::make_unique<JobUicT>(
+ std::move(uiInputFile), FileName, std::move(includeString));
success = wrk.Gen().ParallelJobPushUic(jobHandle);
} else {
// A skipped file is successful
@@ -586,7 +584,7 @@ std::string cmQtAutoGeneratorMocUic::JobParseT::UicFindIncludedFile(
emsg += Quoted(testFile);
emsg += "\n";
}
- wrk.LogFileError(GeneratorT::UIC, FileName, emsg);
+ wrk.LogFileError(GenT::UIC, FileName, emsg);
}
return res;
@@ -602,7 +600,7 @@ void cmQtAutoGeneratorMocUic::JobMocPredefsT::Process(WorkerT& wrk)
std::string reason = "Generating ";
reason += Quoted(wrk.Moc().PredefsFileRel);
reason += " because it doesn't exist";
- wrk.LogInfo(GeneratorT::MOC, reason);
+ wrk.LogInfo(GenT::MOC, reason);
}
generate = true;
} else if (wrk.Moc().SettingsChanged) {
@@ -610,7 +608,7 @@ void cmQtAutoGeneratorMocUic::JobMocPredefsT::Process(WorkerT& wrk)
std::string reason = "Generating ";
reason += Quoted(wrk.Moc().PredefsFileRel);
reason += " because the settings changed.";
- wrk.LogInfo(GeneratorT::MOC, reason);
+ wrk.LogInfo(GenT::MOC, reason);
}
generate = true;
}
@@ -627,12 +625,12 @@ void cmQtAutoGeneratorMocUic::JobMocPredefsT::Process(WorkerT& wrk)
cmd.push_back("-D" + def);
}
// Execute command
- if (!wrk.RunProcess(GeneratorT::MOC, result, cmd)) {
+ if (!wrk.RunProcess(GenT::MOC, result, cmd)) {
std::string emsg = "The content generation command for ";
emsg += Quoted(wrk.Moc().PredefsFileRel);
emsg += " failed.\n";
emsg += result.ErrorMessage;
- wrk.LogCommandError(GeneratorT::MOC, emsg, cmd, result.StdOut);
+ wrk.LogCommandError(GenT::MOC, emsg, cmd, result.StdOut);
}
}
@@ -640,14 +638,14 @@ void cmQtAutoGeneratorMocUic::JobMocPredefsT::Process(WorkerT& wrk)
if (!result.error()) {
if (!fileExists ||
wrk.FileSys().FileDiffers(wrk.Moc().PredefsFileAbs, result.StdOut)) {
- if (wrk.FileSys().FileWrite(GeneratorT::MOC, wrk.Moc().PredefsFileAbs,
+ if (wrk.FileSys().FileWrite(GenT::MOC, wrk.Moc().PredefsFileAbs,
result.StdOut)) {
// Success
} else {
std::string emsg = "Writing ";
emsg += Quoted(wrk.Moc().PredefsFileRel);
emsg += " failed.";
- wrk.LogFileError(GeneratorT::MOC, wrk.Moc().PredefsFileAbs, emsg);
+ wrk.LogFileError(GenT::MOC, wrk.Moc().PredefsFileAbs, emsg);
}
} else {
// Touch to update the time stamp
@@ -655,7 +653,7 @@ void cmQtAutoGeneratorMocUic::JobMocPredefsT::Process(WorkerT& wrk)
std::string msg = "Touching ";
msg += Quoted(wrk.Moc().PredefsFileRel);
msg += ".";
- wrk.LogInfo(GeneratorT::MOC, msg);
+ wrk.LogInfo(GenT::MOC, msg);
}
wrk.FileSys().Touch(wrk.Moc().PredefsFileAbs);
}
@@ -713,7 +711,7 @@ bool cmQtAutoGeneratorMocUic::JobMocT::UpdateRequired(WorkerT& wrk)
reason += " from its source file ";
reason += Quoted(SourceFile);
reason += " because it doesn't exist";
- wrk.LogInfo(GeneratorT::MOC, reason);
+ wrk.LogInfo(GenT::MOC, reason);
}
return true;
}
@@ -726,7 +724,7 @@ bool cmQtAutoGeneratorMocUic::JobMocT::UpdateRequired(WorkerT& wrk)
reason += " from ";
reason += Quoted(SourceFile);
reason += " because the MOC settings changed";
- wrk.LogInfo(GeneratorT::MOC, reason);
+ wrk.LogInfo(GenT::MOC, reason);
}
return true;
}
@@ -739,7 +737,7 @@ bool cmQtAutoGeneratorMocUic::JobMocT::UpdateRequired(WorkerT& wrk)
isOlder = wrk.FileSys().FileIsOlderThan(
BuildFile, wrk.Moc().PredefsFileAbs, &error);
if (!isOlder && !error.empty()) {
- wrk.LogError(GeneratorT::MOC, error);
+ wrk.LogError(GenT::MOC, error);
return false;
}
}
@@ -749,7 +747,7 @@ bool cmQtAutoGeneratorMocUic::JobMocT::UpdateRequired(WorkerT& wrk)
reason += Quoted(BuildFile);
reason += " because it's older than: ";
reason += Quoted(wrk.Moc().PredefsFileAbs);
- wrk.LogInfo(GeneratorT::MOC, reason);
+ wrk.LogInfo(GenT::MOC, reason);
}
return true;
}
@@ -762,7 +760,7 @@ bool cmQtAutoGeneratorMocUic::JobMocT::UpdateRequired(WorkerT& wrk)
std::string error;
isOlder = wrk.FileSys().FileIsOlderThan(BuildFile, SourceFile, &error);
if (!isOlder && !error.empty()) {
- wrk.LogError(GeneratorT::MOC, error);
+ wrk.LogError(GenT::MOC, error);
return false;
}
}
@@ -772,7 +770,7 @@ bool cmQtAutoGeneratorMocUic::JobMocT::UpdateRequired(WorkerT& wrk)
reason += Quoted(BuildFile);
reason += " because it's older than its source file ";
reason += Quoted(SourceFile);
- wrk.LogInfo(GeneratorT::MOC, reason);
+ wrk.LogInfo(GenT::MOC, reason);
}
return true;
}
@@ -794,7 +792,7 @@ bool cmQtAutoGeneratorMocUic::JobMocT::UpdateRequired(WorkerT& wrk)
emsg += Quoted(IncluderFile);
emsg += ".\n";
emsg += error;
- wrk.LogError(GeneratorT::MOC, emsg);
+ wrk.LogError(GenT::MOC, emsg);
return false;
}
}
@@ -815,18 +813,18 @@ bool cmQtAutoGeneratorMocUic::JobMocT::UpdateRequired(WorkerT& wrk)
reason += Quoted(SourceFile);
reason += " because it is older than it's dependency file ";
reason += Quoted(depFileAbs);
- wrk.LogInfo(GeneratorT::MOC, reason);
+ wrk.LogInfo(GenT::MOC, reason);
}
return true;
}
if (!error.empty()) {
- wrk.LogError(GeneratorT::MOC, error);
+ wrk.LogError(GenT::MOC, error);
return false;
}
} else {
std::string message = "Could not find dependency file ";
message += Quoted(depFileRel);
- wrk.LogFileWarning(GeneratorT::MOC, SourceFile, message);
+ wrk.LogFileWarning(GenT::MOC, SourceFile, message);
}
}
}
@@ -837,7 +835,7 @@ bool cmQtAutoGeneratorMocUic::JobMocT::UpdateRequired(WorkerT& wrk)
void cmQtAutoGeneratorMocUic::JobMocT::GenerateMoc(WorkerT& wrk)
{
// Make sure the parent directory exists
- if (wrk.FileSys().MakeParentDirectory(GeneratorT::MOC, BuildFile)) {
+ if (wrk.FileSys().MakeParentDirectory(GenT::MOC, BuildFile)) {
// Compose moc command
std::vector<std::string> cmd;
cmd.push_back(wrk.Moc().Executable);
@@ -855,11 +853,11 @@ void cmQtAutoGeneratorMocUic::JobMocT::GenerateMoc(WorkerT& wrk)
// Execute moc command
ProcessResultT result;
- if (wrk.RunProcess(GeneratorT::MOC, result, cmd)) {
+ if (wrk.RunProcess(GenT::MOC, result, cmd)) {
// Moc command success
// Print moc output
if (!result.StdOut.empty()) {
- wrk.LogInfo(GeneratorT::MOC, result.StdOut);
+ wrk.LogInfo(GenT::MOC, result.StdOut);
}
// Notify the generator that a not included file changed (on demand)
if (IncludeString.empty()) {
@@ -874,7 +872,7 @@ void cmQtAutoGeneratorMocUic::JobMocT::GenerateMoc(WorkerT& wrk)
emsg += Quoted(BuildFile);
emsg += ".\n";
emsg += result.ErrorMessage;
- wrk.LogCommandError(GeneratorT::MOC, emsg, cmd, result.StdOut);
+ wrk.LogCommandError(GenT::MOC, emsg, cmd, result.StdOut);
}
wrk.FileSys().FileRemove(BuildFile);
}
@@ -905,7 +903,7 @@ bool cmQtAutoGeneratorMocUic::JobUicT::UpdateRequired(WorkerT& wrk)
reason += " from its source file ";
reason += Quoted(SourceFile);
reason += " because it doesn't exist";
- wrk.LogInfo(GeneratorT::UIC, reason);
+ wrk.LogInfo(GenT::UIC, reason);
}
return true;
}
@@ -918,7 +916,7 @@ bool cmQtAutoGeneratorMocUic::JobUicT::UpdateRequired(WorkerT& wrk)
reason += " from ";
reason += Quoted(SourceFile);
reason += " because the UIC settings changed";
- wrk.LogInfo(GeneratorT::UIC, reason);
+ wrk.LogInfo(GenT::UIC, reason);
}
return true;
}
@@ -930,7 +928,7 @@ bool cmQtAutoGeneratorMocUic::JobUicT::UpdateRequired(WorkerT& wrk)
std::string error;
isOlder = wrk.FileSys().FileIsOlderThan(BuildFile, SourceFile, &error);
if (!isOlder && !error.empty()) {
- wrk.LogError(GeneratorT::UIC, error);
+ wrk.LogError(GenT::UIC, error);
return false;
}
}
@@ -940,7 +938,7 @@ bool cmQtAutoGeneratorMocUic::JobUicT::UpdateRequired(WorkerT& wrk)
reason += Quoted(BuildFile);
reason += " because it's older than its source file ";
reason += Quoted(SourceFile);
- wrk.LogInfo(GeneratorT::UIC, reason);
+ wrk.LogInfo(GenT::UIC, reason);
}
return true;
}
@@ -952,7 +950,7 @@ bool cmQtAutoGeneratorMocUic::JobUicT::UpdateRequired(WorkerT& wrk)
void cmQtAutoGeneratorMocUic::JobUicT::GenerateUic(WorkerT& wrk)
{
// Make sure the parent directory exists
- if (wrk.FileSys().MakeParentDirectory(GeneratorT::UIC, BuildFile)) {
+ if (wrk.FileSys().MakeParentDirectory(GenT::UIC, BuildFile)) {
// Compose uic command
std::vector<std::string> cmd;
cmd.push_back(wrk.Uic().Executable);
@@ -970,11 +968,11 @@ void cmQtAutoGeneratorMocUic::JobUicT::GenerateUic(WorkerT& wrk)
cmd.push_back(SourceFile);
ProcessResultT result;
- if (wrk.RunProcess(GeneratorT::UIC, result, cmd)) {
+ if (wrk.RunProcess(GenT::UIC, result, cmd)) {
// Uic command success
// Print uic output
if (!result.StdOut.empty()) {
- wrk.LogInfo(GeneratorT::UIC, result.StdOut);
+ wrk.LogInfo(GenT::UIC, result.StdOut);
}
} else {
// Uic command failed
@@ -987,18 +985,13 @@ void cmQtAutoGeneratorMocUic::JobUicT::GenerateUic(WorkerT& wrk)
emsg += Quoted(IncluderFile);
emsg += ".\n";
emsg += result.ErrorMessage;
- wrk.LogCommandError(GeneratorT::UIC, emsg, cmd, result.StdOut);
+ wrk.LogCommandError(GenT::UIC, emsg, cmd, result.StdOut);
}
wrk.FileSys().FileRemove(BuildFile);
}
}
}
-void cmQtAutoGeneratorMocUic::JobDeleterT::operator()(JobT* job)
-{
- delete job;
-}
-
cmQtAutoGeneratorMocUic::WorkerT::WorkerT(cmQtAutoGeneratorMocUic* gen,
uv_loop_t* uvLoop)
: Gen_(gen)
@@ -1018,41 +1011,39 @@ cmQtAutoGeneratorMocUic::WorkerT::~WorkerT()
}
void cmQtAutoGeneratorMocUic::WorkerT::LogInfo(
- GeneratorT genType, std::string const& message) const
+ GenT genType, std::string const& message) const
{
Log().Info(genType, message);
}
void cmQtAutoGeneratorMocUic::WorkerT::LogWarning(
- GeneratorT genType, std::string const& message) const
+ GenT genType, std::string const& message) const
{
Log().Warning(genType, message);
}
void cmQtAutoGeneratorMocUic::WorkerT::LogFileWarning(
- GeneratorT genType, std::string const& filename,
- std::string const& message) const
+ GenT genType, std::string const& filename, std::string const& message) const
{
Log().WarningFile(genType, filename, message);
}
void cmQtAutoGeneratorMocUic::WorkerT::LogError(
- GeneratorT genType, std::string const& message) const
+ GenT genType, std::string const& message) const
{
Gen().ParallelRegisterJobError();
Log().Error(genType, message);
}
void cmQtAutoGeneratorMocUic::WorkerT::LogFileError(
- GeneratorT genType, std::string const& filename,
- std::string const& message) const
+ GenT genType, std::string const& filename, std::string const& message) const
{
Gen().ParallelRegisterJobError();
Log().ErrorFile(genType, filename, message);
}
void cmQtAutoGeneratorMocUic::WorkerT::LogCommandError(
- GeneratorT genType, std::string const& message,
+ GenT genType, std::string const& message,
std::vector<std::string> const& command, std::string const& output) const
{
Gen().ParallelRegisterJobError();
@@ -1060,7 +1051,7 @@ void cmQtAutoGeneratorMocUic::WorkerT::LogCommandError(
}
bool cmQtAutoGeneratorMocUic::WorkerT::RunProcess(
- GeneratorT genType, ProcessResultT& result,
+ GenT genType, ProcessResultT& result,
std::vector<std::string> const& command)
{
if (command.empty()) {
@@ -1213,7 +1204,7 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile)
// -- Read info file
if (!makefile->ReadListFile(InfoFile())) {
- Log().ErrorFile(GeneratorT::GEN, InfoFile(), "File processing failed");
+ Log().ErrorFile(GenT::GEN, InfoFile(), "File processing failed");
return false;
}
@@ -1238,14 +1229,13 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile)
InfoGetBool("AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE");
Base_.AutogenBuildDir = InfoGet("AM_BUILD_DIR");
if (Base_.AutogenBuildDir.empty()) {
- Log().ErrorFile(GeneratorT::GEN, InfoFile(),
- "Autogen build directory missing");
+ Log().ErrorFile(GenT::GEN, InfoFile(), "Autogen build directory missing");
return false;
}
// include directory
Base_.AutogenIncludeDir = InfoGetConfig("AM_INCLUDE_DIR");
if (Base_.AutogenIncludeDir.empty()) {
- Log().ErrorFile(GeneratorT::GEN, InfoFile(),
+ Log().ErrorFile(GenT::GEN, InfoFile(),
"Autogen include directory missing");
return false;
}
@@ -1253,7 +1243,7 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile)
// - Files
SettingsFile_ = InfoGetConfig("AM_SETTINGS_FILE");
if (SettingsFile_.empty()) {
- Log().ErrorFile(GeneratorT::GEN, InfoFile(), "Settings file name missing");
+ Log().ErrorFile(GenT::GEN, InfoFile(), "Settings file name missing");
return false;
}
@@ -1270,9 +1260,8 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile)
Moc_.Executable = InfoGet("AM_QT_MOC_EXECUTABLE");
Moc_.Enabled = !Moc().Executable.empty();
if (Moc().Enabled) {
- {
- auto lst = InfoGetList("AM_MOC_SKIP");
- Moc_.SkipList.insert(lst.begin(), lst.end());
+ for (std::string& sfl : InfoGetList("AM_MOC_SKIP")) {
+ Moc_.SkipList.insert(std::move(sfl));
}
Moc_.Definitions = InfoGetConfigList("AM_MOC_DEFINITIONS");
Moc_.IncludePaths = InfoGetConfigList("AM_MOC_INCLUDES");
@@ -1334,20 +1323,20 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile)
}
} else {
Log().ErrorFile(
- GeneratorT::MOC, InfoFile(),
+ GenT::MOC, InfoFile(),
"AUTOMOC_DEPEND_FILTERS list size is not a multiple of 2");
return false;
}
}
if (!error.empty()) {
- Log().ErrorFile(GeneratorT::MOC, InfoFile(), error);
+ Log().ErrorFile(GenT::MOC, InfoFile(), error);
return false;
}
}
Moc_.PredefsCmd = InfoGetList("AM_MOC_PREDEFS_CMD");
// Install moc predefs job
if (!Moc().PredefsCmd.empty()) {
- JobQueues_.MocPredefs.emplace_back(new JobMocPredefsT());
+ JobQueues_.MocPredefs.emplace_back(cm::make_unique<JobMocPredefsT>());
}
}
@@ -1355,9 +1344,8 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile)
Uic_.Executable = InfoGet("AM_QT_UIC_EXECUTABLE");
Uic_.Enabled = !Uic().Executable.empty();
if (Uic().Enabled) {
- {
- auto lst = InfoGetList("AM_UIC_SKIP");
- Uic_.SkipList.insert(lst.begin(), lst.end());
+ for (std::string& sfl : InfoGetList("AM_UIC_SKIP")) {
+ Uic_.SkipList.insert(std::move(sfl));
}
Uic_.SearchPaths = InfoGetList("AM_UIC_SEARCH_PATHS");
Uic_.TargetOptions = InfoGetConfigList("AM_UIC_TARGET_OPTIONS");
@@ -1369,7 +1357,7 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile)
std::ostringstream ost;
ost << "files/options lists sizes mismatch (" << sources.size() << "/"
<< options.size() << ")";
- Log().ErrorFile(GeneratorT::UIC, InfoFile(), ost.str());
+ Log().ErrorFile(GenT::UIC, InfoFile(), ost.str());
return false;
}
auto fitEnd = sources.cend();
@@ -1383,53 +1371,44 @@ bool cmQtAutoGeneratorMocUic::Init(cmMakefile* makefile)
}
}
- // Initialize source file jobs
+ // - Headers and sources
{
- std::hash<std::string> stringHash;
- std::set<std::size_t> uniqueHeaders;
-
- // Add header jobs
+ auto addHeader = [this](std::string&& hdr, bool moc, bool uic) {
+ this->JobQueues_.Headers.emplace_back(
+ cm::make_unique<JobParseT>(std::move(hdr), moc, uic, true));
+ };
+ auto addSource = [this](std::string&& src, bool moc, bool uic) {
+ this->JobQueues_.Sources.emplace_back(
+ cm::make_unique<JobParseT>(std::move(src), moc, uic, false));
+ };
+
+ // Add headers
for (std::string& hdr : InfoGetList("AM_HEADERS")) {
- const bool moc = !Moc().skipped(hdr);
- const bool uic = !Uic().skipped(hdr);
- if ((moc || uic) && uniqueHeaders.emplace(stringHash(hdr)).second) {
- JobQueues_.Headers.emplace_back(
- new JobParseT(std::move(hdr), moc, uic, true));
+ addHeader(std::move(hdr), true, true);
+ }
+ if (Moc().Enabled) {
+ for (std::string& hdr : InfoGetList("AM_MOC_HEADERS")) {
+ addHeader(std::move(hdr), true, false);
}
}
- // Add source jobs
- {
- std::vector<std::string> sources = InfoGetList("AM_SOURCES");
- // Add header(s) for the source file
- for (std::string& src : sources) {
- const bool srcMoc = !Moc().skipped(src);
- const bool srcUic = !Uic().skipped(src);
- if (!srcMoc && !srcUic) {
- continue;
- }
- // Search for the default header file and a private header
- {
- std::array<std::string, 2> bases;
- bases[0] = FileSys().SubDirPrefix(src);
- bases[0] += FileSys().GetFilenameWithoutLastExtension(src);
- bases[1] = bases[0];
- bases[1] += "_p";
- for (std::string const& headerBase : bases) {
- std::string header;
- if (Base().FindHeader(header, headerBase)) {
- const bool moc = srcMoc && !Moc().skipped(header);
- const bool uic = srcUic && !Uic().skipped(header);
- if ((moc || uic) &&
- uniqueHeaders.emplace(stringHash(header)).second) {
- JobQueues_.Headers.emplace_back(
- new JobParseT(std::move(header), moc, uic, true));
- }
- }
- }
- }
- // Add source job
- JobQueues_.Sources.emplace_back(
- new JobParseT(std::move(src), srcMoc, srcUic));
+ if (Uic().Enabled) {
+ for (std::string& hdr : InfoGetList("AM_UIC_HEADERS")) {
+ addHeader(std::move(hdr), false, true);
+ }
+ }
+
+ // Add sources
+ for (std::string& src : InfoGetList("AM_SOURCES")) {
+ addSource(std::move(src), true, true);
+ }
+ if (Moc().Enabled) {
+ for (std::string& src : InfoGetList("AM_MOC_SOURCES")) {
+ addSource(std::move(src), true, false);
+ }
+ }
+ if (Uic().Enabled) {
+ for (std::string& src : InfoGetList("AM_UIC_SOURCES")) {
+ addSource(std::move(src), false, true);
}
}
}
@@ -1690,8 +1669,7 @@ void cmQtAutoGeneratorMocUic::SettingsFileWrite()
// Only write if any setting changed
if (!JobError_ && (Moc().SettingsChanged || Uic().SettingsChanged)) {
if (Log().Verbose()) {
- Log().Info(GeneratorT::GEN,
- "Writing settings file " + Quoted(SettingsFile_));
+ Log().Info(GenT::GEN, "Writing settings file " + Quoted(SettingsFile_));
}
// Compose settings file content
std::string content;
@@ -1709,8 +1687,8 @@ void cmQtAutoGeneratorMocUic::SettingsFileWrite()
SettingAppend("uic", SettingsStringUic_);
}
// Write settings file
- if (!FileSys().FileWrite(GeneratorT::GEN, SettingsFile_, content)) {
- Log().ErrorFile(GeneratorT::GEN, SettingsFile_,
+ if (!FileSys().FileWrite(GenT::GEN, SettingsFile_, content)) {
+ Log().ErrorFile(GenT::GEN, SettingsFile_,
"Settings file writing failed");
// Remove old settings file to trigger a full rebuild on the next run
FileSys().FileRemove(SettingsFile_);
@@ -1722,7 +1700,7 @@ void cmQtAutoGeneratorMocUic::SettingsFileWrite()
void cmQtAutoGeneratorMocUic::CreateDirectories()
{
// Create AUTOGEN include directory
- if (!FileSys().MakeDirectory(GeneratorT::GEN, Base().AutogenIncludeDir)) {
+ if (!FileSys().MakeDirectory(GenT::GEN, Base().AutogenIncludeDir)) {
RegisterJobError();
}
}
@@ -1802,7 +1780,7 @@ void cmQtAutoGeneratorMocUic::WorkerSwapJob(JobHandleT& jobHandle)
{
bool const jobProcessed(jobHandle);
if (jobProcessed) {
- jobHandle.reset(nullptr);
+ jobHandle.reset();
}
{
std::unique_lock<std::mutex> jobsLock(JobsMutex_);
@@ -1882,7 +1860,7 @@ bool cmQtAutoGeneratorMocUic::ParallelJobPushMoc(JobHandleT& jobHandle)
"- add a directory prefix to a \"<NAME>.moc\" include "
"(e.g \"sub/<NAME>.moc\")\n"
"- rename the source file(s)\n";
- Log().Error(GeneratorT::MOC, error);
+ Log().Error(GenT::MOC, error);
RegisterJobError();
}
// Do not push this job in since the included moc file already
@@ -1932,7 +1910,7 @@ bool cmQtAutoGeneratorMocUic::ParallelJobPushUic(JobHandleT& jobHandle)
"(e.g \"sub/ui_<NAME>.h\")\n"
"- rename the <NAME>.ui file(s) and adjust the \"ui_<NAME>.h\" "
"include(s)\n";
- Log().Error(GeneratorT::UIC, error);
+ Log().Error(GenT::UIC, error);
RegisterJobError();
}
// Do not push this job in since the uic file already
@@ -2019,10 +1997,10 @@ void cmQtAutoGeneratorMocUic::MocGenerateCompilation()
if (FileSys().FileDiffers(compAbs, content)) {
// Actually write mocs compilation file
if (Log().Verbose()) {
- Log().Info(GeneratorT::MOC, "Generating MOC compilation " + compAbs);
+ Log().Info(GenT::MOC, "Generating MOC compilation " + compAbs);
}
- if (!FileSys().FileWrite(GeneratorT::MOC, compAbs, content)) {
- Log().ErrorFile(GeneratorT::MOC, compAbs,
+ if (!FileSys().FileWrite(GenT::MOC, compAbs, content)) {
+ Log().ErrorFile(GenT::MOC, compAbs,
"mocs compilation file writing failed");
RegisterJobError();
return;
@@ -2030,7 +2008,7 @@ void cmQtAutoGeneratorMocUic::MocGenerateCompilation()
} else if (MocAutoFileUpdated_) {
// Only touch mocs compilation file
if (Log().Verbose()) {
- Log().Info(GeneratorT::MOC, "Touching mocs compilation " + compAbs);
+ Log().Info(GenT::MOC, "Touching mocs compilation " + compAbs);
}
FileSys().Touch(compAbs);
}
diff --git a/Source/cmQtAutoGeneratorMocUic.h b/Source/cmQtAutoGeneratorMocUic.h
index c22df29..e48d7f3 100644
--- a/Source/cmQtAutoGeneratorMocUic.h
+++ b/Source/cmQtAutoGeneratorMocUic.h
@@ -20,6 +20,7 @@
#include <set>
#include <string>
#include <thread>
+#include <unordered_set>
#include <utility>
#include <vector>
@@ -133,7 +134,7 @@ public:
std::string CompFileAbs;
std::string PredefsFileRel;
std::string PredefsFileAbs;
- std::set<std::string> SkipList;
+ std::unordered_set<std::string> SkipList;
std::vector<std::string> IncludePaths;
std::vector<std::string> Includes;
std::vector<std::string> Definitions;
@@ -164,7 +165,7 @@ public:
bool Enabled = false;
bool SettingsChanged = false;
std::string Executable;
- std::set<std::string> SkipList;
+ std::unordered_set<std::string> SkipList;
std::vector<std::string> TargetOptions;
std::map<std::string, std::vector<std::string>> Options;
std::vector<std::string> SearchPaths;
@@ -186,15 +187,8 @@ public:
virtual void Process(WorkerT& wrk) = 0;
};
- /// @brief Deleter for classes derived from Job
- ///
- struct JobDeleterT
- {
- void operator()(JobT* job);
- };
-
// Job management types
- typedef std::unique_ptr<JobT, JobDeleterT> JobHandleT;
+ typedef std::unique_ptr<JobT> JobHandleT;
typedef std::deque<JobHandleT> JobQueueT;
/// @brief Parse source job
@@ -321,22 +315,22 @@ public:
const UicSettingsT& Uic() const { return Gen_->Uic(); }
// -- Log info
- void LogInfo(GeneratorT genType, std::string const& message) const;
+ void LogInfo(GenT genType, std::string const& message) const;
// -- Log warning
- void LogWarning(GeneratorT genType, std::string const& message) const;
- void LogFileWarning(GeneratorT genType, std::string const& filename,
+ void LogWarning(GenT genType, std::string const& message) const;
+ void LogFileWarning(GenT genType, std::string const& filename,
std::string const& message) const;
// -- Log error
- void LogError(GeneratorT genType, std::string const& message) const;
- void LogFileError(GeneratorT genType, std::string const& filename,
+ void LogError(GenT genType, std::string const& message) const;
+ void LogFileError(GenT genType, std::string const& filename,
std::string const& message) const;
- void LogCommandError(GeneratorT genType, std::string const& message,
+ void LogCommandError(GenT genType, std::string const& message,
std::vector<std::string> const& command,
std::string const& output) const;
// -- External processes
/// @brief Verbose logging version
- bool RunProcess(GeneratorT genType, ProcessResultT& result,
+ bool RunProcess(GenT genType, ProcessResultT& result,
std::vector<std::string> const& command);
private:
diff --git a/Source/cmQtAutoGeneratorRcc.cxx b/Source/cmQtAutoGeneratorRcc.cxx
index 021a15f..5deb532 100644
--- a/Source/cmQtAutoGeneratorRcc.cxx
+++ b/Source/cmQtAutoGeneratorRcc.cxx
@@ -55,7 +55,7 @@ bool cmQtAutoGeneratorRcc::Init(cmMakefile* makefile)
// -- Read info file
if (!makefile->ReadListFile(InfoFile())) {
- Log().ErrorFile(GeneratorT::RCC, InfoFile(), "File processing failed");
+ Log().ErrorFile(GenT::RCC, InfoFile(), "File processing failed");
return false;
}
@@ -66,13 +66,13 @@ bool cmQtAutoGeneratorRcc::Init(cmMakefile* makefile)
// - Directories
AutogenBuildDir_ = InfoGet("ARCC_BUILD_DIR");
if (AutogenBuildDir_.empty()) {
- Log().ErrorFile(GeneratorT::RCC, InfoFile(), "Build directory empty");
+ Log().ErrorFile(GenT::RCC, InfoFile(), "Build directory empty");
return false;
}
IncludeDir_ = InfoGetConfig("ARCC_INCLUDE_DIR");
if (IncludeDir_.empty()) {
- Log().ErrorFile(GeneratorT::RCC, InfoFile(), "Include directory empty");
+ Log().ErrorFile(GenT::RCC, InfoFile(), "Include directory empty");
return false;
}
@@ -95,28 +95,27 @@ bool cmQtAutoGeneratorRcc::Init(cmMakefile* makefile)
// - Validity checks
if (LockFile_.empty()) {
- Log().ErrorFile(GeneratorT::RCC, InfoFile(), "Lock file name missing");
+ Log().ErrorFile(GenT::RCC, InfoFile(), "Lock file name missing");
return false;
}
if (SettingsFile_.empty()) {
- Log().ErrorFile(GeneratorT::RCC, InfoFile(), "Settings file name missing");
+ Log().ErrorFile(GenT::RCC, InfoFile(), "Settings file name missing");
return false;
}
if (AutogenBuildDir_.empty()) {
- Log().ErrorFile(GeneratorT::RCC, InfoFile(),
- "Autogen build directory missing");
+ Log().ErrorFile(GenT::RCC, InfoFile(), "Autogen build directory missing");
return false;
}
if (RccExecutable_.empty()) {
- Log().ErrorFile(GeneratorT::RCC, InfoFile(), "rcc executable missing");
+ Log().ErrorFile(GenT::RCC, InfoFile(), "rcc executable missing");
return false;
}
if (QrcFile_.empty()) {
- Log().ErrorFile(GeneratorT::RCC, InfoFile(), "rcc input file missing");
+ Log().ErrorFile(GenT::RCC, InfoFile(), "rcc input file missing");
return false;
}
if (RccFileName_.empty()) {
- Log().ErrorFile(GeneratorT::RCC, InfoFile(), "rcc output file missing");
+ Log().ErrorFile(GenT::RCC, InfoFile(), "rcc output file missing");
return false;
}
@@ -287,8 +286,7 @@ bool cmQtAutoGeneratorRcc::SettingsFileRead()
// Make sure the lock file exists
if (!FileSys().FileExists(LockFile_, true)) {
if (!FileSys().Touch(LockFile_, true)) {
- Log().ErrorFile(GeneratorT::RCC, LockFile_,
- "Lock file creation failed");
+ Log().ErrorFile(GenT::RCC, LockFile_, "Lock file creation failed");
Error_ = true;
return false;
}
@@ -297,7 +295,7 @@ bool cmQtAutoGeneratorRcc::SettingsFileRead()
cmFileLockResult lockResult =
LockFileLock_.Lock(LockFile_, static_cast<unsigned long>(-1));
if (!lockResult.IsOk()) {
- Log().ErrorFile(GeneratorT::RCC, LockFile_,
+ Log().ErrorFile(GenT::RCC, LockFile_,
"File lock failed: " + lockResult.GetOutputMessage());
Error_ = true;
return false;
@@ -313,7 +311,7 @@ bool cmQtAutoGeneratorRcc::SettingsFileRead()
// This triggers a full rebuild on the next run if the current
// build is aborted before writing the current settings in the end.
if (SettingsChanged_) {
- FileSys().FileWrite(GeneratorT::RCC, SettingsFile_, "");
+ FileSys().FileWrite(GenT::RCC, SettingsFile_, "");
}
} else {
SettingsChanged_ = true;
@@ -328,15 +326,14 @@ void cmQtAutoGeneratorRcc::SettingsFileWrite()
// Only write if any setting changed
if (SettingsChanged_) {
if (Log().Verbose()) {
- Log().Info(GeneratorT::RCC,
- "Writing settings file " + Quoted(SettingsFile_));
+ Log().Info(GenT::RCC, "Writing settings file " + Quoted(SettingsFile_));
}
// Write settings file
std::string content = "rcc:";
content += SettingsString_;
content += '\n';
- if (!FileSys().FileWrite(GeneratorT::RCC, SettingsFile_, content)) {
- Log().ErrorFile(GeneratorT::RCC, SettingsFile_,
+ if (!FileSys().FileWrite(GenT::RCC, SettingsFile_, content)) {
+ Log().ErrorFile(GenT::RCC, SettingsFile_,
"Settings file writing failed");
// Remove old settings file to trigger a full rebuild on the next run
FileSys().FileRemove(SettingsFile_);
@@ -360,7 +357,7 @@ bool cmQtAutoGeneratorRcc::TestQrcRccFiles()
reason += " from its source file ";
reason += Quoted(QrcFile_);
reason += " because it doesn't exist";
- Log().Info(GeneratorT::RCC, reason);
+ Log().Info(GenT::RCC, reason);
}
Generate_ = true;
return Generate_;
@@ -374,7 +371,7 @@ bool cmQtAutoGeneratorRcc::TestQrcRccFiles()
reason += " from ";
reason += Quoted(QrcFile_);
reason += " because the RCC settings changed";
- Log().Info(GeneratorT::RCC, reason);
+ Log().Info(GenT::RCC, reason);
}
Generate_ = true;
return Generate_;
@@ -387,7 +384,7 @@ bool cmQtAutoGeneratorRcc::TestQrcRccFiles()
std::string error;
isOlder = FileSys().FileIsOlderThan(RccFileOutput_, QrcFile_, &error);
if (!error.empty()) {
- Log().ErrorFile(GeneratorT::RCC, QrcFile_, error);
+ Log().ErrorFile(GenT::RCC, QrcFile_, error);
Error_ = true;
}
}
@@ -397,7 +394,7 @@ bool cmQtAutoGeneratorRcc::TestQrcRccFiles()
reason += Quoted(RccFileOutput_);
reason += " because it is older than ";
reason += Quoted(QrcFile_);
- Log().Info(GeneratorT::RCC, reason);
+ Log().Info(GenT::RCC, reason);
}
Generate_ = true;
}
@@ -424,12 +421,11 @@ bool cmQtAutoGeneratorRcc::TestResourcesRead()
std::string parseError;
if (!RccListParseOutput(ProcessResult_.StdOut, ProcessResult_.StdErr,
Inputs_, parseError)) {
- Log().ErrorFile(GeneratorT::RCC, QrcFile_, parseError);
+ Log().ErrorFile(GenT::RCC, QrcFile_, parseError);
Error_ = true;
}
} else {
- Log().ErrorFile(GeneratorT::RCC, QrcFile_,
- ProcessResult_.ErrorMessage);
+ Log().ErrorFile(GenT::RCC, QrcFile_, ProcessResult_.ErrorMessage);
Error_ = true;
}
// Clean up
@@ -457,7 +453,7 @@ bool cmQtAutoGeneratorRcc::TestResourcesRead()
// rcc does not support the --list command.
// Read the qrc file content and parse it.
std::string qrcContent;
- if (FileSys().FileRead(GeneratorT::RCC, qrcContent, QrcFile_)) {
+ if (FileSys().FileRead(GenT::RCC, qrcContent, QrcFile_)) {
RccListParseContent(qrcContent, Inputs_);
}
}
@@ -483,7 +479,7 @@ bool cmQtAutoGeneratorRcc::TestResources()
error = "Could not find the resource file\n ";
error += Quoted(resFile);
error += '\n';
- Log().ErrorFile(GeneratorT::RCC, QrcFile_, error);
+ Log().ErrorFile(GenT::RCC, QrcFile_, error);
Error_ = true;
break;
}
@@ -496,14 +492,14 @@ bool cmQtAutoGeneratorRcc::TestResources()
reason += Quoted(QrcFile_);
reason += " because it is older than ";
reason += Quoted(resFile);
- Log().Info(GeneratorT::RCC, reason);
+ Log().Info(GenT::RCC, reason);
}
Generate_ = true;
break;
}
// Print error and break on demand
if (!error.empty()) {
- Log().ErrorFile(GeneratorT::RCC, QrcFile_, error);
+ Log().ErrorFile(GenT::RCC, QrcFile_, error);
Error_ = true;
break;
}
@@ -522,7 +518,7 @@ void cmQtAutoGeneratorRcc::TestInfoFile()
std::string error;
isOlder = FileSys().FileIsOlderThan(RccFileOutput_, InfoFile(), &error);
if (!error.empty()) {
- Log().ErrorFile(GeneratorT::RCC, QrcFile_, error);
+ Log().ErrorFile(GenT::RCC, QrcFile_, error);
Error_ = true;
}
}
@@ -532,7 +528,7 @@ void cmQtAutoGeneratorRcc::TestInfoFile()
reason += Quoted(RccFileOutput_);
reason += " because it is older than ";
reason += Quoted(InfoFile());
- Log().Info(GeneratorT::RCC, reason);
+ Log().Info(GenT::RCC, reason);
}
// Touch build file
FileSys().Touch(RccFileOutput_);
@@ -544,7 +540,7 @@ void cmQtAutoGeneratorRcc::TestInfoFile()
void cmQtAutoGeneratorRcc::GenerateParentDir()
{
// Make sure the parent directory exists
- if (!FileSys().MakeParentDirectory(GeneratorT::RCC, RccFileOutput_)) {
+ if (!FileSys().MakeParentDirectory(GenT::RCC, RccFileOutput_)) {
Error_ = true;
}
}
@@ -567,7 +563,7 @@ bool cmQtAutoGeneratorRcc::GenerateRcc()
// Rcc process success
// Print rcc output
if (!ProcessResult_.StdOut.empty()) {
- Log().Info(GeneratorT::RCC, ProcessResult_.StdOut);
+ Log().Info(GenT::RCC, ProcessResult_.StdOut);
}
BuildFileChanged_ = true;
} else {
@@ -581,7 +577,7 @@ bool cmQtAutoGeneratorRcc::GenerateRcc()
emsg += "\n";
emsg += ProcessResult_.ErrorMessage;
}
- Log().ErrorCommand(GeneratorT::RCC, emsg, Process_->Setup().Command,
+ Log().ErrorCommand(GenT::RCC, emsg, Process_->Setup().Command,
ProcessResult_.StdOut);
}
FileSys().FileRemove(RccFileOutput_);
@@ -625,19 +621,17 @@ void cmQtAutoGeneratorRcc::GenerateWrapper()
if (FileSys().FileDiffers(RccFilePublic_, content)) {
// Write new wrapper file
if (Log().Verbose()) {
- Log().Info(GeneratorT::RCC,
- "Generating RCC wrapper file " + RccFilePublic_);
+ Log().Info(GenT::RCC, "Generating RCC wrapper file " + RccFilePublic_);
}
- if (!FileSys().FileWrite(GeneratorT::RCC, RccFilePublic_, content)) {
- Log().ErrorFile(GeneratorT::RCC, RccFilePublic_,
+ if (!FileSys().FileWrite(GenT::RCC, RccFilePublic_, content)) {
+ Log().ErrorFile(GenT::RCC, RccFilePublic_,
"RCC wrapper file writing failed");
Error_ = true;
}
} else if (BuildFileChanged_) {
// Just touch the wrapper file
if (Log().Verbose()) {
- Log().Info(GeneratorT::RCC,
- "Touching RCC wrapper file " + RccFilePublic_);
+ Log().Info(GenT::RCC, "Touching RCC wrapper file " + RccFilePublic_);
}
FileSys().Touch(RccFilePublic_);
}
@@ -653,7 +647,7 @@ bool cmQtAutoGeneratorRcc::StartProcess(
std::string msg = "Running command:\n";
msg += QuotedCommand(command);
msg += '\n';
- Log().Info(GeneratorT::RCC, msg);
+ Log().Info(GenT::RCC, msg);
}
// Create process handler
@@ -661,7 +655,7 @@ bool cmQtAutoGeneratorRcc::StartProcess(
Process_->setup(&ProcessResult_, mergedOutput, command, workingDirectory);
// Start process
if (!Process_->start(UVLoop(), [this] { UVRequest().send(); })) {
- Log().ErrorFile(GeneratorT::RCC, QrcFile_, ProcessResult_.ErrorMessage);
+ Log().ErrorFile(GenT::RCC, QrcFile_, ProcessResult_.ErrorMessage);
Error_ = true;
// Clean up
Process_.reset();