summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2017-08-09 09:22:56 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2017-08-10 16:48:15 (GMT)
commit362f9bd755c7b964184db38d1fb2217ded70af63 (patch)
tree92bb5224ba4cc97cd0d8786921fc97010cfa4282
parent952fc65d140a1b36fc2e580d7ca89de231a04412 (diff)
downloadCMake-362f9bd755c7b964184db38d1fb2217ded70af63.zip
CMake-362f9bd755c7b964184db38d1fb2217ded70af63.tar.gz
CMake-362f9bd755c7b964184db38d1fb2217ded70af63.tar.bz2
Autogen: Merge and remove redundant function calls
-rw-r--r--Source/cmGlobalGenerator.cxx47
-rw-r--r--Source/cmQtAutoGeneratorInitializer.cxx30
-rw-r--r--Source/cmQtAutoGeneratorInitializer.h1
3 files changed, 34 insertions, 44 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index c8b13ad..18d10c5 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1433,31 +1433,36 @@ cmGlobalGenerator::CreateQtAutoGeneratorsTargets()
std::vector<const cmGeneratorTarget*> autogenTargets;
#ifdef CMAKE_BUILD_WITH_CMAKE
- for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
- std::vector<cmGeneratorTarget*> targets =
- this->LocalGenerators[i]->GetGeneratorTargets();
+ for (std::vector<cmLocalGenerator*>::const_iterator lgit =
+ this->LocalGenerators.begin();
+ lgit != this->LocalGenerators.end(); ++lgit) {
+ cmLocalGenerator* localGen = *lgit;
+ 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*>::iterator ti = targets.begin();
+ for (std::vector<cmGeneratorTarget*>::const_iterator ti = targets.begin();
ti != targets.end(); ++ti) {
- if ((*ti)->GetType() == cmStateEnums::GLOBAL_TARGET) {
+ cmGeneratorTarget* target = *ti;
+ if (target->GetType() == cmStateEnums::GLOBAL_TARGET) {
continue;
}
- if ((*ti)->GetType() != cmStateEnums::EXECUTABLE &&
- (*ti)->GetType() != cmStateEnums::STATIC_LIBRARY &&
- (*ti)->GetType() != cmStateEnums::SHARED_LIBRARY &&
- (*ti)->GetType() != cmStateEnums::MODULE_LIBRARY &&
- (*ti)->GetType() != cmStateEnums::OBJECT_LIBRARY) {
+ if (target->GetType() != cmStateEnums::EXECUTABLE &&
+ target->GetType() != cmStateEnums::STATIC_LIBRARY &&
+ target->GetType() != cmStateEnums::SHARED_LIBRARY &&
+ target->GetType() != cmStateEnums::MODULE_LIBRARY &&
+ target->GetType() != cmStateEnums::OBJECT_LIBRARY) {
continue;
}
- if ((!(*ti)->GetPropertyAsBool("AUTOMOC") &&
- !(*ti)->GetPropertyAsBool("AUTOUIC") &&
- !(*ti)->GetPropertyAsBool("AUTORCC")) ||
- (*ti)->IsImported()) {
+ if ((!target->GetPropertyAsBool("AUTOMOC") &&
+ !target->GetPropertyAsBool("AUTOUIC") &&
+ !target->GetPropertyAsBool("AUTORCC")) ||
+ target->IsImported()) {
continue;
}
- // don't do anything if there is no Qt4 or Qt5Core (which contains moc):
- cmMakefile* mf = (*ti)->Target->GetMakefile();
+ // 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");
@@ -1465,17 +1470,13 @@ cmGlobalGenerator::CreateQtAutoGeneratorsTargets()
if (qtMajorVersion != "4" && qtMajorVersion != "5") {
continue;
}
-
- cmGeneratorTarget* gt = *ti;
-
- cmQtAutoGeneratorInitializer::InitializeAutogenSources(gt);
- filteredTargets.push_back(gt);
+ filteredTargets.push_back(target);
}
+ // Initialize AUTOGEN targets
for (std::vector<cmGeneratorTarget*>::iterator ti =
filteredTargets.begin();
ti != filteredTargets.end(); ++ti) {
- cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
- this->LocalGenerators[i], *ti);
+ cmQtAutoGeneratorInitializer::InitializeAutogenTarget(localGen, *ti);
autogenTargets.push_back(*ti);
}
}
diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx
index 2cf2ee9..7974977 100644
--- a/Source/cmQtAutoGeneratorInitializer.cxx
+++ b/Source/cmQtAutoGeneratorInitializer.cxx
@@ -263,13 +263,17 @@ static bool AddToSourceGroup(cmMakefile* makefile, const std::string& fileName,
return true;
}
-static void AddGeneratedSource(cmMakefile* makefile,
+static void AddGeneratedSource(cmGeneratorTarget* target,
const std::string& filename,
cmQtAutoGeneratorCommon::GeneratorType genType)
{
- cmSourceFile* gFile = makefile->GetOrCreateSource(filename, true);
- gFile->SetProperty("GENERATED", "1");
- gFile->SetProperty("SKIP_AUTOGEN", "On");
+ cmMakefile* makefile = target->Target->GetMakefile();
+ {
+ cmSourceFile* gFile = makefile->GetOrCreateSource(filename, true);
+ gFile->SetProperty("GENERATED", "1");
+ gFile->SetProperty("SKIP_AUTOGEN", "On");
+ }
+ target->AddSource(filename);
AddToSourceGroup(makefile, filename, genType);
}
@@ -692,19 +696,6 @@ static void RccSetupAutoTarget(cmGeneratorTarget const* target,
AddDefinitionEscaped(makefile, "_rcc_options_options", rccFileOptions);
}
-void cmQtAutoGeneratorInitializer::InitializeAutogenSources(
- cmGeneratorTarget* target)
-{
- if (target->GetPropertyAsBool("AUTOMOC")) {
- cmMakefile* makefile = target->Target->GetMakefile();
- // Mocs compilation file
- const std::string mocsComp =
- GetAutogenTargetBuildDir(target) + "/mocs_compilation.cpp";
- AddGeneratedSource(makefile, mocsComp, cmQtAutoGeneratorCommon::MOC);
- target->AddSource(mocsComp);
- }
-}
-
void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
cmLocalGenerator* lg, cmGeneratorTarget* target)
{
@@ -781,6 +772,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
// Add moc compilation to generated files list
if (mocEnabled) {
const std::string mocsComp = autogenBuildDir + "/mocs_compilation.cpp";
+ AddGeneratedSource(target, mocsComp, cmQtAutoGeneratorCommon::MOC);
autogenProvides.push_back(mocsComp);
}
@@ -880,10 +872,8 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
rccBuildFile += ".cpp";
// Register rcc ouput file as generated
- AddGeneratedSource(makefile, rccBuildFile,
+ AddGeneratedSource(target, rccBuildFile,
cmQtAutoGeneratorCommon::RCC);
- // Add rcc output file to origin target sources
- target->AddSource(rccBuildFile);
// Register rcc ouput file as generated by the _autogen target
autogenProvides.push_back(rccBuildFile);
}
diff --git a/Source/cmQtAutoGeneratorInitializer.h b/Source/cmQtAutoGeneratorInitializer.h
index ca806f5..11f6e1e 100644
--- a/Source/cmQtAutoGeneratorInitializer.h
+++ b/Source/cmQtAutoGeneratorInitializer.h
@@ -11,7 +11,6 @@ class cmLocalGenerator;
class cmQtAutoGeneratorInitializer
{
public:
- static void InitializeAutogenSources(cmGeneratorTarget* target);
static void InitializeAutogenTarget(cmLocalGenerator* lg,
cmGeneratorTarget* target);
static void SetupAutoGenerateTarget(cmGeneratorTarget const* target);