summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGenerator.cxx
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2017-08-26 11:59:57 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2017-09-07 15:53:18 (GMT)
commitd1e5eb849704f73d646f64105d44807f3de50e48 (patch)
tree2246c9fd4e76d5f6eecdf42372d7c28adfc19b0a /Source/cmGlobalGenerator.cxx
parent25ac91a715ee5f21fd169c47d55e02234c00915f (diff)
downloadCMake-d1e5eb849704f73d646f64105d44807f3de50e48.zip
CMake-d1e5eb849704f73d646f64105d44807f3de50e48.tar.gz
CMake-d1e5eb849704f73d646f64105d44807f3de50e48.tar.bz2
Autogen: Iterate source files only once
This is a large commit that serves multiple purposes - Iterate source files only once and store all extracted information in a cmQtAutogenDigest class that can be reused. This is brings speed improvements because several properties are only evaluated once. More that that it helps to avoid duplication of code with non trivial files property checks. - Fix the Visual Studio generator to use PRE_BUILD when possible. - Convert `for( ... )` loops to C++11 range base loops where possible (cmQtAutogen*.cxx only). - String concatenation optimizations.
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r--Source/cmGlobalGenerator.cxx74
1 files changed, 37 insertions, 37 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index ab35593..39c181a 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1263,8 +1263,7 @@ bool cmGlobalGenerator::Compute()
#ifdef CMAKE_BUILD_WITH_CMAKE
// Iterate through all targets and set up automoc for those which have
// the AUTOMOC, AUTOUIC or AUTORCC property set
- std::vector<cmGeneratorTarget const*> autogenTargets =
- this->CreateQtAutoGeneratorsTargets();
+ cmQtAutoGenDigestUPV autogenDigests = this->CreateQtAutoGeneratorsTargets();
#endif
unsigned int i;
@@ -1287,11 +1286,10 @@ bool cmGlobalGenerator::Compute()
}
#ifdef CMAKE_BUILD_WITH_CMAKE
- for (std::vector<cmGeneratorTarget const*>::iterator it =
- autogenTargets.begin();
- it != autogenTargets.end(); ++it) {
- cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(*it);
+ for (const cmQtAutoGenDigestUP& digest : autogenDigests) {
+ cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(*digest);
}
+ autogenDigests.clear();
#endif
for (i = 0; i < this->LocalGenerators.size(); ++i) {
@@ -1427,24 +1425,16 @@ bool cmGlobalGenerator::ComputeTargetDepends()
return true;
}
-std::vector<const cmGeneratorTarget*>
-cmGlobalGenerator::CreateQtAutoGeneratorsTargets()
+cmQtAutoGenDigestUPV cmGlobalGenerator::CreateQtAutoGeneratorsTargets()
{
- std::vector<const cmGeneratorTarget*> autogenTargets;
+ cmQtAutoGenDigestUPV autogenDigests;
#ifdef CMAKE_BUILD_WITH_CMAKE
- for (std::vector<cmLocalGenerator*>::const_iterator lgit =
- this->LocalGenerators.begin();
- lgit != this->LocalGenerators.end(); ++lgit) {
- cmLocalGenerator* localGen = *lgit;
+ for (cmLocalGenerator* localGen : this->LocalGenerators) {
const std::vector<cmGeneratorTarget*>& targets =
localGen->GetGeneratorTargets();
// Find targets that require AUTOGEN processing
- std::vector<cmGeneratorTarget*> filteredTargets;
- filteredTargets.reserve(targets.size());
- for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
- ti != targets.end(); ++ti) {
- cmGeneratorTarget* target = *ti;
+ for (cmGeneratorTarget* target : targets) {
if (target->GetType() == cmStateEnums::GLOBAL_TARGET) {
continue;
}
@@ -1455,33 +1445,43 @@ cmGlobalGenerator::CreateQtAutoGeneratorsTargets()
target->GetType() != cmStateEnums::OBJECT_LIBRARY) {
continue;
}
- if ((!target->GetPropertyAsBool("AUTOMOC") &&
- !target->GetPropertyAsBool("AUTOUIC") &&
- !target->GetPropertyAsBool("AUTORCC")) ||
- target->IsImported()) {
+ if (target->IsImported()) {
continue;
}
- // don't do anything if there is no Qt4 or Qt5Core (which contains moc)
- cmMakefile* mf = target->Target->GetMakefile();
- std::string qtMajorVersion = mf->GetSafeDefinition("QT_VERSION_MAJOR");
- if (qtMajorVersion == "") {
- qtMajorVersion = mf->GetSafeDefinition("Qt5Core_VERSION_MAJOR");
+
+ const bool mocEnabled = target->GetPropertyAsBool("AUTOMOC");
+ const bool uicEnabled = target->GetPropertyAsBool("AUTOUIC");
+ const bool rccEnabled = target->GetPropertyAsBool("AUTORCC");
+ if (!mocEnabled && !uicEnabled && !rccEnabled) {
+ continue;
}
- if (qtMajorVersion != "4" && qtMajorVersion != "5") {
+
+ std::string qtVersionMajor =
+ cmQtAutoGeneratorInitializer::GetQtMajorVersion(target);
+ // don't do anything if there is no Qt4 or Qt5Core (which contains moc)
+ if (qtVersionMajor != "4" && qtVersionMajor != "5") {
continue;
}
- filteredTargets.push_back(target);
- }
- // Initialize AUTOGEN targets
- for (std::vector<cmGeneratorTarget*>::iterator ti =
- filteredTargets.begin();
- ti != filteredTargets.end(); ++ti) {
- cmQtAutoGeneratorInitializer::InitializeAutogenTarget(localGen, *ti);
- autogenTargets.push_back(*ti);
+
+ {
+ cmQtAutoGenDigestUP digest(new cmQtAutoGenDigest(target));
+ digest->QtVersionMajor = std::move(qtVersionMajor);
+ digest->QtVersionMinor =
+ cmQtAutoGeneratorInitializer::GetQtMinorVersion(
+ target, digest->QtVersionMajor);
+ digest->MocEnabled = mocEnabled;
+ digest->UicEnabled = uicEnabled;
+ digest->RccEnabled = rccEnabled;
+ autogenDigests.emplace_back(std::move(digest));
+ }
}
}
+ // Initialize autogen targets
+ for (const cmQtAutoGenDigestUP& digest : autogenDigests) {
+ cmQtAutoGeneratorInitializer::InitializeAutogenTarget(*digest);
+ }
#endif
- return autogenTargets;
+ return autogenDigests;
}
cmLinkLineComputer* cmGlobalGenerator::CreateLinkLineComputer(