Fortran: Thread compiler id through to internal Fortran parser

This commit is contained in:
Brad King
2019-02-13 13:34:56 -05:00
parent 7ae329e2ed
commit 72057d9c15
5 changed files with 26 additions and 5 deletions

View File

@@ -94,6 +94,8 @@ cmDependsFortran::cmDependsFortran(cmLocalGenerator* lg)
}
this->PPDefinitions.insert(def);
}
this->CompilerId = mf->GetSafeDefinition("CMAKE_Fortran_COMPILER_ID");
}
cmDependsFortran::~cmDependsFortran()
@@ -116,6 +118,9 @@ bool cmDependsFortran::WriteDependencies(const std::set<std::string>& sources,
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 @@ bool cmDependsFortran::WriteDependencies(const std::set<std::string>& sources,
// 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());

View File

@@ -77,6 +77,8 @@ protected:
// The source file from which to start scanning.
std::string SourceFile;
std::string CompilerId;
std::set<std::string> PPDefinitions;
// Internal implementation details.

View File

@@ -128,9 +128,14 @@ struct cmFortranFile
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 @@ struct cmFortranParser_s
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;

View File

@@ -43,10 +43,12 @@ bool cmFortranParser_s::FindIncludeFile(const char* dir,
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)
{

View File

@@ -1679,6 +1679,7 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
return 1;
}
cmFortranCompiler fc;
std::vector<std::string> includes;
{
Json::Value tdio;
@@ -1700,11 +1701,14 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
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());