summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalNinjaGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-06-14 20:25:02 (GMT)
committerBrad King <brad.king@kitware.com>2021-06-15 13:11:06 (GMT)
commita35d1212760707b195f6c462aadae8383ffcdeca (patch)
treed8486131dfa10b96e565645a68481efc6e634707 /Source/cmGlobalNinjaGenerator.cxx
parent10b2e5346984d95c15d0cc38ddf5c5fad11a6a65 (diff)
downloadCMake-a35d1212760707b195f6c462aadae8383ffcdeca.zip
CMake-a35d1212760707b195f6c462aadae8383ffcdeca.tar.gz
CMake-a35d1212760707b195f6c462aadae8383ffcdeca.tar.bz2
Ninja: Populate P1689R4 compiled-module-path field for Fortran
When scanning Fortran dependencies, we know the file path at which a provided module file is written. Store it in the `compiled-module-path` field as specified by P1689R4. Our collator in `cmake_ninja_dyndep` no longer needs to assume that the module file path can be derived from the logical module name. In the future, the Fortran dependency scanning may be done by the compiler itself, in which case it will provide the value of `compiled-module-path`.
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx21
1 files changed, 21 insertions, 0 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 5108a6f..963118f 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -6,6 +6,7 @@
#include <cctype>
#include <cstdio>
#include <sstream>
+#include <utility>
#include <cm/iterator>
#include <cm/memory>
@@ -2400,6 +2401,8 @@ cm::optional<cmSourceInfo> cmcmd_cmake_ninja_depends_fortran(
cm::optional<cmSourceInfo> info;
cmFortranCompiler fc;
std::vector<std::string> includes;
+ std::string dir_top_bld;
+ std::string module_dir;
{
Json::Value tdio;
Json::Value const& tdi = tdio;
@@ -2414,6 +2417,11 @@ cm::optional<cmSourceInfo> cmcmd_cmake_ninja_depends_fortran(
}
}
+ dir_top_bld = tdi["dir-top-bld"].asString();
+ if (!dir_top_bld.empty() && !cmHasLiteralSuffix(dir_top_bld, "/")) {
+ dir_top_bld += '/';
+ }
+
Json::Value const& tdi_include_dirs = tdi["include-dirs"];
if (tdi_include_dirs.isArray()) {
for (auto const& tdi_include_dir : tdi_include_dirs) {
@@ -2421,6 +2429,12 @@ cm::optional<cmSourceInfo> cmcmd_cmake_ninja_depends_fortran(
}
}
+ Json::Value const& tdi_module_dir = tdi["module-dir"];
+ module_dir = tdi_module_dir.asString();
+ if (!module_dir.empty() && !cmHasLiteralSuffix(module_dir, "/")) {
+ module_dir += '/';
+ }
+
Json::Value const& tdi_compiler_id = tdi["compiler-id"];
fc.Id = tdi_compiler_id.asString();
@@ -2448,6 +2462,13 @@ cm::optional<cmSourceInfo> cmcmd_cmake_ninja_depends_fortran(
for (std::string const& provide : finfo.Provides) {
cmSourceReqInfo src_info;
src_info.LogicalName = provide;
+ if (!module_dir.empty()) {
+ std::string mod = cmStrCat(module_dir, provide);
+ if (!dir_top_bld.empty() && cmHasPrefix(mod, dir_top_bld)) {
+ mod = mod.substr(dir_top_bld.size());
+ }
+ src_info.CompiledModulePath = std::move(mod);
+ }
info->ScanDep.Provides.emplace_back(src_info);
}
for (std::string const& require : finfo.Requires) {