cmGeneratorTarget: Move GetLanguages from cmTarget.
This commit is contained in:
parent
0431f2c4d7
commit
69329fff70
|
@ -4415,6 +4415,57 @@ cmGeneratorTarget::GetLinkImplementation(const std::string& config) const
|
||||||
return &impl;
|
return &impl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmGeneratorTarget::GetLanguages(std::set<std::string>& languages,
|
||||||
|
const std::string& config) const
|
||||||
|
{
|
||||||
|
std::vector<cmSourceFile*> sourceFiles;
|
||||||
|
this->Target->GetSourceFiles(sourceFiles, config);
|
||||||
|
for(std::vector<cmSourceFile*>::const_iterator
|
||||||
|
i = sourceFiles.begin(); i != sourceFiles.end(); ++i)
|
||||||
|
{
|
||||||
|
const std::string& lang = (*i)->GetLanguage();
|
||||||
|
if(!lang.empty())
|
||||||
|
{
|
||||||
|
languages.insert(lang);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<cmGeneratorTarget*> objectLibraries;
|
||||||
|
std::vector<cmSourceFile const*> externalObjects;
|
||||||
|
if (!this->Makefile->IsConfigured())
|
||||||
|
{
|
||||||
|
std::vector<cmTarget*> objectTargets;
|
||||||
|
this->Target->GetObjectLibrariesCMP0026(objectTargets);
|
||||||
|
objectLibraries.reserve(objectTargets.size());
|
||||||
|
for (std::vector<cmTarget*>::const_iterator it = objectTargets.begin();
|
||||||
|
it != objectTargets.end(); ++it)
|
||||||
|
{
|
||||||
|
objectLibraries.push_back(this->GlobalGenerator
|
||||||
|
->GetGeneratorTarget(*it));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->GetExternalObjects(externalObjects, config);
|
||||||
|
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(this->GlobalGenerator
|
||||||
|
->GetGeneratorTarget(tgt));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(std::vector<cmGeneratorTarget*>::const_iterator
|
||||||
|
i = objectLibraries.begin(); i != objectLibraries.end(); ++i)
|
||||||
|
{
|
||||||
|
(*i)->GetLanguages(languages, config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmGeneratorTarget::ComputeLinkImplementationLanguages(
|
void cmGeneratorTarget::ComputeLinkImplementationLanguages(
|
||||||
const std::string& config,
|
const std::string& config,
|
||||||
|
@ -4423,7 +4474,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLanguages(
|
||||||
// This target needs runtime libraries for its source languages.
|
// This target needs runtime libraries for its source languages.
|
||||||
std::set<std::string> languages;
|
std::set<std::string> languages;
|
||||||
// Get languages used in our source files.
|
// Get languages used in our source files.
|
||||||
this->Target->GetLanguages(languages, config);
|
this->GetLanguages(languages, config);
|
||||||
// Copy the set of langauges to the link implementation.
|
// Copy the set of langauges to the link implementation.
|
||||||
impl.Languages.insert(impl.Languages.begin(),
|
impl.Languages.insert(impl.Languages.begin(),
|
||||||
languages.begin(), languages.end());
|
languages.begin(), languages.end());
|
||||||
|
|
|
@ -205,6 +205,14 @@ public:
|
||||||
cmOptionalLinkImplementation& impl
|
cmOptionalLinkImplementation& impl
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
// Compute the set of languages compiled by the target. This is
|
||||||
|
// computed every time it is called because the languages can change
|
||||||
|
// when source file properties are changed and we do not have enough
|
||||||
|
// information to forward these property changes to the targets
|
||||||
|
// until we have per-target object file properties.
|
||||||
|
void GetLanguages(std::set<std::string>& languages,
|
||||||
|
std::string const& config) 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
|
||||||
|
|
|
@ -1134,7 +1134,8 @@ bool cmGlobalUnixMakefileGenerator3
|
||||||
::NeedRequiresStep(cmTarget const& target)
|
::NeedRequiresStep(cmTarget const& target)
|
||||||
{
|
{
|
||||||
std::set<std::string> languages;
|
std::set<std::string> languages;
|
||||||
target.GetLanguages(languages,
|
cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&target);
|
||||||
|
gtgt->GetLanguages(languages,
|
||||||
target.GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
|
target.GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
|
||||||
for(std::set<std::string>::const_iterator l = languages.begin();
|
for(std::set<std::string>::const_iterator l = languages.begin();
|
||||||
l != languages.end(); ++l)
|
l != languages.end(); ++l)
|
||||||
|
|
|
@ -836,6 +836,8 @@ void RegisterVisualStudioMacros(const std::string& macrosFile,
|
||||||
bool
|
bool
|
||||||
cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target)
|
cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target)
|
||||||
{
|
{
|
||||||
|
cmGeneratorTarget* gt = this->GetGeneratorTarget(&target);
|
||||||
|
|
||||||
// check to see if this is a fortran build
|
// check to see if this is a fortran build
|
||||||
std::set<std::string> languages;
|
std::set<std::string> languages;
|
||||||
{
|
{
|
||||||
|
@ -846,7 +848,7 @@ cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
target.GetLanguages(languages, "");
|
gt->GetLanguages(languages, "");
|
||||||
if(languages.size() == 1)
|
if(languages.size() == 1)
|
||||||
{
|
{
|
||||||
if(*languages.begin() == "Fortran")
|
if(*languages.begin() == "Fortran")
|
||||||
|
|
|
@ -1805,7 +1805,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
|
||||||
|
|
||||||
// Compute the compilation flags for each language.
|
// Compute the compilation flags for each language.
|
||||||
std::set<std::string> languages;
|
std::set<std::string> languages;
|
||||||
target.GetLanguages(languages, configName);
|
cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target);
|
||||||
|
gtgt->GetLanguages(languages, configName);
|
||||||
std::map<std::string, std::string> cflags;
|
std::map<std::string, std::string> cflags;
|
||||||
for (std::set<std::string>::iterator li = languages.begin();
|
for (std::set<std::string>::iterator li = languages.begin();
|
||||||
li != languages.end(); ++li)
|
li != languages.end(); ++li)
|
||||||
|
@ -1827,7 +1828,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
|
||||||
AddCompileOptions(flags, &target, lang, configName);
|
AddCompileOptions(flags, &target, lang, configName);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target);
|
|
||||||
std::string llang = gtgt->GetLinkerLanguage(configName);
|
std::string llang = gtgt->GetLinkerLanguage(configName);
|
||||||
if(binary && llang.empty())
|
if(binary && llang.empty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -1257,7 +1257,9 @@ cmLocalUnixMakefileGenerator3
|
||||||
{
|
{
|
||||||
// Get the set of source languages in the target.
|
// Get the set of source languages in the target.
|
||||||
std::set<std::string> languages;
|
std::set<std::string> languages;
|
||||||
target.GetLanguages(languages,
|
cmGeneratorTarget *gtgt =
|
||||||
|
this->GlobalGenerator->GetGeneratorTarget(&target);
|
||||||
|
gtgt->GetLanguages(languages,
|
||||||
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
|
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
|
||||||
fout << "\n"
|
fout << "\n"
|
||||||
<< "# Per-language clean rules from dependency scanning.\n"
|
<< "# Per-language clean rules from dependency scanning.\n"
|
||||||
|
|
|
@ -276,7 +276,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
|
||||||
{
|
{
|
||||||
// write language flags for target
|
// write language flags for target
|
||||||
std::set<std::string> languages;
|
std::set<std::string> languages;
|
||||||
this->Target->GetLanguages(languages,
|
this->GeneratorTarget->GetLanguages(languages,
|
||||||
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
|
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
|
||||||
// put the compiler in the rules.make file so that if it changes
|
// put the compiler in the rules.make file so that if it changes
|
||||||
// things rebuild
|
// things rebuild
|
||||||
|
|
|
@ -3130,50 +3130,6 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmTarget::GetLanguages(std::set<std::string>& languages,
|
|
||||||
const std::string& config) const
|
|
||||||
{
|
|
||||||
std::vector<cmSourceFile*> sourceFiles;
|
|
||||||
this->GetSourceFiles(sourceFiles, config);
|
|
||||||
for(std::vector<cmSourceFile*>::const_iterator
|
|
||||||
i = sourceFiles.begin(); i != sourceFiles.end(); ++i)
|
|
||||||
{
|
|
||||||
const std::string& lang = (*i)->GetLanguage();
|
|
||||||
if(!lang.empty())
|
|
||||||
{
|
|
||||||
languages.insert(lang);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<cmTarget*> objectLibraries;
|
|
||||||
std::vector<cmSourceFile const*> externalObjects;
|
|
||||||
if (!this->Makefile->IsConfigured())
|
|
||||||
{
|
|
||||||
this->GetObjectLibrariesCMP0026(objectLibraries);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cmGeneratorTarget* gt = this->Makefile->GetGlobalGenerator()
|
|
||||||
->GetGeneratorTarget(this);
|
|
||||||
gt->GetExternalObjects(externalObjects, config);
|
|
||||||
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, config);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmTarget::ImportInfo const*
|
cmTarget::ImportInfo const*
|
||||||
cmTarget::GetImportInfo(const std::string& config) const
|
cmTarget::GetImportInfo(const std::string& config) const
|
||||||
|
|
|
@ -305,14 +305,6 @@ public:
|
||||||
If no macro should be defined null is returned. */
|
If no macro should be defined null is returned. */
|
||||||
const char* GetExportMacro() const;
|
const char* GetExportMacro() const;
|
||||||
|
|
||||||
// Compute the set of languages compiled by the target. This is
|
|
||||||
// computed every time it is called because the languages can change
|
|
||||||
// when source file properties are changed and we do not have enough
|
|
||||||
// information to forward these property changes to the targets
|
|
||||||
// until we have per-target object file properties.
|
|
||||||
void GetLanguages(std::set<std::string>& languages,
|
|
||||||
std::string const& config) const;
|
|
||||||
|
|
||||||
/** Return whether this target is an executable with symbol exports
|
/** Return whether this target is an executable with symbol exports
|
||||||
enabled. */
|
enabled. */
|
||||||
bool IsExecutableWithExports() const;
|
bool IsExecutableWithExports() const;
|
||||||
|
|
Loading…
Reference in New Issue