diff options
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 27 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.h | 4 |
2 files changed, 26 insertions, 5 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index b95c4889d2..0b379bdd16 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -121,6 +121,12 @@ void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags, } } +std::string +cmNinjaTargetGenerator::OrderDependsTargetForTarget() +{ + return "cmake_order_depends_target_" + this->GetTargetName(); +} + // TODO: Most of the code is picked up from // void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink), // void cmMakefileTargetGenerator::WriteTargetLanguageFlags() @@ -516,6 +522,19 @@ cmNinjaTargetGenerator { this->Objects.push_back(this->GetSourceFilePath(*si)); } + + cmNinjaDeps orderOnlyDeps; + this->GetLocalGenerator()->AppendTargetDepends(this->Target, orderOnlyDeps); + cmNinjaDeps orderOnlyTarget; + orderOnlyTarget.push_back(this->OrderDependsTargetForTarget()); + this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(), + "Order-only phony target for " + + this->GetTargetName(), + orderOnlyTarget, + cmNinjaDeps(), + cmNinjaDeps(), + orderOnlyDeps); + std::vector<cmSourceFile const*> objectSources; this->GeneratorTarget->GetObjectSources(objectSources, config); for(std::vector<cmSourceFile const*>::const_iterator @@ -554,11 +573,6 @@ cmNinjaTargetGenerator sourceFileName = this->GetSourceFilePath(source); explicitDeps.push_back(sourceFileName); - // Ensure that the target dependencies are built before any source file in - // the target, using order-only dependencies. - cmNinjaDeps orderOnlyDeps; - this->GetLocalGenerator()->AppendTargetDepends(this->Target, orderOnlyDeps); - cmNinjaDeps implicitDeps; if(const char* objectDeps = source->GetProperty("OBJECT_DEPENDS")) { std::vector<std::string> depList; @@ -567,6 +581,9 @@ cmNinjaTargetGenerator std::back_inserter(implicitDeps), MapToNinjaPath()); } + cmNinjaDeps orderOnlyDeps; + orderOnlyDeps.push_back(this->OrderDependsTargetForTarget()); + // Add order-only dependencies on custom command outputs. for(std::vector<cmCustomCommand const*>::const_iterator cci = this->CustomCommands.begin(); diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index be516e07a1..94c420fb8c 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -74,6 +74,10 @@ protected: bool GetFeatureAsBool(const std::string& feature); void AddFeatureFlags(std::string& flags, const std::string& lang); + std::string OrderDependsTargetForTarget(); + + std::string ComputeOrderDependsForTarget(); + /** * Compute the flags for compilation of object files for a given @a language. * @note Generally it is the value of the variable whose name is computed |