diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 21ada7133..309884fb9 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1267,7 +1267,7 @@ bool cmGlobalGenerator::Compute() for (std::vector::iterator it = autogenTargets.begin(); it != autogenTargets.end(); ++it) { - cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget((*it)->Target); + cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(*it); } #endif @@ -1451,15 +1451,14 @@ cmGlobalGenerator::CreateQtAutoGeneratorsTargets() cmGeneratorTarget* gt = this->GetGeneratorTarget(&ti->second); - cmQtAutoGeneratorInitializer::InitializeAutogenSources(gt->Target); + cmQtAutoGeneratorInitializer::InitializeAutogenSources(gt); filteredTargets.push_back(gt); } for(std::vector::iterator ti = filteredTargets.begin(); ti != filteredTargets.end(); ++ti) { - cmTarget* target = (*ti)->Target; cmQtAutoGeneratorInitializer::InitializeAutogenTarget( - this->LocalGenerators[i], target); + this->LocalGenerators[i], *ti); autogenTargets.push_back(*ti); } } diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index fe888b7be..2703f4c99 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -25,19 +25,16 @@ # include "cmGlobalVisualStudioGenerator.h" #endif -static void SetupSourceFiles(cmTarget const* target, +static void SetupSourceFiles(cmGeneratorTarget const* target, std::vector& skipMoc, std::vector& mocSources, std::vector& mocHeaders, std::vector& skipUic) { - cmMakefile* makefile = target->GetMakefile(); + cmMakefile* makefile = target->Target->GetMakefile(); std::vector srcFiles; - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); - gtgt->GetConfigCommonSourceFiles(srcFiles); + target->GetConfigCommonSourceFiles(srcFiles); std::vector newRccFiles; @@ -67,7 +64,7 @@ static void SetupSourceFiles(cmTarget const* target, std::string basename = cmsys::SystemTools:: GetFilenameWithoutLastExtension(absFile); - std::string rcc_output_dir = target->GetSupportDirectory(); + std::string rcc_output_dir = target->Target->GetSupportDirectory(); cmSystemTools::MakeDirectory(rcc_output_dir.c_str()); std::string rcc_output_file = rcc_output_dir; rcc_output_file += "/qrc_" + basename + ".cpp"; @@ -104,40 +101,38 @@ static void SetupSourceFiles(cmTarget const* target, fileIt != newRccFiles.end(); ++fileIt) { - const_cast(target)->AddSource(*fileIt); + const_cast(target->Target)->AddSource(*fileIt); } } -static void GetCompileDefinitionsAndDirectories(cmTarget const* target, - const std::string& config, - std::string &incs, - std::string &defs) +static void GetCompileDefinitionsAndDirectories( + cmGeneratorTarget const* target, + const std::string& config, + std::string &incs, + std::string &defs) { - cmMakefile* makefile = target->GetMakefile(); - cmGlobalGenerator* globalGen = makefile->GetGlobalGenerator(); std::vector includeDirs; - cmGeneratorTarget *gtgt = globalGen->GetGeneratorTarget(target); - cmLocalGenerator *localGen = gtgt->GetLocalGenerator(); + cmLocalGenerator *localGen = target->GetLocalGenerator(); // Get the include dirs for this target, without stripping the implicit // include dirs off, see http://public.kitware.com/Bug/view.php?id=13667 - localGen->GetIncludeDirectories(includeDirs, gtgt, "CXX", config, false); + localGen->GetIncludeDirectories(includeDirs, target, "CXX", config, false); incs = cmJoin(includeDirs, ";"); std::set defines; - localGen->AddCompileDefinitions(defines, target, config, "CXX"); + localGen->AddCompileDefinitions(defines, target->Target, config, "CXX"); defs += cmJoin(defines, ";"); } -static void SetupAutoMocTarget(cmTarget const* target, +static void SetupAutoMocTarget(cmGeneratorTarget const* target, const std::string &autogenTargetName, std::vector const& skipMoc, std::vector const& mocHeaders, std::map &configIncludes, std::map &configDefines) { - cmMakefile* makefile = target->GetMakefile(); + cmMakefile* makefile = target->Target->GetMakefile(); const char* tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS"); std::string _moc_options = (tmp!=0 ? tmp : ""); @@ -222,22 +217,20 @@ static void SetupAutoMocTarget(cmTarget const* target, } } -static void GetUicOpts(cmTarget const* target, const std::string& config, +static void GetUicOpts(cmGeneratorTarget const* target, + const std::string& config, std::string &optString) { - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); std::vector opts; - gtgt->GetAutoUicOptions(opts, config); + target->GetAutoUicOptions(opts, config); optString = cmJoin(opts, ";"); } -static void SetupAutoUicTarget(cmTarget const* target, +static void SetupAutoUicTarget(cmGeneratorTarget const* target, std::vector const& skipUic, std::map &configUicOptions) { - cmMakefile *makefile = target->GetMakefile(); + cmMakefile *makefile = target->Target->GetMakefile(); std::set skipped; skipped.insert(skipUic.begin(), skipUic.end()); @@ -340,12 +333,9 @@ static void SetupAutoUicTarget(cmTarget const* target, } } -static std::string GetRccExecutable(cmTarget const* target) +static std::string GetRccExecutable(cmGeneratorTarget const* target) { - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); - cmMakefile *makefile = target->GetMakefile(); + cmMakefile *makefile = target->Target->GetMakefile(); const char *qtVersion = makefile->GetDefinition("_target_qt_version"); if (!qtVersion) { @@ -355,7 +345,8 @@ static std::string GetRccExecutable(cmTarget const* target) qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } if (const char *targetQtVersion = - gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) + target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", + "")) { qtVersion = targetQtVersion; } @@ -434,7 +425,7 @@ static void MergeRccOptions(std::vector &opts, } std::string GetAutogenTargetName( - cmTarget const* target) + cmGeneratorTarget const* target) { std::string autogenTargetName = target->GetName(); autogenTargetName += "_automoc"; @@ -442,9 +433,9 @@ std::string GetAutogenTargetName( } std::string GetAutogenTargetDir( - cmTarget const* target) + cmGeneratorTarget const* target) { - cmMakefile* makefile = target->GetMakefile(); + cmMakefile* makefile = target->Target->GetMakefile(); std::string targetDir = makefile->GetCurrentBinaryDirectory(); targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory(); targetDir += "/"; @@ -485,7 +476,7 @@ static std::string ReadAll(const std::string& filename) } static std::string ListQt5RccInputs(cmSourceFile* sf, - cmTarget const* target, + cmGeneratorTarget const* target, std::vector& depends) { std::string rccCommand @@ -591,17 +582,14 @@ static std::string ListQt4RccInputs(cmSourceFile* sf, return entriesList; } -static void SetupAutoRccTarget(cmTarget const* target) +static void SetupAutoRccTarget(cmGeneratorTarget const* target) { std::string _rcc_files; const char* sepRccFiles = ""; - cmMakefile *makefile = target->GetMakefile(); + cmMakefile *makefile = target->Target->GetMakefile(); std::vector srcFiles; - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); - gtgt->GetConfigCommonSourceFiles(srcFiles); + target->GetConfigCommonSourceFiles(srcFiles); std::string qrcInputs; const char* qrcInputsSep = ""; @@ -705,9 +693,10 @@ static void SetupAutoRccTarget(cmTarget const* target) GetRccExecutable(target).c_str()); } -void cmQtAutoGeneratorInitializer::InitializeAutogenSources(cmTarget* target) +void cmQtAutoGeneratorInitializer::InitializeAutogenSources( + cmGeneratorTarget* target) { - cmMakefile* makefile = target->GetMakefile(); + cmMakefile* makefile = target->Target->GetMakefile(); if (target->GetPropertyAsBool("AUTOMOC")) { @@ -720,15 +709,15 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenSources(cmTarget* target) makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", mocCppFile.c_str(), false); - target->AddSource(mocCppFile); + target->Target->AddSource(mocCppFile); } } void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( cmLocalGenerator* lg, - cmTarget* target) + cmGeneratorTarget* target) { - cmMakefile* makefile = target->GetMakefile(); + cmMakefile* makefile = target->Target->GetMakefile(); std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); if (qtMajorVersion == "") @@ -825,9 +814,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( ) { std::vector srcFiles; - cmGeneratorTarget* gtgt = - lg->GetGlobalGenerator()->GetGeneratorTarget(target); - gtgt->GetConfigCommonSourceFiles(srcFiles); + target->GetConfigCommonSourceFiles(srcFiles); for(std::vector::const_iterator fileIt = srcFiles.begin(); fileIt != srcFiles.end(); ++fileIt) @@ -846,7 +833,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( std::string basename = cmsys::SystemTools:: GetFilenameWithoutLastExtension(absFile); - std::string rcc_output_dir = target->GetSupportDirectory(); + std::string rcc_output_dir = target->Target->GetSupportDirectory(); cmSystemTools::MakeDirectory(rcc_output_dir.c_str()); std::string rcc_output_file = rcc_output_dir; rcc_output_file += "/qrc_" + basename + ".cpp"; @@ -887,7 +874,7 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( workingDirectory.c_str()); cc.SetEscapeOldStyle(false); cc.SetEscapeAllowMakeVars(true); - target->AddPreBuildCommand(cc); + target->Target->AddPreBuildCommand(cc); } else #endif @@ -916,17 +903,17 @@ void cmQtAutoGeneratorInitializer::InitializeAutogenTarget( else { // inherit FOLDER property from target (#13688) - copyTargetProperty(autogenTarget, target, "FOLDER"); + copyTargetProperty(gt->Target, target->Target, "FOLDER"); } - target->AddUtility(autogenTargetName); + target->Target->AddUtility(autogenTargetName); } } void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget( - cmTarget const* target) + cmGeneratorTarget const* target) { - cmMakefile* makefile = target->GetMakefile(); + cmMakefile* makefile = target->Target->GetMakefile(); // forget the variables added here afterwards again: cmMakefile::ScopePushPop varScope(makefile); @@ -947,11 +934,8 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget( { qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); if (const char *targetQtVersion = - gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) + target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) { qtVersion = targetQtVersion; } diff --git a/Source/cmQtAutoGeneratorInitializer.h b/Source/cmQtAutoGeneratorInitializer.h index ad5c85c73..eaf140d26 100644 --- a/Source/cmQtAutoGeneratorInitializer.h +++ b/Source/cmQtAutoGeneratorInitializer.h @@ -21,15 +21,16 @@ #include class cmSourceFile; -class cmTarget; +class cmGeneratorTarget; class cmLocalGenerator; class cmQtAutoGeneratorInitializer { public: - static void InitializeAutogenSources(cmTarget* target); - static void InitializeAutogenTarget(cmLocalGenerator* lg, cmTarget* target); - static void SetupAutoGenerateTarget(cmTarget const* target); + static void InitializeAutogenSources(cmGeneratorTarget* target); + static void InitializeAutogenTarget(cmLocalGenerator* lg, + cmGeneratorTarget* target); + static void SetupAutoGenerateTarget(cmGeneratorTarget const* target); }; #endif