summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2023-03-02 21:28:21 +0000
committerKitware Robot <kwrobot@kitware.com>2023-03-02 16:28:30 -0500
commitdef618f1ae36f07a2b9b3f2770d98f5de6de7244 (patch)
treebdb8745648e022ac41f274a3dd84c8f20fda9429 /Source
parent9f309e655fe87b8d2193c8e719a8748ad3e3c382 (diff)
parenta2c9c4f202d1bfb104ddebf5db11f7b74824337f (diff)
downloadcmake-def618f1ae36f07a2b9b3f2770d98f5de6de7244.tar.gz
Merge topic 'TargetRunTimeDllDirs'
a2c9c4f202 Add test for the new TARGET_RUNTIME_DLL_PATHS genex aa68de0a27 TARGET_RUNTIME_DLLS: minor refactoring of shared-check.cmake 2ce3d62ffb Help: add documentation for the new TARGET_RUNTIME_DLL_DIRS genex c351dcd967 TARGET_RUNTIME_DLL_DIRS: add the new genex to cmGeneratorExpressionNode 064c3244da TARGET_RUNTIME_DLLS: fix test for this genex Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Acked-by: Alex <leha-bot@yandex.ru> Merge-request: !8247
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorExpressionNode.cxx56
1 files changed, 46 insertions, 10 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 2a01c9e8d1..6e78f55776 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -2402,15 +2402,12 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
}
} targetObjectsNode;
-static const struct TargetRuntimeDllsNode : public cmGeneratorExpressionNode
+struct TargetRuntimeDllsBaseNode : public cmGeneratorExpressionNode
{
- TargetRuntimeDllsNode() {} // NOLINT(modernize-use-equals-default)
-
- std::string Evaluate(
+ std::vector<std::string> CollectDlls(
const std::vector<std::string>& parameters,
cmGeneratorExpressionContext* context,
- const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
+ const GeneratorExpressionContent* content) const
{
std::string const& tgtName = parameters.front();
cmGeneratorTarget* gt = context->LG->FindGeneratorTargetToUse(tgtName);
@@ -2419,7 +2416,7 @@ static const struct TargetRuntimeDllsNode : public cmGeneratorExpressionNode
e << "Objects of target \"" << tgtName
<< "\" referenced but no such target exists.";
reportError(context, content->GetOriginalExpression(), e.str());
- return std::string();
+ return std::vector<std::string>();
}
cmStateEnums::TargetType type = gt->GetType();
if (type != cmStateEnums::EXECUTABLE &&
@@ -2430,7 +2427,7 @@ static const struct TargetRuntimeDllsNode : public cmGeneratorExpressionNode
<< "\" referenced but is not one of the allowed target types "
<< "(EXECUTABLE, SHARED, MODULE).";
reportError(context, content->GetOriginalExpression(), e.str());
- return std::string();
+ return std::vector<std::string>();
}
if (auto* cli = gt->GetLinkInformation(context->Config)) {
@@ -2443,13 +2440,51 @@ static const struct TargetRuntimeDllsNode : public cmGeneratorExpressionNode
}
}
- return cmJoin(dllPaths, ";");
+ return dllPaths;
}
- return "";
+ return std::vector<std::string>();
+ }
+};
+
+static const struct TargetRuntimeDllsNode : public TargetRuntimeDllsBaseNode
+{
+ TargetRuntimeDllsNode() {} // NOLINT(modernize-use-equals-default)
+
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
+ {
+ std::vector<std::string> dlls = CollectDlls(parameters, context, content);
+ return cmJoin(dlls, ";");
}
} targetRuntimeDllsNode;
+static const struct TargetRuntimeDllDirsNode : public TargetRuntimeDllsBaseNode
+{
+ TargetRuntimeDllDirsNode() {} // NOLINT(modernize-use-equals-default)
+
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
+ {
+ std::vector<std::string> dlls = CollectDlls(parameters, context, content);
+ std::vector<std::string> dllDirs;
+ for (const std::string& dll : dlls) {
+ std::string directory = cmSystemTools::GetFilenamePath(dll);
+ if (std::find(dllDirs.begin(), dllDirs.end(), directory) ==
+ dllDirs.end()) {
+ dllDirs.push_back(directory);
+ }
+ }
+ return cmJoin(dllDirs, ";");
+ }
+} targetRuntimeDllDirsNode;
+
static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
{
CompileFeaturesNode() {} // NOLINT(modernize-use-equals-default)
@@ -3774,6 +3809,7 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode(
{ "TARGET_NAME_IF_EXISTS", &targetNameIfExistsNode },
{ "TARGET_GENEX_EVAL", &targetGenexEvalNode },
{ "TARGET_RUNTIME_DLLS", &targetRuntimeDllsNode },
+ { "TARGET_RUNTIME_DLL_DIRS", &targetRuntimeDllDirsNode },
{ "GENEX_EVAL", &genexEvalNode },
{ "BUILD_INTERFACE", &buildInterfaceNode },
{ "INSTALL_INTERFACE", &installInterfaceNode },