summaryrefslogtreecommitdiffstats
path: root/Source/cmInstallFileSetGenerator.cxx
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2021-06-17 21:01:28 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2021-10-27 19:17:23 (GMT)
commit9b479124cc4be49a4b2c6e45e733b489f7a26432 (patch)
treec8ca0ce69ed5706d20cfc08a486507c58905233c /Source/cmInstallFileSetGenerator.cxx
parentd8af2d954f8619f0e8bc42252d310085dec94df4 (diff)
downloadCMake-9b479124cc4be49a4b2c6e45e733b489f7a26432.zip
CMake-9b479124cc4be49a4b2c6e45e733b489f7a26432.tar.gz
CMake-9b479124cc4be49a4b2c6e45e733b489f7a26432.tar.bz2
install(TARGETS): Add FILE_SET mode
Diffstat (limited to 'Source/cmInstallFileSetGenerator.cxx')
-rw-r--r--Source/cmInstallFileSetGenerator.cxx88
1 files changed, 88 insertions, 0 deletions
diff --git a/Source/cmInstallFileSetGenerator.cxx b/Source/cmInstallFileSetGenerator.cxx
new file mode 100644
index 0000000..7121ea3
--- /dev/null
+++ b/Source/cmInstallFileSetGenerator.cxx
@@ -0,0 +1,88 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmInstallFileSetGenerator.h"
+
+#include <map>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "cmFileSet.h"
+#include "cmGeneratorExpression.h"
+#include "cmGlobalGenerator.h"
+#include "cmInstallType.h"
+#include "cmLocalGenerator.h"
+#include "cmStringAlgorithms.h"
+
+cmInstallFileSetGenerator::cmInstallFileSetGenerator(
+ std::string targetName, cmFileSet* fileSet, std::string const& dest,
+ std::string file_permissions, std::vector<std::string> const& configurations,
+ std::string const& component, MessageLevel message, bool exclude_from_all,
+ bool optional, cmListFileBacktrace backtrace)
+ : cmInstallGenerator(dest, configurations, component, message,
+ exclude_from_all, false, std::move(backtrace))
+ , TargetName(std::move(targetName))
+ , FileSet(fileSet)
+ , FilePermissions(std::move(file_permissions))
+ , Optional(optional)
+{
+ this->ActionsPerConfig = true;
+}
+
+cmInstallFileSetGenerator::~cmInstallFileSetGenerator() = default;
+
+bool cmInstallFileSetGenerator::Compute(cmLocalGenerator* lg)
+{
+ this->LocalGenerator = lg;
+
+ // Lookup this target in the current directory.
+ this->Target = lg->FindLocalNonAliasGeneratorTarget(this->TargetName);
+ if (!this->Target) {
+ // If no local target has been found, find it in the global scope.
+ this->Target =
+ lg->GetGlobalGenerator()->FindGeneratorTarget(this->TargetName);
+ }
+
+ return true;
+}
+
+std::string cmInstallFileSetGenerator::GetDestination(
+ std::string const& config) const
+{
+ return cmGeneratorExpression::Evaluate(this->Destination,
+ this->LocalGenerator, config);
+}
+
+void cmInstallFileSetGenerator::GenerateScriptForConfig(
+ std::ostream& os, const std::string& config, Indent indent)
+{
+ for (auto const& dirEntry : this->CalculateFilesPerDir(config)) {
+ std::string destSub;
+ if (!dirEntry.first.empty()) {
+ destSub = cmStrCat('/', dirEntry.first);
+ }
+ this->AddInstallRule(os, cmStrCat(this->GetDestination(config), destSub),
+ cmInstallType_FILES, dirEntry.second,
+ this->GetOptional(), this->FilePermissions.c_str(),
+ nullptr, nullptr, nullptr, indent);
+ }
+}
+
+std::map<std::string, std::vector<std::string>>
+cmInstallFileSetGenerator::CalculateFilesPerDir(
+ const std::string& config) const
+{
+ std::map<std::string, std::vector<std::string>> result;
+
+ auto dirCges = this->FileSet->CompileDirectoryEntries();
+ auto dirs = this->FileSet->EvaluateDirectoryEntries(
+ dirCges, this->LocalGenerator, config, this->Target);
+
+ auto fileCges = this->FileSet->CompileFileEntries();
+ for (auto const& fileCge : fileCges) {
+ this->FileSet->EvaluateFileEntry(
+ dirs, result, fileCge, this->LocalGenerator, config, this->Target);
+ }
+
+ return result;
+}