summaryrefslogtreecommitdiffstats
path: root/Source/cmNinjaTargetGenerator.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/cmNinjaTargetGenerator.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/cmNinjaTargetGenerator.cxx')
-rw-r--r--Source/cmNinjaTargetGenerator.cxx15
1 files changed, 12 insertions, 3 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index f035c1e..5bf6a2b 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -545,7 +545,7 @@ std::string GetScanCommand(cm::string_view cmakeCmd, cm::string_view tdi,
cm::string_view ddiFile)
{
return cmStrCat(cmakeCmd, " -E cmake_ninja_depends --tdi=", tdi,
- " --lang=", lang, " --src=", srcFile,
+ " --lang=", lang, " --src=", srcFile, " --out=$out",
" --dep=$DEP_FILE --obj=$OBJ_FILE --ddi=", ddiFile);
}
@@ -1258,6 +1258,7 @@ namespace {
cmNinjaBuild GetScanBuildStatement(const std::string& ruleName,
const std::string& ppFileName,
bool compilePP, bool compilePPWithDefines,
+ bool compilationPreprocesses,
cmNinjaBuild& objBuild, cmNinjaVars& vars,
const std::string& objectFileName,
cmLocalGenerator* lg)
@@ -1314,6 +1315,13 @@ cmNinjaBuild GetScanBuildStatement(const std::string& ruleName,
} else {
scanBuild.Outputs.push_back(ddiFile);
scanBuild.Variables["PREPROCESSED_OUTPUT_FILE"] = ppFileName;
+ if (!compilationPreprocesses) {
+ // Compilation does not preprocess and we are not compiling an
+ // already-preprocessed source. Make compilation depend on the scan
+ // results to honor implicit dependencies discovered during scanning
+ // (such as Fortran INCLUDE directives).
+ objBuild.ImplicitDeps.emplace_back(ddiFile);
+ }
}
// Scanning always provides a depfile for preprocessor dependencies. This
@@ -1520,8 +1528,9 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
}
cmNinjaBuild ppBuild = GetScanBuildStatement(
- scanRuleName, ppFileName, compilePP, compilePPWithDefines, objBuild,
- vars, objectFileName, this->LocalGenerator);
+ scanRuleName, ppFileName, compilePP, compilePPWithDefines,
+ compilationPreprocesses, objBuild, vars, objectFileName,
+ this->LocalGenerator);
if (compilePP) {
// In case compilation requires flags that are incompatible with