cmGeneratorTarget: Move GetConfigCommonSourceFiles from cmTarget.
This commit is contained in:
parent
69329fff70
commit
c2b7336ff3
@ -4415,12 +4415,69 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const
|
|||||||
return &impl;
|
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,
|
void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages,
|
||||||
const std::string& config) const
|
const std::string& config) const
|
||||||
{
|
{
|
||||||
std::vector<cmSourceFile*> sourceFiles;
|
std::vector<cmSourceFile*> sourceFiles;
|
||||||
this->Target->GetSourceFiles(sourceFiles, config);
|
this->GetSourceFiles(sourceFiles, config);
|
||||||
for(std::vector<cmSourceFile*>::const_iterator
|
for(std::vector<cmSourceFile*>::const_iterator
|
||||||
i = sourceFiles.begin(); i != sourceFiles.end(); ++i)
|
i = sourceFiles.begin(); i != sourceFiles.end(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -213,6 +213,8 @@ public:
|
|||||||
void GetLanguages(std::set<std::string>& languages,
|
void GetLanguages(std::set<std::string>& languages,
|
||||||
std::string const& config) const;
|
std::string const& config) const;
|
||||||
|
|
||||||
|
bool GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const;
|
||||||
|
|
||||||
bool HaveBuildTreeRPATH(const std::string& config) const;
|
bool HaveBuildTreeRPATH(const std::string& config) const;
|
||||||
|
|
||||||
/** Full path with trailing slash to the top-level directory
|
/** Full path with trailing slash to the top-level directory
|
||||||
|
@ -843,7 +843,7 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target)
|
|||||||
{
|
{
|
||||||
// Issue diagnostic if the source files depend on the config.
|
// Issue diagnostic if the source files depend on the config.
|
||||||
std::vector<cmSourceFile*> sources;
|
std::vector<cmSourceFile*> sources;
|
||||||
if (!target.GetConfigCommonSourceFiles(sources))
|
if (!gt->GetConfigCommonSourceFiles(sources))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1124,7 +1124,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
|
|||||||
|
|
||||||
// organize the sources
|
// organize the sources
|
||||||
std::vector<cmSourceFile*> classes;
|
std::vector<cmSourceFile*> classes;
|
||||||
if (!cmtarget.GetConfigCommonSourceFiles(classes))
|
if (!gtgt->GetConfigCommonSourceFiles(classes))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1505,7 +1505,8 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<cmSourceFile*> classes;
|
std::vector<cmSourceFile*> classes;
|
||||||
if (!cmtarget.GetConfigCommonSourceFiles(classes))
|
cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget);
|
||||||
|
if (!gtgt->GetConfigCommonSourceFiles(classes))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2557,7 +2558,8 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget)
|
|||||||
if(cmtarget.GetType() == cmTarget::UTILITY)
|
if(cmtarget.GetType() == cmTarget::UTILITY)
|
||||||
{
|
{
|
||||||
std::vector<cmSourceFile*> sources;
|
std::vector<cmSourceFile*> sources;
|
||||||
if (!cmtarget.GetConfigCommonSourceFiles(sources))
|
cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget);
|
||||||
|
if (!gtgt->GetConfigCommonSourceFiles(sources))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -3085,7 +3087,8 @@ bool cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<cmSourceFile*> classes;
|
std::vector<cmSourceFile*> classes;
|
||||||
if (!cmtarget.GetConfigCommonSourceFiles(classes))
|
cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget);
|
||||||
|
if (!gtgt->GetConfigCommonSourceFiles(classes))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -305,9 +305,12 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
|
|||||||
// We may be modifying the source groups temporarily, so make a copy.
|
// We may be modifying the source groups temporarily, so make a copy.
|
||||||
std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
|
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
|
// get the classes from the source lists then add them to the groups
|
||||||
std::vector<cmSourceFile*> classes;
|
std::vector<cmSourceFile*> classes;
|
||||||
if (!target.GetConfigCommonSourceFiles(classes))
|
if (!gt->GetConfigCommonSourceFiles(classes))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1469,10 +1469,13 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
|
|||||||
// We may be modifying the source groups temporarily, so make a copy.
|
// We may be modifying the source groups temporarily, so make a copy.
|
||||||
std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
|
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
|
// get the classes from the source lists then add them to the groups
|
||||||
this->ModuleDefinitionFile = "";
|
this->ModuleDefinitionFile = "";
|
||||||
std::vector<cmSourceFile*> classes;
|
std::vector<cmSourceFile*> classes;
|
||||||
if (!target.GetConfigCommonSourceFiles(classes))
|
if (!gt->GetConfigCommonSourceFiles(classes))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1514,8 +1517,6 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
|
|||||||
{
|
{
|
||||||
// VS >= 8 support per-config source locations so we
|
// VS >= 8 support per-config source locations so we
|
||||||
// list object library content as external objects.
|
// list object library content as external objects.
|
||||||
cmGeneratorTarget* gt =
|
|
||||||
this->GlobalGenerator->GetGeneratorTarget(&target);
|
|
||||||
std::vector<std::string> objs;
|
std::vector<std::string> objs;
|
||||||
gt->UseObjectLibraries(objs, "");
|
gt->UseObjectLibraries(objs, "");
|
||||||
if(!objs.empty())
|
if(!objs.empty())
|
||||||
|
@ -403,7 +403,9 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg,
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
std::vector<cmSourceFile*> srcFiles;
|
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();
|
for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
|
||||||
fileIt != srcFiles.end();
|
fileIt != srcFiles.end();
|
||||||
++fileIt)
|
++fileIt)
|
||||||
@ -661,7 +663,10 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target)
|
|||||||
const char* sepHeaders = "";
|
const char* sepHeaders = "";
|
||||||
|
|
||||||
std::vector<cmSourceFile*> srcFiles;
|
std::vector<cmSourceFile*> srcFiles;
|
||||||
target->GetConfigCommonSourceFiles(srcFiles);
|
cmGeneratorTarget *gtgt = target->GetMakefile()
|
||||||
|
->GetGlobalGenerator()
|
||||||
|
->GetGeneratorTarget(target);
|
||||||
|
gtgt->GetConfigCommonSourceFiles(srcFiles);
|
||||||
|
|
||||||
const char *skipMocSep = "";
|
const char *skipMocSep = "";
|
||||||
const char *skipUicSep = "";
|
const char *skipUicSep = "";
|
||||||
@ -1046,7 +1051,10 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
|
|||||||
cmMakefile *makefile = target->GetMakefile();
|
cmMakefile *makefile = target->GetMakefile();
|
||||||
|
|
||||||
std::vector<cmSourceFile*> srcFiles;
|
std::vector<cmSourceFile*> srcFiles;
|
||||||
target->GetConfigCommonSourceFiles(srcFiles);
|
cmGeneratorTarget *gtgt = target->GetMakefile()
|
||||||
|
->GetGlobalGenerator()
|
||||||
|
->GetGeneratorTarget(target);
|
||||||
|
gtgt->GetConfigCommonSourceFiles(srcFiles);
|
||||||
|
|
||||||
std::string qrcInputs;
|
std::string qrcInputs;
|
||||||
const char* qrcInputsSep = "";
|
const char* qrcInputsSep = "";
|
||||||
|
@ -724,62 +724,6 @@ void cmTarget::GetSourceFiles(std::vector<std::string> &files,
|
|||||||
cmDeleteAll(linkInterfaceSourcesEntries);
|
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,
|
void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files,
|
||||||
const std::string& config) const
|
const std::string& config) const
|
||||||
|
@ -137,8 +137,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
void GetSourceFiles(std::vector<cmSourceFile*> &files,
|
void GetSourceFiles(std::vector<cmSourceFile*> &files,
|
||||||
const std::string& config) const;
|
const std::string& config) const;
|
||||||
bool GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add sources to the target.
|
* Add sources to the target.
|
||||||
*/
|
*/
|
||||||
|
@ -965,7 +965,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
|
|||||||
std::vector<cmSourceGroup> sourceGroups =
|
std::vector<cmSourceGroup> sourceGroups =
|
||||||
this->Makefile->GetSourceGroups();
|
this->Makefile->GetSourceGroups();
|
||||||
std::vector<cmSourceFile*> classes;
|
std::vector<cmSourceFile*> classes;
|
||||||
if (!this->Target->GetConfigCommonSourceFiles(classes))
|
if (!this->GeneratorTarget->GetConfigCommonSourceFiles(classes))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user