diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 2225fdc4e..c75ac234c 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -368,3 +368,37 @@ std::string cmCommonTargetGenerator::GetIncludes(std::string const& l) } return i->second; } + +std::vector +cmCommonTargetGenerator::GetLinkedTargetDirectories() const +{ + std::vector dirs; + std::set emitted; + if (cmComputeLinkInformation* cli = + this->Target->GetLinkInformation(this->ConfigName)) + { + cmComputeLinkInformation::ItemVector const& items = cli->GetItems(); + for(cmComputeLinkInformation::ItemVector::const_iterator + i = items.begin(); i != items.end(); ++i) + { + cmTarget const* linkee = i->Target; + if(linkee && !linkee->IsImported() + // We can ignore the INTERFACE_LIBRARY items because + // Target->GetLinkInformation already processed their + // link interface and they don't have any output themselves. + && linkee->GetType() != cmTarget::INTERFACE_LIBRARY + && emitted.insert(linkee).second) + { + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(linkee); + cmLocalGenerator* lg = gt->GetLocalGenerator(); + cmMakefile* mf = linkee->GetMakefile(); + std::string di = mf->GetCurrentBinaryDirectory(); + di += "/"; + di += lg->GetTargetDirectory(*linkee); + dirs.push_back(di); + } + } + } + return dirs; +} diff --git a/Source/cmCommonTargetGenerator.h b/Source/cmCommonTargetGenerator.h index 5451a5aec..166508d6e 100644 --- a/Source/cmCommonTargetGenerator.h +++ b/Source/cmCommonTargetGenerator.h @@ -85,6 +85,8 @@ protected: ByLanguageMap DefinesByLanguage; std::string GetIncludes(std::string const& l); ByLanguageMap IncludesByLanguage; + + std::vector GetLinkedTargetDirectories() const; }; #endif diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 6cc237836..0bf376436 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1058,33 +1058,11 @@ void cmMakefileTargetGenerator::WriteTargetDependRules() << "\n" << "# Targets to which this target links.\n" << "set(CMAKE_TARGET_LINKED_INFO_FILES\n"; - std::set emitted; - const char* cfg = this->LocalGenerator->GetConfigName().c_str(); - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) + std::vector dirs = this->GetLinkedTargetDirectories(); + for (std::vector::iterator i = dirs.begin(); + i != dirs.end(); ++i) { - cmComputeLinkInformation::ItemVector const& items = cli->GetItems(); - for(cmComputeLinkInformation::ItemVector::const_iterator - i = items.begin(); i != items.end(); ++i) - { - cmTarget const* linkee = i->Target; - if(linkee && !linkee->IsImported() - // We can ignore the INTERFACE_LIBRARY items because - // Target->GetLinkInformation already processed their - // link interface and they don't have any output themselves. - && linkee->GetType() != cmTarget::INTERFACE_LIBRARY - && emitted.insert(linkee).second) - { - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(linkee); - cmLocalGenerator* lg = gt->GetLocalGenerator(); - cmMakefile* mf = linkee->GetMakefile(); - std::string di = mf->GetCurrentBinaryDirectory(); - di += "/"; - di += lg->GetTargetDirectory(*linkee); - di += "/DependInfo.cmake"; - *this->InfoFileStream << " \"" << di << "\"\n"; - } - } + *this->InfoFileStream << " \"" << *i << "/DependInfo.cmake\"\n"; } *this->InfoFileStream << " )\n";