summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalNinjaGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-03-20 13:55:35 (GMT)
committerKitware Robot <kwrobot@kitware.com>2024-03-20 13:55:48 (GMT)
commitd704a3f8189ce737ab5dd38ab3c87a0eebb7a7b6 (patch)
treec72572e8fef94e46c7fb912ef7d88fc2b4636340 /Source/cmGlobalNinjaGenerator.cxx
parent94edef24714325eb25d7ba3a4f1479673c1bfbff (diff)
parent36dc8d6d50e0724d6f4bcebdada5610db8dbd698 (diff)
downloadCMake-d704a3f8189ce737ab5dd38ab3c87a0eebb7a7b6.zip
CMake-d704a3f8189ce737ab5dd38ab3c87a0eebb7a7b6.tar.gz
CMake-d704a3f8189ce737ab5dd38ab3c87a0eebb7a7b6.tar.bz2
Merge topic 'ninja-fortran-include'
36dc8d6d50 Ninja: Fix Fortran module deps in files INCLUDEd by preprocessed sources Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !9351
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx21
1 files changed, 18 insertions, 3 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index f018a8c..612af4f 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -2350,7 +2350,8 @@ struct cmSourceInfo
};
cm::optional<cmSourceInfo> cmcmd_cmake_ninja_depends_fortran(
- std::string const& arg_tdi, std::string const& arg_src);
+ std::string const& arg_tdi, std::string const& arg_src,
+ std::string const& arg_src_orig);
}
int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
@@ -2358,6 +2359,7 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
{
std::string arg_tdi;
std::string arg_src;
+ std::string arg_src_orig;
std::string arg_out;
std::string arg_dep;
std::string arg_obj;
@@ -2368,6 +2370,8 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
arg_tdi = arg.substr(6);
} else if (cmHasLiteralPrefix(arg, "--src=")) {
arg_src = arg.substr(6);
+ } else if (cmHasLiteralPrefix(arg, "--src-orig=")) {
+ arg_src_orig = arg.substr(11);
} else if (cmHasLiteralPrefix(arg, "--out=")) {
arg_out = arg.substr(6);
} else if (cmHasLiteralPrefix(arg, "--dep=")) {
@@ -2419,7 +2423,7 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
cm::optional<cmSourceInfo> info;
if (arg_lang == "Fortran") {
- info = cmcmd_cmake_ninja_depends_fortran(arg_tdi, arg_src);
+ info = cmcmd_cmake_ninja_depends_fortran(arg_tdi, arg_src, arg_src_orig);
} else {
cmSystemTools::Error(
cmStrCat("-E cmake_ninja_depends does not understand the ", arg_lang,
@@ -2454,13 +2458,24 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
namespace {
cm::optional<cmSourceInfo> cmcmd_cmake_ninja_depends_fortran(
- std::string const& arg_tdi, std::string const& arg_src)
+ std::string const& arg_tdi, std::string const& arg_src,
+ std::string const& arg_src_orig)
{
cm::optional<cmSourceInfo> info;
cmFortranCompiler fc;
std::vector<std::string> includes;
std::string dir_top_bld;
std::string module_dir;
+
+ if (!arg_src_orig.empty()) {
+ // Prepend the original source file's directory as an include directory
+ // so Fortran INCLUDE statements can look for files in it.
+ std::string src_orig_dir = cmSystemTools::GetParentDirectory(arg_src_orig);
+ if (!src_orig_dir.empty()) {
+ includes.push_back(src_orig_dir);
+ }
+ }
+
{
Json::Value tdio;
Json::Value const& tdi = tdio;