From c355d10865ba0dbaef06d0eafe678627c875a5f5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 18 Mar 2014 17:04:46 +0100 Subject: cmComputeTargetDepends: Track object library depends. Relieve cmGeneratorTarget of that responsibility. --- Source/cmComputeTargetDepends.cxx | 29 +++++++++++++++++++++++++++++ Source/cmGeneratorTarget.cxx | 1 - 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx index b4dbce7..db8b7f3 100644 --- a/Source/cmComputeTargetDepends.cxx +++ b/Source/cmComputeTargetDepends.cxx @@ -16,6 +16,7 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmSystemTools.h" +#include "cmSourceFile.h" #include "cmTarget.h" #include "cmake.h" @@ -213,6 +214,34 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index) { std::set emitted; { + cmGeneratorTarget* gt = depender->GetMakefile()->GetLocalGenerator() + ->GetGlobalGenerator() + ->GetGeneratorTarget(depender); + std::vector objectFiles; + gt->GetExternalObjects(objectFiles); + for(std::vector::const_iterator + it = objectFiles.begin(); it != objectFiles.end(); ++it) + { + std::string objLib = (*it)->GetObjectLibrary(); + if (!objLib.empty() && emitted.insert(objLib).second) + { + if(depender->GetType() != cmTarget::EXECUTABLE && + depender->GetType() != cmTarget::STATIC_LIBRARY && + depender->GetType() != cmTarget::SHARED_LIBRARY && + depender->GetType() != cmTarget::MODULE_LIBRARY) + { + this->GlobalGenerator->GetCMakeInstance() + ->IssueMessage(cmake::FATAL_ERROR, + "Only executables and non-OBJECT libraries may " + "reference target objects.", + depender->GetBacktrace()); + return; + } + const_cast(depender)->AddUtility(objLib); + } + } + } + { std::vector tlibs; depender->GetDirectLinkLibraries("", tlibs, depender); // A target should not depend on itself. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 834f9fd..66f6bdf 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -528,7 +528,6 @@ void cmGeneratorTarget::LookupObjectLibraries() this->Target->GetBacktrace()); return; } - this->Target->AddUtility(objLib->GetName()); this->ObjectLibraries.push_back(objLib); } else -- cgit v0.12