summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-03-18 18:23:45 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-04-02 21:12:56 (GMT)
commit042c1c834e69ee60b605b02bad8be87b2193a7d2 (patch)
tree3103f2172ee2e7a159bf7aaaa05d16e43012d556
parentfdcefe3c42fefdfcd27e6cf7b679f39cb99db4b9 (diff)
downloadCMake-042c1c834e69ee60b605b02bad8be87b2193a7d2.zip
CMake-042c1c834e69ee60b605b02bad8be87b2193a7d2.tar.gz
CMake-042c1c834e69ee60b605b02bad8be87b2193a7d2.tar.bz2
cmTarget: Compute languages from object libraries on demand.
-rw-r--r--Source/cmTarget.cxx67
-rw-r--r--Source/cmTarget.h5
2 files changed, 47 insertions, 25 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index aea6446..61260be 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -608,13 +608,6 @@ void cmTarget::AddSources(std::vector<std::string> const& srcs)
if(src[0] == '$' && src[1] == '<')
{
this->AddSource(src);
-
- if(cmHasLiteralPrefix(i->c_str(), "$<TARGET_OBJECTS:") &&
- (*i)[i->size()-1] == '>')
- {
- std::string objLibName = i->substr(17, i->size()-18);
- this->ObjectLibraries.push_back(objLibName);
- }
}
else
{
@@ -5013,6 +5006,53 @@ void cmTarget::GetLanguages(std::set<std::string>& languages) const
languages.insert(lang);
}
}
+
+ std::vector<cmTarget*> objectLibraries;
+ std::vector<cmSourceFile const*> externalObjects;
+ if (this->Makefile->GetGeneratorTargets().empty())
+ {
+ // At configure-time, this method can be called as part of getting the
+ // LOCATION property or to export() a file to be include()d. However
+ // there is no cmGeneratorTarget at configure-time, so search the SOURCES
+ // for TARGET_OBJECTS instead for backwards compatibility with OLD
+ // behavior of CMP0024 and CMP0026 only.
+ std::vector<std::string> srcs;
+ cmSystemTools::ExpandListArgument(this->GetProperty("SOURCES"), srcs);
+ for(std::vector<std::string>::const_iterator it = srcs.begin();
+ it != srcs.end(); ++it)
+ {
+ if (cmHasLiteralPrefix(*it, "$<TARGET_OBJECTS:")
+ && cmHasLiteralSuffix(*it, ">"))
+ {
+ std::string objLibName = it->substr(17, it->size()-18);
+ if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLibName))
+ {
+ objectLibraries.push_back(tgt);
+ }
+ }
+ }
+ }
+ else
+ {
+ cmGeneratorTarget* gt = this->Makefile->GetLocalGenerator()
+ ->GetGlobalGenerator()
+ ->GetGeneratorTarget(this);
+ gt->GetExternalObjects(externalObjects);
+ for(std::vector<cmSourceFile const*>::const_iterator
+ i = externalObjects.begin(); i != externalObjects.end(); ++i)
+ {
+ std::string objLib = (*i)->GetObjectLibrary();
+ if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib))
+ {
+ objectLibraries.push_back(tgt);
+ }
+ }
+ }
+ for(std::vector<cmTarget*>::const_iterator
+ i = objectLibraries.begin(); i != objectLibraries.end(); ++i)
+ {
+ (*i)->GetLanguages(languages);
+ }
}
//----------------------------------------------------------------------------
@@ -6077,19 +6117,6 @@ cmTarget::ComputeLinkImplementationLanguages(LinkImplementation& impl) const
std::set<std::string> languages;
// Get languages used in our source files.
this->GetLanguages(languages);
- // Get languages used in object library sources.
- for(std::vector<std::string>::const_iterator
- i = this->ObjectLibraries.begin();
- i != this->ObjectLibraries.end(); ++i)
- {
- if(cmTarget* objLib = this->Makefile->FindTargetToUse(*i))
- {
- if(objLib->GetType() == cmTarget::OBJECT_LIBRARY)
- {
- objLib->GetLanguages(languages);
- }
- }
- }
// Copy the set of langauges to the link implementation.
for(std::set<std::string>::iterator li = languages.begin();
li != languages.end(); ++li)
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 45fca53..fcbff93 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -137,10 +137,6 @@ public:
*/
void GetSourceFiles(std::vector<std::string> &files) const;
void GetSourceFiles(std::vector<cmSourceFile*> &files) const;
- std::vector<std::string> const& GetObjectLibraries() const
- {
- return this->ObjectLibraries;
- }
/**
* Add sources to the target.
@@ -686,7 +682,6 @@ private:
std::vector<cmCustomCommand> PreLinkCommands;
std::vector<cmCustomCommand> PostBuildCommands;
TargetType TargetTypeValue;
- std::vector<std::string> ObjectLibraries;
LinkLibraryVectorType LinkLibraries;
LinkLibraryVectorType PrevLinkedLibraries;
bool LinkLibrariesAnalyzed;