Browse Source

cmInstallDirectoryGenerator: Factor out method to get list of directories

Brad King 4 years ago
parent
commit
2452cfdeab
2 changed files with 20 additions and 5 deletions
  1. 17 5
      Source/cmInstallDirectoryGenerator.cxx
  2. 3 0
      Source/cmInstallDirectoryGenerator.h

+ 17 - 5
Source/cmInstallDirectoryGenerator.cxx

@@ -50,6 +50,22 @@ bool cmInstallDirectoryGenerator::Compute(cmLocalGenerator* lg)
   return true;
   return true;
 }
 }
 
 
+std::vector<std::string> cmInstallDirectoryGenerator::GetDirectories(
+  std::string const& config) const
+{
+  std::vector<std::string> directories;
+  if (this->ActionsPerConfig) {
+    for (std::string const& f : this->Directories) {
+      cmExpandList(
+        cmGeneratorExpression::Evaluate(f, this->LocalGenerator, config),
+        directories);
+    }
+  } else {
+    directories = this->Directories;
+  }
+  return directories;
+}
+
 void cmInstallDirectoryGenerator::GenerateScriptActions(std::ostream& os,
 void cmInstallDirectoryGenerator::GenerateScriptActions(std::ostream& os,
                                                         Indent indent)
                                                         Indent indent)
 {
 {
@@ -63,11 +79,7 @@ void cmInstallDirectoryGenerator::GenerateScriptActions(std::ostream& os,
 void cmInstallDirectoryGenerator::GenerateScriptForConfig(
 void cmInstallDirectoryGenerator::GenerateScriptForConfig(
   std::ostream& os, const std::string& config, Indent indent)
   std::ostream& os, const std::string& config, Indent indent)
 {
 {
-  std::vector<std::string> dirs;
-  for (std::string const& d : this->Directories) {
-    cmExpandList(
-      cmGeneratorExpression::Evaluate(d, this->LocalGenerator, config), dirs);
-  }
+  std::vector<std::string> dirs = this->GetDirectories(config);
 
 
   // Make sure all dirs have absolute paths.
   // Make sure all dirs have absolute paths.
   cmMakefile const& mf = *this->LocalGenerator->GetMakefile();
   cmMakefile const& mf = *this->LocalGenerator->GetMakefile();

+ 3 - 0
Source/cmInstallDirectoryGenerator.h

@@ -32,6 +32,9 @@ public:
   bool Compute(cmLocalGenerator* lg) override;
   bool Compute(cmLocalGenerator* lg) override;
 
 
   std::string GetDestination(std::string const& config) const;
   std::string GetDestination(std::string const& config) const;
+  std::vector<std::string> GetDirectories(std::string const& config) const;
+
+  bool GetOptional() const { return this->Optional; }
 
 
 protected:
 protected:
   void GenerateScriptActions(std::ostream& os, Indent indent) override;
   void GenerateScriptActions(std::ostream& os, Indent indent) override;