Fortran: Thread compiler id through to internal Fortran parser
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx
index cae3ff6..fe69d14 100644
--- a/Source/cmDependsFortran.cxx
+++ b/Source/cmDependsFortran.cxx
@@ -94,6 +94,8 @@
     }
     this->PPDefinitions.insert(def);
   }
+
+  this->CompilerId = mf->GetSafeDefinition("CMAKE_Fortran_COMPILER_ID");
 }
 
 cmDependsFortran::~cmDependsFortran()
@@ -116,6 +118,9 @@
     return false;
   }
 
+  cmFortranCompiler fc;
+  fc.Id = this->CompilerId;
+
   bool okay = true;
   for (std::string const& src : sources) {
     // Get the information object for this source.
@@ -123,7 +128,7 @@
 
     // Create the parser object. The constructor takes info by reference,
     // so we may look into the resulting objects later.
-    cmFortranParser parser(this->IncludePath, this->PPDefinitions, info);
+    cmFortranParser parser(fc, this->IncludePath, this->PPDefinitions, info);
 
     // Push on the starting file.
     cmFortranParser_FilePush(&parser, src.c_str());
diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h
index bf09904..f2d9cf2 100644
--- a/Source/cmDependsFortran.h
+++ b/Source/cmDependsFortran.h
@@ -77,6 +77,8 @@
   // The source file from which to start scanning.
   std::string SourceFile;
 
+  std::string CompilerId;
+
   std::set<std::string> PPDefinitions;
 
   // Internal implementation details.
diff --git a/Source/cmFortranParser.h b/Source/cmFortranParser.h
index cc5c113..3fbf552 100644
--- a/Source/cmFortranParser.h
+++ b/Source/cmFortranParser.h
@@ -128,9 +128,14 @@
   bool LastCharWasNewline;
 };
 
+struct cmFortranCompiler
+{
+  std::string Id;
+};
+
 struct cmFortranParser_s
 {
-  cmFortranParser_s(std::vector<std::string> includes,
+  cmFortranParser_s(cmFortranCompiler fc, std::vector<std::string> includes,
                     std::set<std::string> defines, cmFortranSourceInfo& info);
   ~cmFortranParser_s();
 
@@ -141,6 +146,9 @@
   std::string SModName(std::string const& mod_name,
                        std::string const& sub_name) const;
 
+  // What compiler.
+  cmFortranCompiler Compiler;
+
   // The include file search path.
   std::vector<std::string> IncludePath;
 
diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx
index 7b0c1a9..8787206 100644
--- a/Source/cmFortranParserImpl.cxx
+++ b/Source/cmFortranParserImpl.cxx
@@ -43,10 +43,12 @@
   return false;
 }
 
-cmFortranParser_s::cmFortranParser_s(std::vector<std::string> includes,
+cmFortranParser_s::cmFortranParser_s(cmFortranCompiler fc,
+                                     std::vector<std::string> includes,
                                      std::set<std::string> defines,
                                      cmFortranSourceInfo& info)
-  : IncludePath(std::move(includes))
+  : Compiler(std::move(fc))
+  , IncludePath(std::move(includes))
   , PPDefinitions(std::move(defines))
   , Info(info)
 {
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 6498024..f5262f0 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -1679,6 +1679,7 @@
     return 1;
   }
 
+  cmFortranCompiler fc;
   std::vector<std::string> includes;
   {
     Json::Value tdio;
@@ -1700,11 +1701,14 @@
         includes.push_back(tdi_include_dir.asString());
       }
     }
+
+    Json::Value const& tdi_compiler_id = tdi["compiler-id"];
+    fc.Id = tdi_compiler_id.asString();
   }
 
   cmFortranSourceInfo info;
   std::set<std::string> defines;
-  cmFortranParser parser(includes, defines, info);
+  cmFortranParser parser(fc, includes, defines, info);
   if (!cmFortranParser_FilePush(&parser, arg_pp.c_str())) {
     cmSystemTools::Error("-E cmake_ninja_depends failed to open ",
                          arg_pp.c_str());