summaryrefslogtreecommitdiffstats
path: root/Source/cmComputeTargetDepends.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-05-28 18:58:11 (GMT)
committerBrad King <brad.king@kitware.com>2021-05-28 19:25:28 (GMT)
commit83ad066ed10ccabc4331c4b620ad6a4fa0cd36ba (patch)
tree4ebae82ceea27a06304ff1991d221af8a1c85425 /Source/cmComputeTargetDepends.cxx
parent7f506b95a78a3238d3481539810441ca955a0901 (diff)
downloadCMake-83ad066ed10ccabc4331c4b620ad6a4fa0cd36ba.zip
CMake-83ad066ed10ccabc4331c4b620ad6a4fa0cd36ba.tar.gz
CMake-83ad066ed10ccabc4331c4b620ad6a4fa0cd36ba.tar.bz2
cmComputeTargetDepends: Factor out helper to add object library dependency
Diffstat (limited to 'Source/cmComputeTargetDepends.cxx')
-rw-r--r--Source/cmComputeTargetDepends.cxx49
1 files changed, 29 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)