summaryrefslogtreecommitdiffstats
path: root/Source/cmNinjaTargetGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-04-25 15:33:53 (GMT)
committerBrad King <brad.king@kitware.com>2018-04-26 12:40:57 (GMT)
commit625b8f9076080b3831ef7821812461b694ef5586 (patch)
treeece0e5a7e100f9f65e725097235e575f6e1990f2 /Source/cmNinjaTargetGenerator.cxx
parentae6722483e8e1b64cf05d5186c6240d724ad409e (diff)
downloadCMake-625b8f9076080b3831ef7821812461b694ef5586.zip
CMake-625b8f9076080b3831ef7821812461b694ef5586.tar.gz
CMake-625b8f9076080b3831ef7821812461b694ef5586.tar.bz2
Ninja: Avoid empty phony edges for target ordering
Since commit v3.9.0-rc1~230^2~2 (ninja: break unnecessary target dependencies, 2017-04-17) we unconditionally generate a phony edge for target ordering. It is needed in case a later target depends on it. However, if the phony edge has no inputs then `ninja -d explain` prints: ninja explain: output ... of phony edge with no inputs doesn't exist Furthermore the phony edge's output is considered dirty and can cause dependents to be incorrectly considered dirty. Avoid this by always generating at least one input to the target ordering phony edges. If we have no real dependencies just use a path that always exists. Fixes: #17942
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r--Source/cmNinjaTargetGenerator.cxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 4ce3cef..7dfce57 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -821,6 +821,19 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements()
orderOnlyDeps.erase(std::unique(orderOnlyDeps.begin(), orderOnlyDeps.end()),
orderOnlyDeps.end());
+ // The phony target must depend on at least one input or ninja will explain
+ // that "output ... of phony edge with no inputs doesn't exist" and consider
+ // the phony output "dirty".
+ if (orderOnlyDeps.empty()) {
+ // Any path that always exists will work here. It would be nice to
+ // use just "." but that is not supported by Ninja < 1.7.
+ std::string tgtDir;
+ tgtDir += this->LocalGenerator->GetCurrentBinaryDirectory();
+ tgtDir += "/";
+ tgtDir += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
+ orderOnlyDeps.push_back(this->ConvertToNinjaPath(tgtDir));
+ }
+
{
cmNinjaDeps orderOnlyTarget;
orderOnlyTarget.push_back(this->OrderDependsTargetForTarget());