ENH: Added cmTarget::GetLanguages method to centralize computation of the list of languages compiled in a target.
This commit is contained in:
parent
dac7814841
commit
9f2de08f90
@ -234,14 +234,12 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
|
|||||||
void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
|
void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
|
||||||
{
|
{
|
||||||
// write language flags for target
|
// write language flags for target
|
||||||
std::map<cmStdString,cmLocalUnixMakefileGenerator3::IntegrityCheckSet>&
|
std::set<cmStdString> languages;
|
||||||
checkSet =
|
this->Target->GetLanguages(languages);
|
||||||
this->LocalGenerator->GetIntegrityCheckSet()[this->Target->GetName()];
|
for(std::set<cmStdString>::const_iterator l = languages.begin();
|
||||||
for(std::map<cmStdString,
|
l != languages.end(); ++l)
|
||||||
cmLocalUnixMakefileGenerator3::IntegrityCheckSet>::const_iterator
|
|
||||||
l = checkSet.begin(); l != checkSet.end(); ++l)
|
|
||||||
{
|
{
|
||||||
const char *lang = l->first.c_str();
|
const char *lang = l->c_str();
|
||||||
std::string flags;
|
std::string flags;
|
||||||
bool shared = ((this->Target->GetType() == cmTarget::SHARED_LIBRARY) ||
|
bool shared = ((this->Target->GetType() == cmTarget::SHARED_LIBRARY) ||
|
||||||
(this->Target->GetType() == cmTarget::MODULE_LIBRARY));
|
(this->Target->GetType() == cmTarget::MODULE_LIBRARY));
|
||||||
|
@ -1488,14 +1488,7 @@ const char* cmTarget::GetLinkerLanguage(cmGlobalGenerator* gg)
|
|||||||
// if the property has not yet been set, collect all languages in the
|
// if the property has not yet been set, collect all languages in the
|
||||||
// target and then find the language with the highest preference value
|
// target and then find the language with the highest preference value
|
||||||
std::set<cmStdString> languages;
|
std::set<cmStdString> languages;
|
||||||
for(std::vector<cmSourceFile*>::const_iterator
|
this->GetLanguages(languages);
|
||||||
i = this->SourceFiles.begin(); i != this->SourceFiles.end(); ++i)
|
|
||||||
{
|
|
||||||
if(const char* lang = (*i)->GetLanguage())
|
|
||||||
{
|
|
||||||
languages.insert(lang);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string linkerLangList; // only used for the error message
|
std::string linkerLangList; // only used for the error message
|
||||||
int maxLinkerPref = 0;
|
int maxLinkerPref = 0;
|
||||||
@ -2369,3 +2362,16 @@ const char* cmTarget::GetExportMacro()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmTarget::GetLanguages(std::set<cmStdString>& languages) const
|
||||||
|
{
|
||||||
|
for(std::vector<cmSourceFile*>::const_iterator
|
||||||
|
i = this->SourceFiles.begin(); i != this->SourceFiles.end(); ++i)
|
||||||
|
{
|
||||||
|
if(const char* lang = (*i)->GetLanguage())
|
||||||
|
{
|
||||||
|
languages.insert(lang);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -61,7 +61,7 @@ public:
|
|||||||
|
|
||||||
///! Set the cmMakefile that owns this target
|
///! Set the cmMakefile that owns this target
|
||||||
void SetMakefile(cmMakefile *mf);
|
void SetMakefile(cmMakefile *mf);
|
||||||
cmMakefile *GetMakefile() { return this->Makefile;};
|
cmMakefile *GetMakefile() const { return this->Makefile;};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of the custom commands for this target
|
* Get the list of the custom commands for this target
|
||||||
@ -264,6 +264,13 @@ public:
|
|||||||
If no macro should be defined null is returned. */
|
If no macro should be defined null is returned. */
|
||||||
const char* GetExportMacro();
|
const char* GetExportMacro();
|
||||||
|
|
||||||
|
// 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<cmStdString>& languages) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* A list of direct dependencies. Use in conjunction with DependencyMap.
|
* A list of direct dependencies. Use in conjunction with DependencyMap.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user