From 1de68b46f1650735bcc550626436f5286ccf36c2 Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Fri, 2 Mar 2007 14:31:04 -0500 Subject: [PATCH] BUG: fix for build order --- Source/cmMakefileUtilityTargetGenerator.cxx | 29 +++++++++++++++++++-- Source/cmMakefileUtilityTargetGenerator.h | 2 ++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx index 6ab18631f..60400239e 100644 --- a/Source/cmMakefileUtilityTargetGenerator.cxx +++ b/Source/cmMakefileUtilityTargetGenerator.cxx @@ -23,6 +23,12 @@ #include "cmSourceFile.h" #include "cmTarget.h" +//---------------------------------------------------------------------------- +cmMakefileUtilityTargetGenerator::cmMakefileUtilityTargetGenerator() +{ + this->DriveCustomCommandsOnDepends = true; +} + //---------------------------------------------------------------------------- void cmMakefileUtilityTargetGenerator::WriteRuleFiles() @@ -42,10 +48,30 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles() // Utility targets store their rules in pre- and post-build commands. this->LocalGenerator->AppendCustomDepends (depends, this->Target->GetPreBuildCommands()); + + // Build list of dependencies. + std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath(); + std::string objTarget; + this->LocalGenerator->AppendCustomDepends (depends, this->Target->GetPostBuildCommands()); + this->LocalGenerator->AppendCustomCommands (commands, this->Target->GetPreBuildCommands()); + + // Depend on all custom command outputs for sources + const std::vector& sources = + this->Target->GetSourceFiles(); + for(std::vector::const_iterator source = sources.begin(); + source != sources.end(); ++source) + { + if(cmCustomCommand* cc = (*source)->GetCustomCommand()) + { + this->LocalGenerator->AppendCustomCommand(commands, *cc); + this->LocalGenerator->AppendCustomDepend(depends, *cc); + } + } + this->LocalGenerator->AppendCustomCommands (commands, this->Target->GetPostBuildCommands()); @@ -53,8 +79,7 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles() this->AppendTargetDepends(depends); // Add a dependency on the rule file itself. - std::string relPath = this->LocalGenerator->GetHomeRelativeOutputPath(); - std::string objTarget = relPath; + objTarget = relPath; objTarget += this->BuildFileName; this->LocalGenerator->AppendRuleDepend(depends, objTarget.c_str()); diff --git a/Source/cmMakefileUtilityTargetGenerator.h b/Source/cmMakefileUtilityTargetGenerator.h index c8642a6c6..17572a89c 100644 --- a/Source/cmMakefileUtilityTargetGenerator.h +++ b/Source/cmMakefileUtilityTargetGenerator.h @@ -23,6 +23,8 @@ class cmMakefileUtilityTargetGenerator: public cmMakefileTargetGenerator { public: + cmMakefileUtilityTargetGenerator(); + /* the main entry point for this class. Writes the Makefiles associated with this target */ virtual void WriteRuleFiles();