diff options
author | Alexander Neundorf <neundorf@kde.org> | 2023-02-26 15:33:16 (GMT) |
---|---|---|
committer | Alexander Neundorf <neundorf@kde.org> | 2023-02-26 15:33:16 (GMT) |
commit | c351dcd967379644db65e62534e73f874b16b4a3 (patch) | |
tree | 386f78d556b168748a51be495b0d87f5c955ec15 /Source/cmGeneratorExpressionNode.cxx | |
parent | 064c3244da08acecb313d0076eecb4eba30f1932 (diff) | |
download | CMake-c351dcd967379644db65e62534e73f874b16b4a3.zip CMake-c351dcd967379644db65e62534e73f874b16b4a3.tar.gz CMake-c351dcd967379644db65e62534e73f874b16b4a3.tar.bz2 |
TARGET_RUNTIME_DLL_DIRS: add the new genex to cmGeneratorExpressionNode
This commit adds handling for a new genex TARGET_RUNTIME_DLL_DIRS to
cmGeneratorExpressionNode. It refactors the code for TARGET_RUNTIME_DLLS
a bit, so that both TARGET_RUNTIME_DLL_DIRS and TARGET_RUNTIME_DLLS
share the implementation to collect all dlls. The new genex
collects the dlls and in a final step puts all the directories
into the result variable (and makes sure there are no duplicates).
Diffstat (limited to 'Source/cmGeneratorExpressionNode.cxx')
-rw-r--r-- | Source/cmGeneratorExpressionNode.cxx | 56 |
1 files changed, 46 insertions, 10 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 5d761ac..44205b5 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -2337,15 +2337,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); @@ -2354,7 +2351,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 && @@ -2365,7 +2362,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)) { @@ -2378,13 +2375,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) @@ -3355,6 +3390,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 }, |