diff options
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 15 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.h | 3 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 14 |
3 files changed, 22 insertions, 10 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 545f9e8..b06cdb4 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2092,6 +2092,21 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget( } //---------------------------------------------------------------------------- +std::string +cmGlobalGenerator::GenerateRuleFile(std::string const& output) const +{ + std::string ruleFile = output; + ruleFile += ".rule"; + const char* dir = this->GetCMakeCFGIntDir(); + if(dir && dir[0] == '$') + { + cmSystemTools::ReplaceString(ruleFile, dir, + cmake::GetCMakeFilesDirectory()); + } + return ruleFile; +} + +//---------------------------------------------------------------------------- void cmGlobalGenerator::AppendDirectoryForConfig(const char*, const char*, const char*, std::string&) { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 80b948b..5254b89 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -277,6 +277,9 @@ public: i.e. "Can I build Debug and Release in the same tree?" */ virtual bool IsMultiConfig() { return false; } + /** Generate an <output>.rule file path for a given command output. */ + virtual std::string GenerateRuleFile(std::string const& output) const; + protected: typedef std::vector<cmLocalGenerator*> GeneratorVector; // for a project collect all its targets by following depend diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f2865f6..17bb5ed 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -948,17 +948,11 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs, // Generate a rule file if the main dependency is not available. if(!file) { + cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator(); + // Construct a rule file associated with the first output produced. - std::string outName = outputs[0]; - outName += ".rule"; - const char* dir = - this->LocalGenerator->GetGlobalGenerator()-> - GetCMakeCFGIntDir(); - if(dir && dir[0] == '$') - { - cmSystemTools::ReplaceString(outName, dir, - cmake::GetCMakeFilesDirectory()); - } + std::string outName = gg->GenerateRuleFile(outputs[0]); + // Check if the rule file already exists. file = this->GetSource(outName.c_str()); if(file && file->GetCustomCommand() && !replace) |