summaryrefslogtreecommitdiffstats
path: root/Source/cmExportBuildFileGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-04-21 15:49:25 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-04-21 15:49:40 (GMT)
commit49c96c65083c23f5dd25d8b0a0d8064d701a8ab2 (patch)
tree218882cd007932f52e89510c974beec309b6a499 /Source/cmExportBuildFileGenerator.cxx
parentcd22d5f4191d25b6cd242ceeab196c70c70b4a81 (diff)
parent9ee47188c0822932574ce48c31fea18a87165566 (diff)
downloadCMake-49c96c65083c23f5dd25d8b0a0d8064d701a8ab2.zip
CMake-49c96c65083c23f5dd25d8b0a0d8064d701a8ab2.tar.gz
CMake-49c96c65083c23f5dd25d8b0a0d8064d701a8ab2.tar.bz2
Merge topic 'file-set-build-export'
9ee47188c0 cmExportBuildFileGenerator: handle genex-wrapped source paths 60fab8a6e0 cmInstallCommand: tweak error message Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !7182
Diffstat (limited to 'Source/cmExportBuildFileGenerator.cxx')
-rw-r--r--Source/cmExportBuildFileGenerator.cxx93
1 files changed, 85 insertions, 8 deletions
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index a306fdd..6ce0c98 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExportBuildFileGenerator.h"
+#include <algorithm>
#include <map>
#include <memory>
#include <set>
@@ -15,7 +16,6 @@
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
-#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
@@ -357,16 +357,93 @@ std::string cmExportBuildFileGenerator::InstallNameDir(
return install_name_dir;
}
+namespace {
+bool EntryIsContextSensitive(
+ const std::unique_ptr<cmCompiledGeneratorExpression>& cge)
+{
+ return cge->GetHadContextSensitiveCondition();
+}
+}
+
std::string cmExportBuildFileGenerator::GetFileSetDirectories(
- cmGeneratorTarget* /*gte*/, cmFileSet* fileSet, cmTargetExport* /*te*/)
+ cmGeneratorTarget* gte, cmFileSet* fileSet, cmTargetExport* /*te*/)
{
- return cmOutputConverter::EscapeForCMake(
- cmJoin(fileSet->GetDirectoryEntries(), ";"));
+ std::vector<std::string> resultVector;
+
+ auto configs =
+ gte->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
+ auto directoryEntries = fileSet->CompileDirectoryEntries();
+
+ for (auto const& config : configs) {
+ auto directories = fileSet->EvaluateDirectoryEntries(
+ directoryEntries, gte->LocalGenerator, config, gte);
+
+ bool const contextSensitive =
+ std::any_of(directoryEntries.begin(), directoryEntries.end(),
+ EntryIsContextSensitive);
+
+ for (auto const& directory : directories) {
+ auto dest = cmOutputConverter::EscapeForCMake(
+ directory, cmOutputConverter::WrapQuotes::NoWrap);
+
+ if (contextSensitive && configs.size() != 1) {
+ resultVector.push_back(
+ cmStrCat("\"$<$<CONFIG:", config, ">:", dest, ">\""));
+ } else {
+ resultVector.push_back(cmStrCat('"', dest, '"'));
+ break;
+ }
+ }
+ }
+
+ return cmJoin(resultVector, " ");
}
-std::string cmExportBuildFileGenerator::GetFileSetFiles(
- cmGeneratorTarget* /*gte*/, cmFileSet* fileSet, cmTargetExport* /*te*/)
+std::string cmExportBuildFileGenerator::GetFileSetFiles(cmGeneratorTarget* gte,
+ cmFileSet* fileSet,
+ cmTargetExport* /*te*/)
{
- return cmOutputConverter::EscapeForCMake(
- cmJoin(fileSet->GetFileEntries(), ";"));
+ std::vector<std::string> resultVector;
+
+ auto configs =
+ gte->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
+
+ auto fileEntries = fileSet->CompileFileEntries();
+ auto directoryEntries = fileSet->CompileDirectoryEntries();
+
+ 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);
+ }
+
+ bool const contextSensitive =
+ std::any_of(directoryEntries.begin(), directoryEntries.end(),
+ EntryIsContextSensitive) ||
+ std::any_of(fileEntries.begin(), fileEntries.end(),
+ EntryIsContextSensitive);
+
+ for (auto const& it : files) {
+ for (auto const& filename : it.second) {
+ auto escapedFile = cmOutputConverter::EscapeForCMake(
+ filename, 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, " ");
}