From f7611f167cef7d5d517e901984f5f6c72aa61cf9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 14 Dec 2006 14:30:41 -0500 Subject: [PATCH] ENH: Made cmMakefileTargetGenerator::GlobalGenerator have full type cmGlobalUnixMakefileGenerator3 to give access to all methods. Fixed broken custom targets with no commands for Borland makefiles when CMAKE_SKIP_RULE_DEPENDENCY is set. --- Source/cmGlobalUnixMakefileGenerator3.h | 3 +++ Source/cmMakefileExecutableTargetGenerator.cxx | 2 +- Source/cmMakefileLibraryTargetGenerator.cxx | 2 +- Source/cmMakefileTargetGenerator.cxx | 10 +++++----- Source/cmMakefileTargetGenerator.h | 4 ++-- Source/cmMakefileUtilityTargetGenerator.cxx | 13 ++++++++++++- 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index f07451073..7bf675cff 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -115,6 +115,9 @@ public: no rule. This is used for multiple output dependencies. */ std::string GetEmptyCommandHack() { return this->EmptyCommandsHack; } + /** Get the fake dependency to use when a rule has no real commands + or dependencies. */ + std::string GetEmptyRuleHackDepends() { return this->EmptyRuleHackDepends; } // change the build command for speed virtual std::string GenerateBuildCommand diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 4b24a19ab..4be22295e 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -17,7 +17,7 @@ #include "cmMakefileExecutableTargetGenerator.h" #include "cmGeneratedFileStream.h" -#include "cmGlobalGenerator.h" +#include "cmGlobalUnixMakefileGenerator3.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" #include "cmSourceFile.h" diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index d80fc7e34..291b90a38 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -17,7 +17,7 @@ #include "cmMakefileLibraryTargetGenerator.h" #include "cmGeneratedFileStream.h" -#include "cmGlobalGenerator.h" +#include "cmGlobalUnixMakefileGenerator3.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" #include "cmSourceFile.h" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 1adff5ca7..e941f5879 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -65,7 +65,8 @@ cmMakefileTargetGenerator::New(cmLocalUnixMakefileGenerator3 *lg, result->TargetName = tgtName; result->Target = tgt; result->LocalGenerator = lg; - result->GlobalGenerator = lg->GetGlobalGenerator(); + result->GlobalGenerator = + static_cast(lg->GetGlobalGenerator()); result->Makefile = lg->GetMakefile(); return result; } @@ -891,9 +892,7 @@ void cmMakefileTargetGenerator depends.clear(); depends.push_back(*o); commands.clear(); - cmGlobalUnixMakefileGenerator3* gg = - static_cast(this->GlobalGenerator); - std::string emptyCommand = gg->GetEmptyCommandHack(); + std::string emptyCommand = this->GlobalGenerator->GetEmptyCommandHack(); if(!emptyCommand.empty()) { commands.push_back(emptyCommand); @@ -911,7 +910,8 @@ void cmMakefileTargetGenerator this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, o->c_str(), depends, commands, symbolic); - gg->AddMultipleOutputPair(o->c_str(), depends[0].c_str()); + this->GlobalGenerator->AddMultipleOutputPair(o->c_str(), + depends[0].c_str()); } } diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index dd6bbe62f..fb6562be9 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -23,7 +23,7 @@ class cmCustomCommand; class cmDependInformation; class cmDepends; class cmGeneratedFileStream; -class cmGlobalGenerator; +class cmGlobalUnixMakefileGenerator3; class cmLocalUnixMakefileGenerator3; class cmMakeDepend; class cmMakefile; @@ -121,7 +121,7 @@ protected: cmStdString TargetName; cmTarget *Target; cmLocalUnixMakefileGenerator3 *LocalGenerator; - cmGlobalGenerator *GlobalGenerator; + cmGlobalUnixMakefileGenerator3 *GlobalGenerator; cmMakefile *Makefile; bool DriveCustomCommandsOnDepends; diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx index 51a848fee..6ab18631f 100644 --- a/Source/cmMakefileUtilityTargetGenerator.cxx +++ b/Source/cmMakefileUtilityTargetGenerator.cxx @@ -17,7 +17,7 @@ #include "cmMakefileUtilityTargetGenerator.h" #include "cmGeneratedFileStream.h" -#include "cmGlobalGenerator.h" +#include "cmGlobalUnixMakefileGenerator3.h" #include "cmLocalUnixMakefileGenerator3.h" #include "cmMakefile.h" #include "cmSourceFile.h" @@ -58,6 +58,17 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles() objTarget += this->BuildFileName; this->LocalGenerator->AppendRuleDepend(depends, objTarget.c_str()); + // If the rule is empty add the special empty rule dependency needed + // by some make tools. + if(depends.empty() && commands.empty()) + { + std::string hack = this->GlobalGenerator->GetEmptyRuleHackDepends(); + if(!hack.empty()) + { + depends.push_back(hack); + } + } + // Write the rule. this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0, this->Target->GetName(),