diff options
author | Brad King <brad.king@kitware.com> | 2017-04-24 13:31:44 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2017-04-24 13:31:49 (GMT) |
commit | 305e628284fc647087cc8b1e1d7074f826358de6 (patch) | |
tree | cda9bc002f9fd84485940a60f1592422496fde71 /Source/cmNinjaTargetGenerator.cxx | |
parent | fa338c97d7e1cd320f79a6eed3b7913fd88ee890 (diff) | |
parent | d96e5d9a19d613de108ab399663f76a8dd964172 (diff) | |
download | CMake-305e628284fc647087cc8b1e1d7074f826358de6.zip CMake-305e628284fc647087cc8b1e1d7074f826358de6.tar.gz CMake-305e628284fc647087cc8b1e1d7074f826358de6.tar.bz2 |
Merge topic 'loosen-object-deps'
d96e5d9a Tests: use BYPRODUCTS in the CustomCommandWorkingDirectory test
664591ce RunCMake.Ninja: add a test for assumed sources
adf60b28 ninja: break unnecessary target dependencies
01c5bb95 RunCMake.Ninja: support passing arguments when running ninja
7f947b60 ninja: remove duplicate order-only dependencies
e9827eba ninja: describe the intermediate order depends target better
b57b7d8e Ninja: Order Fortran dyndep file generation explicitly
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !430
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 7c417a4..e0b2217 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -117,7 +117,7 @@ bool cmNinjaTargetGenerator::NeedDyndep(std::string const& lang) const std::string cmNinjaTargetGenerator::OrderDependsTargetForTarget() { - return "cmake_order_depends_target_" + this->GetTargetName(); + return "cmake_object_order_depends_target_" + this->GetTargetName(); } // TODO: Most of the code is picked up from @@ -718,8 +718,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() } cmNinjaDeps orderOnlyDeps; - this->GetLocalGenerator()->AppendTargetDepends(this->GeneratorTarget, - orderOnlyDeps); + this->GetLocalGenerator()->AppendTargetDepends( + this->GeneratorTarget, orderOnlyDeps, DependOnTargetOrdering); // Add order-only dependencies on other files associated with the target. orderOnlyDeps.insert(orderOnlyDeps.end(), this->ExtraFiles.begin(), @@ -740,7 +740,11 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() std::back_inserter(orderOnlyDeps), MapToNinjaPath()); } - if (!orderOnlyDeps.empty()) { + std::sort(orderOnlyDeps.begin(), orderOnlyDeps.end()); + orderOnlyDeps.erase(std::unique(orderOnlyDeps.begin(), orderOnlyDeps.end()), + orderOnlyDeps.end()); + + { cmNinjaDeps orderOnlyTarget; orderOnlyTarget.push_back(this->OrderDependsTargetForTarget()); this->GetGlobalGenerator()->WritePhonyBuild( @@ -753,7 +757,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() for (std::vector<cmSourceFile const*>::const_iterator si = objectSources.begin(); si != objectSources.end(); ++si) { - this->WriteObjectBuildStatement(*si, !orderOnlyDeps.empty()); + this->WriteObjectBuildStatement(*si); } if (!this->DDIFiles.empty()) { @@ -770,6 +774,17 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() ddOutputs.push_back(this->GetDyndepFilePath("Fortran")); + // Make sure dyndep files for all our dependencies have already + // been generated so that the 'FortranModules.json' files they + // produced as side-effects are available for us to read. + // Ideally we should depend on the 'FortranModules.json' files + // from our dependencies directly, but we don't know which of + // our dependencies produces them. Fixing this will require + // refactoring the Ninja generator to generate targets in + // dependency order so that we can collect the needed information. + this->GetLocalGenerator()->AppendTargetDepends( + this->GeneratorTarget, ddOrderOnlyDeps, DependOnTargetArtifact); + this->GetGlobalGenerator()->WriteBuild( this->GetBuildFileStream(), ddComment, ddRule, ddOutputs, ddImplicitOuts, ddExplicitDeps, ddImplicitDeps, ddOrderOnlyDeps, ddVars); @@ -779,7 +794,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements() } void cmNinjaTargetGenerator::WriteObjectBuildStatement( - cmSourceFile const* source, bool writeOrderDependsTargetForTarget) + cmSourceFile const* source) { std::string const language = source->GetLanguage(); std::string const sourceFileName = @@ -830,9 +845,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( } cmNinjaDeps orderOnlyDeps; - if (writeOrderDependsTargetForTarget) { - orderOnlyDeps.push_back(this->OrderDependsTargetForTarget()); - } + orderOnlyDeps.push_back(this->OrderDependsTargetForTarget()); // If the source file is GENERATED and does not have a custom command // (either attached to this source file or another one), assume that one of |