summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalNinjaGenerator.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-05-19 14:21:11 (GMT)
committerBrad King <brad.king@kitware.com>2021-05-19 17:28:14 (GMT)
commit2725ecff38ccd25905a9bc968bfb1b2f0d09b34a (patch)
tree94dd74aa6b00b3bdddf90e64eace0d6aff7078e5 /Source/cmGlobalNinjaGenerator.h
parentbc40cd7a4e107be68debb01760700850d4c1106c (diff)
downloadCMake-2725ecff38ccd25905a9bc968bfb1b2f0d09b34a.zip
CMake-2725ecff38ccd25905a9bc968bfb1b2f0d09b34a.tar.gz
CMake-2725ecff38ccd25905a9bc968bfb1b2f0d09b34a.tar.bz2
Ninja: Handle depfiles with absolute paths to generated files
Ninja treats every (normalized) path as its own node. It does not recognize `/abs/path/to/file` in a depfile as matching `path/to/file` even when `build.ninja` and the working directory are in `/abs/`. See Ninja Issue 1251. In cases where we pass absolute paths to the compiler, it will write a depfile containing absolute paths. If those files are generated in the build tree by custom commands, `build.ninja` references them by relative path in build statement outputs, so Ninja does not hook up the dependency and rebuild the project correctly. Add infrastructure to work around this problem by adding implicit outputs to custom command build statements that reference the main outputs by absolute path. Use a `${cmake_ninja_workdir}` placeholder to avoid repeating the base path. For example: build out.txt | ${cmake_ninja_workdir}out.txt: CUSTOM_COMMAND ... Ninja will create two nodes for the output file, one with a relative path and one with an absolute path. A depfile may then mention either form of the path and Ninja will hook up the dependency. Unfortunately Ninja will also stat the file twice. Issue: #13894 Fixes: #21865
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.h')
-rw-r--r--Source/cmGlobalNinjaGenerator.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 2833367..7a3674e 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -121,6 +121,7 @@ public:
}
void Add(std::vector<std::string> const& outputs);
cmNinjaDeps ExplicitOuts;
+ cmNinjaDeps WorkDirOuts;
};
void WriteCustomCommandBuild(std::string const& command,