diff options
-rw-r--r-- | Source/cmComputeTargetDepends.cxx | 49 | ||||
-rw-r--r-- | Source/cmComputeTargetDepends.h | 3 |
2 files changed, 32 insertions, 20 deletions
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index 85a9d9c..0f23417 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -233,26 +233,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) std::vector<cmSourceFile const*> objectFiles; depender->GetExternalObjects(objectFiles, it); for (cmSourceFile const* o : objectFiles) { - std::string const& objLib = o->GetObjectLibrary(); - if (!objLib.empty()) { - cmLinkItem const& objItem = - depender->ResolveLinkItem(objLib, cmListFileBacktrace()); - if (emitted.insert(objItem).second) { - if (depender->GetType() != cmStateEnums::EXECUTABLE && - depender->GetType() != cmStateEnums::STATIC_LIBRARY && - depender->GetType() != cmStateEnums::SHARED_LIBRARY && - depender->GetType() != cmStateEnums::MODULE_LIBRARY && - depender->GetType() != cmStateEnums::OBJECT_LIBRARY) { - this->GlobalGenerator->GetCMakeInstance()->IssueMessage( - MessageType::FATAL_ERROR, - "Only executables and libraries may reference target objects.", - depender->GetBacktrace()); - return; - } - const_cast<cmGeneratorTarget*>(depender)->Target->AddUtility( - objLib, false); - } - } + this->AddObjectDepends(depender_index, o, emitted); } } } @@ -319,6 +300,34 @@ void cmComputeTargetDepends::AddInterfaceDepends( } } +void cmComputeTargetDepends::AddObjectDepends(int depender_index, + cmSourceFile const* o, + std::set<cmLinkItem>& emitted) +{ + std::string const& objLib = o->GetObjectLibrary(); + if (objLib.empty()) { + return; + } + cmGeneratorTarget const* depender = this->Targets[depender_index]; + cmLinkItem const& objItem = + depender->ResolveLinkItem(objLib, cmListFileBacktrace()); + if (emitted.insert(objItem).second) { + if (depender->GetType() != cmStateEnums::EXECUTABLE && + depender->GetType() != cmStateEnums::STATIC_LIBRARY && + depender->GetType() != cmStateEnums::SHARED_LIBRARY && + depender->GetType() != cmStateEnums::MODULE_LIBRARY && + depender->GetType() != cmStateEnums::OBJECT_LIBRARY) { + this->GlobalGenerator->GetCMakeInstance()->IssueMessage( + MessageType::FATAL_ERROR, + "Only executables and libraries may reference target objects.", + depender->GetBacktrace()); + return; + } + const_cast<cmGeneratorTarget*>(depender)->Target->AddUtility(objLib, + false); + } +} + void cmComputeTargetDepends::AddTargetDepend(int depender_index, cmLinkItem const& dependee_name, bool linking, bool cross) diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h index 3517844..0eab368 100644 --- a/Source/cmComputeTargetDepends.h +++ b/Source/cmComputeTargetDepends.h @@ -16,6 +16,7 @@ class cmComputeComponentGraph; class cmGeneratorTarget; class cmGlobalGenerator; class cmLinkItem; +class cmSourceFile; class cmTargetDependSet; /** \class cmComputeTargetDepends @@ -71,6 +72,8 @@ private: cmListFileBacktrace const& dependee_backtrace, const std::string& config, std::set<cmLinkItem>& emitted); + void AddObjectDepends(int depender_index, cmSourceFile const* o, + std::set<cmLinkItem>& emitted); cmGlobalGenerator* GlobalGenerator; bool DebugMode; bool NoCycles; |