summaryrefslogtreecommitdiffstats
path: root/Source/cmExportBuildFileGenerator.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2022-04-15 19:45:54 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2022-04-18 17:43:18 (GMT)
commit9ee47188c0822932574ce48c31fea18a87165566 (patch)
tree04ee3c198f2e4a72a33a54fb5f0bcb83a2fe3616 /Source/cmExportBuildFileGenerator.cxx
parent60fab8a6e08a014bc66b2347b4d1037ad52164c7 (diff)
downloadCMake-9ee47188c0822932574ce48c31fea18a87165566.zip
CMake-9ee47188c0822932574ce48c31fea18a87165566.tar.gz
CMake-9ee47188c0822932574ce48c31fea18a87165566.tar.bz2
cmExportBuildFileGenerator: handle genex-wrapped source paths
Previously a fileset with `$<$<CONFIG:Debug>:some_file>` would show up as-is (with escaping) in the build directory export. Instead, evaluate all fileset entries as generator expressions and list them as they are similar to the installation information.
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 a47f1e5..2773b3b 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"
@@ -362,16 +362,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, " ");
}