mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-01 19:30:13 -06: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();
|
||||
if (!lang.empty()) {
|
||||
auto const it = this->LanguageToOutputExtension.find(lang);
|
||||
if (it != this->LanguageToOutputExtension.end()) {
|
||||
return it->second;
|
||||
}
|
||||
} else {
|
||||
// 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
|
||||
// and in this map, so it will not be compiled but will just be used.
|
||||
std::string const& ext = source.GetExtension();
|
||||
if (!ext.empty()) {
|
||||
if (this->OutputExtensions.count(ext)) {
|
||||
return ext;
|
||||
}
|
||||
return this->GetLanguageOutputExtension(lang);
|
||||
}
|
||||
// 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
|
||||
// and in this map, so it will not be compiled but will just be used.
|
||||
std::string const& ext = source.GetExtension();
|
||||
if (!ext.empty()) {
|
||||
if (this->OutputExtensions.count(ext)) {
|
||||
return ext;
|
||||
}
|
||||
}
|
||||
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
|
||||
{
|
||||
// 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;
|
||||
//! What is the object file extension for a given source file?
|
||||
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?
|
||||
virtual const char* GetCMakeCFGIntDir() const { return "."; }
|
||||
|
||||
Reference in New Issue
Block a user