mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-05 13:50:10 -05:00
cmGlobalGenerator: Allow passing language to GetLangaugeOutputExtension
The original GetLanguageOutputExtension took a sourcefile instead of the name of the language itself. This implementation provided a convenient handler for when the SourceFile doesn't know what language it is, but there are times where we know the language, but don't necessarily have a source file. Adding an overload that takes the name of the language and returns the extension of that language, or empty string if no extension is registered.
This commit is contained in:
@@ -1158,24 +1158,30 @@ std::string cmGlobalGenerator::GetLanguageOutputExtension(
|
|||||||
{
|
{
|
||||||
const std::string& lang = source.GetLanguage();
|
const std::string& lang = source.GetLanguage();
|
||||||
if (!lang.empty()) {
|
if (!lang.empty()) {
|
||||||
auto const it = this->LanguageToOutputExtension.find(lang);
|
return this->GetLanguageOutputExtension(lang);
|
||||||
if (it != this->LanguageToOutputExtension.end()) {
|
}
|
||||||
return it->second;
|
// if no language is found then check to see if it is already an
|
||||||
}
|
// output extension for some language. In that case it should be ignored
|
||||||
} else {
|
// and in this map, so it will not be compiled but will just be used.
|
||||||
// if no language is found then check to see if it is already an
|
std::string const& ext = source.GetExtension();
|
||||||
// output extension for some language. In that case it should be ignored
|
if (!ext.empty()) {
|
||||||
// and in this map, so it will not be compiled but will just be used.
|
if (this->OutputExtensions.count(ext)) {
|
||||||
std::string const& ext = source.GetExtension();
|
return ext;
|
||||||
if (!ext.empty()) {
|
|
||||||
if (this->OutputExtensions.count(ext)) {
|
|
||||||
return ext;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string cmGlobalGenerator::GetLanguageOutputExtension(
|
||||||
|
std::string const& lang) const
|
||||||
|
{
|
||||||
|
auto const it = this->LanguageToOutputExtension.find(lang);
|
||||||
|
if (it != this->LanguageToOutputExtension.end()) {
|
||||||
|
return it->second;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
std::string cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const
|
std::string cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const
|
||||||
{
|
{
|
||||||
// if there is an extension and it starts with . then move past the
|
// if there is an extension and it starts with . then move past the
|
||||||
|
|||||||
@@ -349,6 +349,8 @@ public:
|
|||||||
int GetLinkerPreference(const std::string& lang) const;
|
int GetLinkerPreference(const std::string& lang) const;
|
||||||
//! What is the object file extension for a given source file?
|
//! What is the object file extension for a given source file?
|
||||||
std::string GetLanguageOutputExtension(cmSourceFile const&) const;
|
std::string GetLanguageOutputExtension(cmSourceFile const&) const;
|
||||||
|
//! What is the object file extension for a given language?
|
||||||
|
std::string GetLanguageOutputExtension(std::string const& lang) const;
|
||||||
|
|
||||||
//! What is the configurations directory variable called?
|
//! What is the configurations directory variable called?
|
||||||
virtual const char* GetCMakeCFGIntDir() const { return "."; }
|
virtual const char* GetCMakeCFGIntDir() const { return "."; }
|
||||||
|
|||||||
Reference in New Issue
Block a user