summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalNinjaGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-05-08 21:04:46 (GMT)
committerBrad King <brad.king@kitware.com>2023-05-09 13:56:42 (GMT)
commit1f1894af1fb263762c062c55fce28b5f9678dc5e (patch)
tree5c02c55f2849221450d3c4ff1c4e14814c7a3475 /Source/cmGlobalNinjaGenerator.cxx
parent9075ebda60922d8d11dd15d15c714c36ec3874cd (diff)
downloadCMake-1f1894af1fb263762c062c55fce28b5f9678dc5e.zip
CMake-1f1894af1fb263762c062c55fce28b5f9678dc5e.tar.gz
CMake-1f1894af1fb263762c062c55fce28b5f9678dc5e.tar.bz2
Ninja: Fix Fortran INCLUDE directive dependencies when not preprocessing
Since commit b0a6161190 (Fortran: Add Fortran_PREPROCESS property, 2020-04-24, v3.18.0-rc1~116^2~3), if `Fortran_PREPROCESS` is `OFF`, the Ninja generator does not properly detect dependencies on sources loaded via the Fortran INCLUDE directive. Fix this and add a test.
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx14
1 files changed, 11 insertions, 3 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index f3927b4..7626fa3 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -2227,7 +2227,7 @@ Compilation of source files within a target is split into the following steps:
command = gfortran -cpp $DEFINES $INCLUDES $FLAGS -E $in -o $out &&
cmake -E cmake_ninja_depends \
--tdi=FortranDependInfo.json --lang=Fortran \
- --src=$out --dep=$DEP_FILE --obj=$OBJ_FILE \
+ --src=$out --out=$out --dep=$DEP_FILE --obj=$OBJ_FILE \
--ddi=$DYNDEP_INTERMEDIATE_FILE
build src.f90-pp.f90 | src.f90.o.ddi: Fortran_PREPROCESS src.f90
@@ -2304,6 +2304,7 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
{
std::string arg_tdi;
std::string arg_src;
+ std::string arg_out;
std::string arg_dep;
std::string arg_obj;
std::string arg_ddi;
@@ -2313,6 +2314,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, "--out=")) {
+ arg_out = arg.substr(6);
} else if (cmHasLiteralPrefix(arg, "--dep=")) {
arg_dep = arg.substr(6);
} else if (cmHasLiteralPrefix(arg, "--obj=")) {
@@ -2322,8 +2325,9 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
} else if (cmHasLiteralPrefix(arg, "--lang=")) {
arg_lang = arg.substr(7);
} else if (cmHasLiteralPrefix(arg, "--pp=")) {
- // CMake 3.26 and below used '--pp=' instead of '--src='.
+ // CMake 3.26 and below used '--pp=' instead of '--src=' and '--out='.
arg_src = arg.substr(5);
+ arg_out = arg_src;
} else {
cmSystemTools::Error(
cmStrCat("-E cmake_ninja_depends unknown argument: ", arg));
@@ -2338,6 +2342,10 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
cmSystemTools::Error("-E cmake_ninja_depends requires value for --src=");
return 1;
}
+ if (arg_out.empty()) {
+ cmSystemTools::Error("-E cmake_ninja_depends requires value for --out=");
+ return 1;
+ }
if (arg_dep.empty()) {
cmSystemTools::Error("-E cmake_ninja_depends requires value for --dep=");
return 1;
@@ -2374,7 +2382,7 @@ int cmcmd_cmake_ninja_depends(std::vector<std::string>::const_iterator argBeg,
{
cmGeneratedFileStream depfile(arg_dep);
- depfile << cmSystemTools::ConvertToUnixOutputPath(arg_src) << ":";
+ depfile << cmSystemTools::ConvertToUnixOutputPath(arg_out) << ":";
for (std::string const& include : info->Includes) {
depfile << " \\\n " << cmSystemTools::ConvertToUnixOutputPath(include);
}