summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-03-18 15:40:46 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-04-02 21:12:56 (GMT)
commite5da9e51d02ba912bba4f556ecd6453dd187c8d8 (patch)
tree1bc042307cf734999bf92d5f82f7feb206d5f3b8 /Source
parent5702e10677e72a75370e8c1bbe6f10fa5ad675a9 (diff)
downloadCMake-e5da9e51d02ba912bba4f556ecd6453dd187c8d8.zip
CMake-e5da9e51d02ba912bba4f556ecd6453dd187c8d8.tar.gz
CMake-e5da9e51d02ba912bba4f556ecd6453dd187c8d8.tar.bz2
cmTarget: Allow any generator expression in SOURCES property.
Remove use of UseObjectLibraries from Makefile and Ninja generators. It is not needed now because those generators use GetExternalObjects which already contains the objects from object libraries. The VS10 generator calls both the UseObjectLibraries and the GetExternalObjects methods. Ensure that duplicates are not created by skipping objects from object libraries in handling of GetExternalObjects. Similarly, fix VS6, VS7 and Xcode object handling by skipping external objects from OBJECT_LIBRARY usage as appropriate. The error message in the BadSourceExpression1 test is now reported by the generator expression evaluator, so it has different text.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx5
-rw-r--r--Source/cmLocalVisualStudio6Generator.cxx10
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx4
-rw-r--r--Source/cmMakefileTargetGenerator.cxx3
-rw-r--r--Source/cmNinjaTargetGenerator.cxx11
-rw-r--r--Source/cmTarget.cxx57
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx13
7 files changed, 62 insertions, 41 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index fdf73d6..2a6e522 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1007,7 +1007,10 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
if(filetype &&
filetype->GetString() == "compiled.mach-o.objfile")
{
- externalObjFiles.push_back(xsf);
+ if ((*i)->GetObjectLibrary().empty())
+ {
+ externalObjFiles.push_back(xsf);
+ }
}
else if(this->IsHeaderFile(*i) ||
(tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader) ||
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index e99f3a4..11e9679 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -324,6 +324,11 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); i++)
{
+ if (!(*i)->GetObjectLibrary().empty())
+ {
+ continue;
+ }
+
// Add the file to the list of sources.
std::string source = (*i)->GetFullPath();
cmSourceGroup* sourceGroup =
@@ -398,6 +403,11 @@ void cmLocalVisualStudio6Generator
for(std::vector<const cmSourceFile *>::const_iterator sf =
sourceFiles.begin(); sf != sourceFiles.end(); ++sf)
{
+ if (!(*sf)->GetObjectLibrary().empty())
+ {
+ continue;
+ }
+
std::string source = (*sf)->GetFullPath();
const cmCustomCommand *command =
(*sf)->GetCustomCommand();
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index e8562ca..8bac10d 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1401,6 +1401,10 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); i++)
{
+ if (!(*i)->GetObjectLibrary().empty())
+ {
+ continue;
+ }
// Add the file to the list of sources.
std::string source = (*i)->GetFullPath();
if(cmSystemTools::UpperCase((*i)->GetExtension()) == "DEF")
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 6759d05..c520f9e 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -202,9 +202,6 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
// Generate this object file's rule file.
this->WriteObjectRuleFiles(**si);
}
-
- // Add object library contents as external objects.
- this->GeneratorTarget->UseObjectLibraries(this->ExternalObjects);
}
//----------------------------------------------------------------------------
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 8865b3d..b7eab7d 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -525,17 +525,6 @@ cmNinjaTargetGenerator
this->ModuleDefinitionFile = this->ConvertToNinjaPath(def.c_str());
}
- {
- // Add object library contents as external objects.
- std::vector<std::string> objs;
- this->GeneratorTarget->UseObjectLibraries(objs);
- for(std::vector<std::string>::iterator oi = objs.begin();
- oi != objs.end(); ++oi)
- {
- this->Objects.push_back(ConvertToNinjaPath(oi->c_str()));
- }
- }
-
this->GetBuildFileStream() << "\n";
}
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 04ae5af..aea6446 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -551,15 +551,16 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files) const
si != this->Internal->SourceEntries.end(); ++si)
{
std::vector<std::string> srcs;
- cmSystemTools::ExpandListArgument((*si)->ge->GetInput(), srcs);
+ cmSystemTools::ExpandListArgument((*si)->ge->Evaluate(this->Makefile,
+ "",
+ false,
+ this),
+ srcs);
+
for(std::vector<std::string>::const_iterator i = srcs.begin();
i != srcs.end(); ++i)
{
std::string src = *i;
- if (cmGeneratorExpression::Find(src) != std::string::npos)
- {
- continue;
- }
cmSourceFile* sf = this->Makefile->GetOrCreateSource(src);
std::string e;
src = sf->GetFullPath(&e);
@@ -606,7 +607,14 @@ void cmTarget::AddSources(std::vector<std::string> const& srcs)
const char* src = i->c_str();
if(src[0] == '$' && src[1] == '<')
{
- this->ProcessSourceExpression(*i);
+ 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
{
@@ -734,28 +742,11 @@ cmSourceFile* cmTarget::AddSource(const std::string& src)
this->Internal->SourceEntries.push_back(
new cmTargetInternals::TargetPropertyEntry(cge));
}
- return this->Makefile->GetOrCreateSource(src);
-}
-
-
-
-//----------------------------------------------------------------------------
-void cmTarget::ProcessSourceExpression(std::string const& expr)
-{
- if(cmHasLiteralPrefix(expr.c_str(), "$<TARGET_OBJECTS:") &&
- expr[expr.size()-1] == '>')
+ if (cmGeneratorExpression::Find(src) != std::string::npos)
{
- std::string objLibName = expr.substr(17, expr.size()-18);
- this->ObjectLibraries.push_back(objLibName);
- this->AddSource(expr);
- }
- else
- {
- cmOStringStream e;
- e << "Unrecognized generator expression:\n"
- << " " << expr;
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return 0;
}
+ return this->Makefile->GetOrCreateSource(src);
}
//----------------------------------------------------------------------------
@@ -2886,6 +2877,14 @@ const char *cmTarget::GetProperty(const std::string& prop,
{
std::string objLibName = li->substr(17, li->size()-18);
+ if (cmGeneratorExpression::Find(objLibName) != std::string::npos)
+ {
+ ss << sep;
+ sep = ";";
+ ss << *li;
+ continue;
+ }
+
bool addContent = false;
bool noMessage = true;
cmOStringStream e;
@@ -2920,6 +2919,12 @@ const char *cmTarget::GetProperty(const std::string& prop,
ss << *li;
}
}
+ else if (cmGeneratorExpression::Find(*li) == std::string::npos)
+ {
+ ss << sep;
+ sep = ";";
+ ss << *li;
+ }
else
{
cmSourceFile *sf = this->Makefile->GetOrCreateSource(*li);
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index bb76b7f..8d10e7c 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1054,6 +1054,19 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
std::vector<cmSourceFile const*> externalObjects;
this->GeneratorTarget->GetExternalObjects(externalObjects);
+ for(std::vector<cmSourceFile const*>::iterator
+ si = externalObjects.begin();
+ si != externalObjects.end(); )
+ {
+ if (!(*si)->GetObjectLibrary().empty())
+ {
+ si = externalObjects.erase(si);
+ }
+ else
+ {
+ ++si;
+ }
+ }
if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10)
{
// For VS >= 11 we use LinkObjects to avoid linking custom command