Browse Source

cmInstallScriptGenerator: Factor out method to get script

Brad King 4 years ago
parent
commit
1215092507
2 changed files with 18 additions and 7 deletions
  1. 14 7
      Source/cmInstallScriptGenerator.cxx
  2. 4 0
      Source/cmInstallScriptGenerator.h

+ 14 - 7
Source/cmInstallScriptGenerator.cxx

@@ -53,6 +53,19 @@ bool cmInstallScriptGenerator::Compute(cmLocalGenerator* lg)
   return true;
 }
 
+std::string cmInstallScriptGenerator::GetScript(
+  std::string const& config) const
+{
+  std::string script;
+  if (this->AllowGenex && this->ActionsPerConfig) {
+    script = cmGeneratorExpression::Evaluate(this->Script,
+                                             this->LocalGenerator, config);
+  } else {
+    script = this->Script;
+  }
+  return script;
+}
+
 void cmInstallScriptGenerator::AddScriptInstallRule(
   std::ostream& os, Indent indent, std::string const& script) const
 {
@@ -76,11 +89,5 @@ void cmInstallScriptGenerator::GenerateScriptActions(std::ostream& os,
 void cmInstallScriptGenerator::GenerateScriptForConfig(
   std::ostream& os, const std::string& config, Indent indent)
 {
-  if (this->AllowGenex) {
-    this->AddScriptInstallRule(os, indent,
-                               cmGeneratorExpression::Evaluate(
-                                 this->Script, this->LocalGenerator, config));
-  } else {
-    this->AddScriptInstallRule(os, indent, this->Script);
-  }
+  this->AddScriptInstallRule(os, indent, this->GetScript(config));
 }

+ 4 - 0
Source/cmInstallScriptGenerator.h

@@ -25,6 +25,10 @@ public:
 
   bool Compute(cmLocalGenerator* lg) override;
 
+  bool IsCode() const { return this->Code; }
+
+  std::string GetScript(std::string const& config) const;
+
 protected:
   void GenerateScriptActions(std::ostream& os, Indent indent) override;
   void GenerateScriptForConfig(std::ostream& os, const std::string& config,