cmGeneratorTarget: Move GetConfigCommonSourceFiles from cmTarget.

This commit is contained in:
Stephen Kelly 2015-08-05 17:37:50 +02:00
parent 69329fff70
commit c2b7336ff3
10 changed files with 88 additions and 72 deletions

View File

@ -4415,12 +4415,69 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const
return &impl;
}
//----------------------------------------------------------------------------
bool cmGeneratorTarget::GetConfigCommonSourceFiles(
std::vector<cmSourceFile*>& files) const
{
std::vector<std::string> configs;
this->Makefile->GetConfigurations(configs);
if (configs.empty())
{
configs.push_back("");
}
std::vector<std::string>::const_iterator it = configs.begin();
const std::string& firstConfig = *it;
this->Target->GetSourceFiles(files, firstConfig);
for ( ; it != configs.end(); ++it)
{
std::vector<cmSourceFile*> configFiles;
this->Target->GetSourceFiles(configFiles, *it);
if (configFiles != files)
{
std::string firstConfigFiles;
const char* sep = "";
for (std::vector<cmSourceFile*>::const_iterator fi = files.begin();
fi != files.end(); ++fi)
{
firstConfigFiles += sep;
firstConfigFiles += (*fi)->GetFullPath();
sep = "\n ";
}
std::string thisConfigFiles;
sep = "";
for (std::vector<cmSourceFile*>::const_iterator fi = configFiles.begin();
fi != configFiles.end(); ++fi)
{
thisConfigFiles += sep;
thisConfigFiles += (*fi)->GetFullPath();
sep = "\n ";
}
std::ostringstream e;
e << "Target \"" << this->GetName()
<< "\" has source files which vary by "
"configuration. This is not supported by the \""
<< this->GlobalGenerator->GetName()
<< "\" generator.\n"
"Config \"" << firstConfig << "\":\n"
" " << firstConfigFiles << "\n"
"Config \"" << *it << "\":\n"
" " << thisConfigFiles << "\n";
this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
}
return true;
}
//----------------------------------------------------------------------------
void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages,
const std::string& config) const
{
std::vector<cmSourceFile*> sourceFiles;
this->Target->GetSourceFiles(sourceFiles, config);
this->GetSourceFiles(sourceFiles, config);
for(std::vector<cmSourceFile*>::const_iterator
i = sourceFiles.begin(); i != sourceFiles.end(); ++i)
{

View File

@ -213,6 +213,8 @@ public:
void GetLanguages(std::set<std::string>& languages,
std::string const& config) const;
bool GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const;
bool HaveBuildTreeRPATH(const std::string& config) const;
/** Full path with trailing slash to the top-level directory

View File

@ -843,7 +843,7 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target)
{
// Issue diagnostic if the source files depend on the config.
std::vector<cmSourceFile*> sources;
if (!target.GetConfigCommonSourceFiles(sources))
if (!gt->GetConfigCommonSourceFiles(sources))
{
return false;
}

View File

@ -1124,7 +1124,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
// organize the sources
std::vector<cmSourceFile*> classes;
if (!cmtarget.GetConfigCommonSourceFiles(classes))
if (!gtgt->GetConfigCommonSourceFiles(classes))
{
return false;
}
@ -1505,7 +1505,8 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
}
std::vector<cmSourceFile*> classes;
if (!cmtarget.GetConfigCommonSourceFiles(classes))
cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget);
if (!gtgt->GetConfigCommonSourceFiles(classes))
{
return;
}
@ -2557,7 +2558,8 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget)
if(cmtarget.GetType() == cmTarget::UTILITY)
{
std::vector<cmSourceFile*> sources;
if (!cmtarget.GetConfigCommonSourceFiles(sources))
cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget);
if (!gtgt->GetConfigCommonSourceFiles(sources))
{
return 0;
}
@ -3085,7 +3087,8 @@ bool cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
}
std::vector<cmSourceFile*> classes;
if (!cmtarget.GetConfigCommonSourceFiles(classes))
cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget);
if (!gtgt->GetConfigCommonSourceFiles(classes))
{
return false;
}

View File

@ -305,9 +305,12 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
// We may be modifying the source groups temporarily, so make a copy.
std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target);
// get the classes from the source lists then add them to the groups
std::vector<cmSourceFile*> classes;
if (!target.GetConfigCommonSourceFiles(classes))
if (!gt->GetConfigCommonSourceFiles(classes))
{
return;
}

View File

@ -1469,10 +1469,13 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
// We may be modifying the source groups temporarily, so make a copy.
std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target);
// get the classes from the source lists then add them to the groups
this->ModuleDefinitionFile = "";
std::vector<cmSourceFile*> classes;
if (!target.GetConfigCommonSourceFiles(classes))
if (!gt->GetConfigCommonSourceFiles(classes))
{
return;
}
@ -1514,8 +1517,6 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
{
// VS >= 8 support per-config source locations so we
// list object library content as external objects.
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target);
std::vector<std::string> objs;
gt->UseObjectLibraries(objs, "");
if(!objs.empty())

View File

@ -403,7 +403,9 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg,
)
{
std::vector<cmSourceFile*> srcFiles;
target->GetConfigCommonSourceFiles(srcFiles);
cmGeneratorTarget* gtgt =
lg->GetGlobalGenerator()->GetGeneratorTarget(target);
gtgt->GetConfigCommonSourceFiles(srcFiles);
for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
fileIt != srcFiles.end();
++fileIt)
@ -661,7 +663,10 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target)
const char* sepHeaders = "";
std::vector<cmSourceFile*> srcFiles;
target->GetConfigCommonSourceFiles(srcFiles);
cmGeneratorTarget *gtgt = target->GetMakefile()
->GetGlobalGenerator()
->GetGeneratorTarget(target);
gtgt->GetConfigCommonSourceFiles(srcFiles);
const char *skipMocSep = "";
const char *skipUicSep = "";
@ -1046,7 +1051,10 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
cmMakefile *makefile = target->GetMakefile();
std::vector<cmSourceFile*> srcFiles;
target->GetConfigCommonSourceFiles(srcFiles);
cmGeneratorTarget *gtgt = target->GetMakefile()
->GetGlobalGenerator()
->GetGeneratorTarget(target);
gtgt->GetConfigCommonSourceFiles(srcFiles);
std::string qrcInputs;
const char* qrcInputsSep = "";

View File

@ -724,62 +724,6 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files,
cmDeleteAll(linkInterfaceSourcesEntries);
}
//----------------------------------------------------------------------------
bool
cmTarget::GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const
{
std::vector<std::string> configs;
this->Makefile->GetConfigurations(configs);
if (configs.empty())
{
configs.push_back("");
}
std::vector<std::string>::const_iterator it = configs.begin();
const std::string& firstConfig = *it;
this->GetSourceFiles(files, firstConfig);
for ( ; it != configs.end(); ++it)
{
std::vector<cmSourceFile*> configFiles;
this->GetSourceFiles(configFiles, *it);
if (configFiles != files)
{
std::string firstConfigFiles;
const char* sep = "";
for (std::vector<cmSourceFile*>::const_iterator fi = files.begin();
fi != files.end(); ++fi)
{
firstConfigFiles += sep;
firstConfigFiles += (*fi)->GetFullPath();
sep = "\n ";
}
std::string thisConfigFiles;
sep = "";
for (std::vector<cmSourceFile*>::const_iterator fi = configFiles.begin();
fi != configFiles.end(); ++fi)
{
thisConfigFiles += sep;
thisConfigFiles += (*fi)->GetFullPath();
sep = "\n ";
}
std::ostringstream e;
e << "Target \"" << this->Name << "\" has source files which vary by "
"configuration. This is not supported by the \""
<< this->Makefile->GetGlobalGenerator()->GetName()
<< "\" generator.\n"
"Config \"" << firstConfig << "\":\n"
" " << firstConfigFiles << "\n"
"Config \"" << *it << "\":\n"
" " << thisConfigFiles << "\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
}
return true;
}
//----------------------------------------------------------------------------
void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files,
const std::string& config) const

View File

@ -137,8 +137,6 @@ public:
*/
void GetSourceFiles(std::vector<cmSourceFile*> &files,
const std::string& config) const;
bool GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const;
/**
* Add sources to the target.
*/

View File

@ -965,7 +965,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
std::vector<cmSourceGroup> sourceGroups =
this->Makefile->GetSourceGroups();
std::vector<cmSourceFile*> classes;
if (!this->Target->GetConfigCommonSourceFiles(classes))
if (!this->GeneratorTarget->GetConfigCommonSourceFiles(classes))
{
return;
}