1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-06-03 20:44:19 +08:00

Fortran: Fix submodule file names across compilers

The naming convention for submodule files varies across compilers.  Add
a table to the compiler information modules and thread the information
through to the Fortran module dependency parser.  Fill out the table for
compiler ids known to support Fortran submodules.

Fixes: #18746
This commit is contained in:
Brad King 2019-02-13 14:08:34 -05:00
parent 72057d9c15
commit d80ecba5c2
12 changed files with 45 additions and 1 deletions

View File

@ -1,6 +1,9 @@
include(Compiler/Clang)
__compiler_clang(Fortran)
set(CMAKE_Fortran_SUBMODULE_SEP "-")
set(CMAKE_Fortran_SUBMODULE_EXT ".mod")
set(CMAKE_Fortran_PREPROCESS_SOURCE
"<CMAKE_Fortran_COMPILER> -cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")

View File

@ -1,6 +1,9 @@
include(Compiler/GNU)
__compiler_gnu(Fortran)
set(CMAKE_Fortran_SUBMODULE_SEP "@")
set(CMAKE_Fortran_SUBMODULE_EXT ".smod")
set(CMAKE_Fortran_PREPROCESS_SOURCE
"<CMAKE_Fortran_COMPILER> -cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> -o <PREPROCESSED_SOURCE>")

View File

@ -1,6 +1,9 @@
include(Compiler/Intel)
__compiler_intel(Fortran)
set(CMAKE_Fortran_SUBMODULE_SEP "@")
set(CMAKE_Fortran_SUBMODULE_EXT ".smod")
set(CMAKE_Fortran_MODDIR_FLAG "-module ")
set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed")
set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free")

View File

@ -1,6 +1,9 @@
include(Compiler/PGI)
__compiler_pgi(Fortran)
set(CMAKE_Fortran_SUBMODULE_SEP "-")
set(CMAKE_Fortran_SUBMODULE_EXT ".mod")
set(CMAKE_Fortran_PREPROCESS_SOURCE
"<CMAKE_Fortran_COMPILER> -Mpreprocess <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")

View File

@ -1,6 +1,9 @@
include(Compiler/XL)
__compiler_xl(Fortran)
set(CMAKE_Fortran_SUBMODULE_SEP "_")
set(CMAKE_Fortran_SUBMODULE_EXT ".smod")
set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-qfixed") # [=<right_margin>]
set(CMAKE_Fortran_FORMAT_FREE_FLAG "-qfree") # [=f90|ibm]

View File

@ -96,6 +96,8 @@ cmDependsFortran::cmDependsFortran(cmLocalGenerator* lg)
}
this->CompilerId = mf->GetSafeDefinition("CMAKE_Fortran_COMPILER_ID");
this->SModSep = mf->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_SEP");
this->SModExt = mf->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_EXT");
}
cmDependsFortran::~cmDependsFortran()
@ -120,6 +122,8 @@ bool cmDependsFortran::WriteDependencies(const std::set<std::string>& sources,
cmFortranCompiler fc;
fc.Id = this->CompilerId;
fc.SModSep = this->SModSep;
fc.SModExt = this->SModExt;
bool okay = true;
for (std::string const& src : sources) {

View File

@ -78,6 +78,8 @@ protected:
std::string SourceFile;
std::string CompilerId;
std::string SModSep;
std::string SModExt;
std::set<std::string> PPDefinitions;

View File

@ -131,6 +131,8 @@ struct cmFortranFile
struct cmFortranCompiler
{
std::string Id;
std::string SModSep;
std::string SModExt;
};
struct cmFortranParser_s

View File

@ -79,7 +79,7 @@ std::string cmFortranParser_s::ModName(std::string const& mod_name) const
std::string cmFortranParser_s::SModName(std::string const& mod_name,
std::string const& sub_name) const
{
return mod_name + "@" + sub_name + ".smod";
return mod_name + this->Compiler.SModSep + sub_name + this->Compiler.SModExt;
}
bool cmFortranParser_FilePush(cmFortranParser* parser, const char* fname)

View File

@ -1704,6 +1704,12 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
Json::Value const& tdi_compiler_id = tdi["compiler-id"];
fc.Id = tdi_compiler_id.asString();
Json::Value const& tdi_submodule_sep = tdi["submodule-sep"];
fc.SModSep = tdi_submodule_sep.asString();
Json::Value const& tdi_submodule_ext = tdi["submodule-ext"];
fc.SModExt = tdi_submodule_ext.asString();
}
cmFortranSourceInfo info;

View File

@ -1808,6 +1808,17 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
<< "_COMPILER_ID \"" << cid << "\")\n";
}
if (implicitLang.first == "Fortran") {
std::string smodSep =
this->Makefile->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_SEP");
std::string smodExt =
this->Makefile->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_EXT");
cmakefileStream << "set(CMAKE_Fortran_SUBMODULE_SEP \"" << smodSep
<< "\")\n";
cmakefileStream << "set(CMAKE_Fortran_SUBMODULE_EXT \"" << smodExt
<< "\")\n";
}
// Build a list of preprocessor definitions for the target.
std::set<std::string> defines;
this->GetTargetDefines(target, this->ConfigName, implicitLang.first,

View File

@ -1144,6 +1144,10 @@ void cmNinjaTargetGenerator::WriteTargetDependInfo(std::string const& lang)
mod_dir = this->Makefile->GetCurrentBinaryDirectory();
}
tdi["module-dir"] = mod_dir;
tdi["submodule-sep"] =
this->Makefile->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_SEP");
tdi["submodule-ext"] =
this->Makefile->GetSafeDefinition("CMAKE_Fortran_SUBMODULE_EXT");
}
tdi["dir-cur-bld"] = this->Makefile->GetCurrentBinaryDirectory();