浏览代码

cmGeneratorTarget: support config-independent Fortran source queries

Some locations care about "any config with Fortran", so make a query for
such (they may not know any configuration names themselves).
Ben Boeckel 2 年之前
父节点
当前提交
6251edaed1
共有 2 个文件被更改,包括 10 次插入0 次删除
  1. 9 0
      Source/cmGeneratorTarget.cxx
  2. 1 0
      Source/cmGeneratorTarget.h

+ 9 - 0
Source/cmGeneratorTarget.cxx

@@ -8873,6 +8873,15 @@ bool cmGeneratorTarget::HaveFortranSources(std::string const& config) const
                      });
 }
 
+bool cmGeneratorTarget::HaveFortranSources() const
+{
+  auto sources = cmGeneratorTarget::GetAllConfigSources();
+  return std::any_of(sources.begin(), sources.end(),
+                     [](AllConfigSource const& sf) -> bool {
+                       return sf.Source->GetLanguage() == "Fortran"_s;
+                     });
+}
+
 bool cmGeneratorTarget::HaveCxx20ModuleSources() const
 {
   auto const& fs_names = this->Target->GetAllFileSetNames();

+ 1 - 0
Source/cmGeneratorTarget.h

@@ -1247,6 +1247,7 @@ public:
                     cmGeneratorTarget const* t2) const;
   };
 
+  bool HaveFortranSources() const;
   bool HaveFortranSources(std::string const& config) const;
 
   // C++20 module support queries.