diff options
author | Brad King <brad.king@kitware.com> | 2018-04-19 13:21:58 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-04-20 14:57:31 (GMT) |
commit | 402735314ec7fe48ec21e5f4c5b19b6f17682c54 (patch) | |
tree | 6ad7b1ccfa99d27779cabaa23095bded497a6cfd /Source/cmFortranParserImpl.cxx | |
parent | 62538b2c4c70eeef52886092e24c97a9a7699a00 (diff) | |
download | CMake-402735314ec7fe48ec21e5f4c5b19b6f17682c54.zip CMake-402735314ec7fe48ec21e5f4c5b19b6f17682c54.tar.gz CMake-402735314ec7fe48ec21e5f4c5b19b6f17682c54.tar.bz2 |
Fortran: Add support for submodule dependencies
Since commit v3.7.0-rc1~73^2~1 (Fortran: Add support for submodule
syntax in dependency scanning, 2016-09-05) we support parsing Fortran
sources that use submodule syntax, but it left addition of `.smod`
dependencies to future work. Add it now.
The syntax
submodule (module_name) submodule_name
means the current source requires `module_name.mod` and provides
`module_name@submodule_name.smod`. The syntax
submodule (module_name:submodule_name) nested_submodule_name
means the current source requires `module_name@submodule_name.smod`
provides `module_name@nested_submodule_name.smod`.
Fixes: #17017
Diffstat (limited to 'Source/cmFortranParserImpl.cxx')
-rw-r--r-- | Source/cmFortranParserImpl.cxx | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx index e4a6ac7..01cbb78 100644 --- a/Source/cmFortranParserImpl.cxx +++ b/Source/cmFortranParserImpl.cxx @@ -245,6 +245,50 @@ void cmFortranParser_RuleModule(cmFortranParser* parser, } } +void cmFortranParser_RuleSubmodule(cmFortranParser* parser, + const char* module_name, + const char* submodule_name) +{ + if (parser->InPPFalseBranch) { + return; + } + + // syntax: "submodule (module_name) submodule_name" + // requires: "module_name.mod" + // provides: "module_name@submodule_name.smod" + // + // FIXME: Some compilers split the submodule part of a module into a + // separate "module_name.smod" file. Whether it is generated or + // not depends on conditions more subtle than we currently detect. + // For now we depend directly on "module_name.mod". + + std::string const& mod_name = cmSystemTools::LowerCase(module_name); + std::string const& sub_name = cmSystemTools::LowerCase(submodule_name); + parser->Info.Requires.insert(mod_name + ".mod"); + parser->Info.Provides.insert(mod_name + "@" + sub_name + ".smod"); +} + +void cmFortranParser_RuleSubmoduleNested(cmFortranParser* parser, + const char* module_name, + const char* submodule_name, + const char* nested_submodule_name) +{ + if (parser->InPPFalseBranch) { + return; + } + + // syntax: "submodule (module_name:submodule_name) nested_submodule_name" + // requires: "module_name@submodule_name.smod" + // provides: "module_name@nested_submodule_name.smod" + + std::string const& mod_name = cmSystemTools::LowerCase(module_name); + std::string const& sub_name = cmSystemTools::LowerCase(submodule_name); + std::string const& nest_name = + cmSystemTools::LowerCase(nested_submodule_name); + parser->Info.Requires.insert(mod_name + "@" + sub_name + ".smod"); + parser->Info.Provides.insert(mod_name + "@" + nest_name + ".smod"); +} + void cmFortranParser_RuleDefine(cmFortranParser* parser, const char* macro) { if (!parser->InPPFalseBranch) { |