|
|
@@ -2,19 +2,23 @@
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
|
|
#include "cmExportInstallFileGenerator.h"
|
|
|
|
|
|
+#include <algorithm>
|
|
|
#include <memory>
|
|
|
#include <sstream>
|
|
|
#include <utility>
|
|
|
|
|
|
#include "cmExportSet.h"
|
|
|
+#include "cmFileSet.h"
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
#include "cmGeneratorExpression.h"
|
|
|
#include "cmGeneratorTarget.h"
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
#include "cmInstallExportGenerator.h"
|
|
|
+#include "cmInstallFileSetGenerator.h"
|
|
|
#include "cmInstallTargetGenerator.h"
|
|
|
#include "cmLocalGenerator.h"
|
|
|
#include "cmMakefile.h"
|
|
|
+#include "cmOutputConverter.h"
|
|
|
#include "cmPolicies.h"
|
|
|
#include "cmStateTypes.h"
|
|
|
#include "cmStringAlgorithms.h"
|
|
|
@@ -147,6 +151,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
|
|
|
this->PopulateCompatibleInterfaceProperties(gt, properties);
|
|
|
|
|
|
this->GenerateInterfaceProperties(gt, os, properties);
|
|
|
+
|
|
|
+ this->GenerateTargetFileSets(gt, os, te);
|
|
|
}
|
|
|
|
|
|
if (require3_1_0) {
|
|
|
@@ -534,3 +540,102 @@ std::string cmExportInstallFileGenerator::InstallNameDir(
|
|
|
|
|
|
return install_name_dir;
|
|
|
}
|
|
|
+
|
|
|
+namespace {
|
|
|
+bool EntryIsContextSensitive(
|
|
|
+ const std::unique_ptr<cmCompiledGeneratorExpression>& cge)
|
|
|
+{
|
|
|
+ return cge->GetHadContextSensitiveCondition();
|
|
|
+}
|
|
|
+}
|
|
|
+
|
|
|
+std::string cmExportInstallFileGenerator::GetFileSetDirectories(
|
|
|
+ cmGeneratorTarget* gte, cmFileSet* fileSet, cmTargetExport* te)
|
|
|
+{
|
|
|
+ std::vector<std::string> resultVector;
|
|
|
+
|
|
|
+ auto configs =
|
|
|
+ gte->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
|
|
|
+
|
|
|
+ cmGeneratorExpression ge;
|
|
|
+ auto cge = ge.Parse(te->FileSetGenerators.at(fileSet)->GetDestination());
|
|
|
+
|
|
|
+ for (auto const& config : configs) {
|
|
|
+ auto dest = cmStrCat("${_IMPORT_PREFIX}/",
|
|
|
+ cmOutputConverter::EscapeForCMake(
|
|
|
+ cge->Evaluate(gte->LocalGenerator, config, gte),
|
|
|
+ cmOutputConverter::WrapQuotes::NoWrap));
|
|
|
+
|
|
|
+ if (cge->GetHadContextSensitiveCondition() && configs.size() != 1) {
|
|
|
+ resultVector.push_back(
|
|
|
+ cmStrCat("\"$<$<CONFIG:", config, ">:", dest, ">\""));
|
|
|
+ } else {
|
|
|
+ resultVector.push_back(cmStrCat('"', dest, '"'));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return cmJoin(resultVector, " ");
|
|
|
+}
|
|
|
+
|
|
|
+std::string cmExportInstallFileGenerator::GetFileSetFiles(
|
|
|
+ cmGeneratorTarget* gte, cmFileSet* fileSet, cmTargetExport* te)
|
|
|
+{
|
|
|
+ std::vector<std::string> resultVector;
|
|
|
+
|
|
|
+ auto configs =
|
|
|
+ gte->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
|
|
|
+
|
|
|
+ auto fileEntries = fileSet->CompileFileEntries();
|
|
|
+ auto directoryEntries = fileSet->CompileDirectoryEntries();
|
|
|
+
|
|
|
+ cmGeneratorExpression destGe;
|
|
|
+ auto destCge =
|
|
|
+ destGe.Parse(te->FileSetGenerators.at(fileSet)->GetDestination());
|
|
|
+
|
|
|
+ for (auto const& config : configs) {
|
|
|
+ auto directories = fileSet->EvaluateDirectoryEntries(
|
|
|
+ directoryEntries, gte->LocalGenerator, config, gte);
|
|
|
+
|
|
|
+ std::map<std::string, std::vector<std::string>> files;
|
|
|
+ for (auto const& entry : fileEntries) {
|
|
|
+ fileSet->EvaluateFileEntry(directories, files, entry,
|
|
|
+ gte->LocalGenerator, config, gte);
|
|
|
+ }
|
|
|
+ auto dest = cmStrCat("${_IMPORT_PREFIX}/",
|
|
|
+ cmOutputConverter::EscapeForCMake(
|
|
|
+ destCge->Evaluate(gte->LocalGenerator, config, gte),
|
|
|
+ cmOutputConverter::WrapQuotes::NoWrap),
|
|
|
+ '/');
|
|
|
+
|
|
|
+ bool const contextSensitive = destCge->GetHadContextSensitiveCondition() ||
|
|
|
+ std::any_of(directoryEntries.begin(), directoryEntries.end(),
|
|
|
+ EntryIsContextSensitive) ||
|
|
|
+ std::any_of(fileEntries.begin(), fileEntries.end(),
|
|
|
+ EntryIsContextSensitive);
|
|
|
+
|
|
|
+ for (auto const& it : files) {
|
|
|
+ auto prefix = it.first.empty() ? "" : cmStrCat(it.first, '/');
|
|
|
+ for (auto const& filename : it.second) {
|
|
|
+ auto relFile =
|
|
|
+ cmStrCat(prefix, cmSystemTools::GetFilenameName(filename));
|
|
|
+ auto escapedFile =
|
|
|
+ cmStrCat(dest,
|
|
|
+ cmOutputConverter::EscapeForCMake(
|
|
|
+ relFile, cmOutputConverter::WrapQuotes::NoWrap));
|
|
|
+ if (contextSensitive && configs.size() != 1) {
|
|
|
+ resultVector.push_back(
|
|
|
+ cmStrCat("\"$<$<CONFIG:", config, ">:", escapedFile, ">\""));
|
|
|
+ } else {
|
|
|
+ resultVector.push_back(cmStrCat('"', escapedFile, '"'));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!(contextSensitive && configs.size() != 1)) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return cmJoin(resultVector, " ");
|
|
|
+}
|