summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorEvan Wilde <etceterawilde@gmail.com>2023-11-18 23:51:13 (GMT)
committerBrad King <brad.king@kitware.com>2023-12-05 00:15:20 (GMT)
commit64b336784507f7b8c9117cf5367a6abfc78a8ba3 (patch)
treee9dd9c2be3f628f346c149941ac89d65ad3373b9 /Source
parentef89ad6c5562cca1911146834b6241e7c4c54653 (diff)
downloadCMake-64b336784507f7b8c9117cf5367a6abfc78a8ba3.zip
CMake-64b336784507f7b8c9117cf5367a6abfc78a8ba3.tar.gz
CMake-64b336784507f7b8c9117cf5367a6abfc78a8ba3.tar.bz2
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.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalGenerator.cxx32
-rw-r--r--Source/cmGlobalGenerator.h2
2 files changed, 21 insertions, 13 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index ca1afab..e74a8b0 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -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
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index aa54f69..d83b669 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -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 "."; }