diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2019-04-04 16:27:29 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-04-08 11:48:20 (GMT) |
commit | 26b6d2aff0076b44fac605de0d3dbfc3f55e64fb (patch) | |
tree | addfb8e09b95cb4f6cf86ff1f5f3bc7880488bf3 /Source | |
parent | 7a5adae94dc8ca38fb2323742c6e4164682a876f (diff) | |
download | CMake-26b6d2aff0076b44fac605de0d3dbfc3f55e64fb.zip CMake-26b6d2aff0076b44fac605de0d3dbfc3f55e64fb.tar.gz CMake-26b6d2aff0076b44fac605de0d3dbfc3f55e64fb.tar.bz2 |
Refactor struct TargetFileSystemArtifact
Creates base class TargetArtifactBase which enable to share code with
future new functionalities.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorExpressionNode.cxx | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 19d2b3a..481ea9e 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -2023,18 +2023,16 @@ struct TargetFilesystemArtifactResultGetter<ArtifactPathTag> static std::string Get(const std::string& result) { return result; } }; -template <typename ArtifactT, typename ComponentT> -struct TargetFilesystemArtifact : public cmGeneratorExpressionNode +struct TargetArtifactBase : public cmGeneratorExpressionNode { - TargetFilesystemArtifact() {} // NOLINT(modernize-use-equals-default) - - int NumExpectedParameters() const override { return 1; } + TargetArtifactBase() {} // NOLINT(modernize-use-equals-default) - std::string Evaluate( +protected: + cmGeneratorTarget* GetTarget( const std::vector<std::string>& parameters, cmGeneratorExpressionContext* context, const GeneratorExpressionContent* content, - cmGeneratorExpressionDAGChecker* dagChecker) const override + cmGeneratorExpressionDAGChecker* dagChecker) const { // Lookup the referenced target. std::string name = parameters.front(); @@ -2042,20 +2040,20 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode if (!cmGeneratorExpression::IsValidTargetName(name)) { ::reportError(context, content->GetOriginalExpression(), "Expression syntax not recognized."); - return std::string(); + return nullptr; } cmGeneratorTarget* target = context->LG->FindGeneratorTargetToUse(name); if (!target) { ::reportError(context, content->GetOriginalExpression(), "No target \"" + name + "\""); - return std::string(); + return nullptr; } if (target->GetType() >= cmStateEnums::OBJECT_LIBRARY && target->GetType() != cmStateEnums::UNKNOWN_LIBRARY) { ::reportError(context, content->GetOriginalExpression(), "Target \"" + name + "\" is not an executable or library."); - return std::string(); + return nullptr; } if (dagChecker && (dagChecker->EvaluatingLinkLibraries(target) || @@ -2064,6 +2062,29 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode ::reportError(context, content->GetOriginalExpression(), "Expressions which require the linker language may not " "be used while evaluating link libraries"); + return nullptr; + } + + return target; + } +}; + +template <typename ArtifactT, typename ComponentT> +struct TargetFilesystemArtifact : public TargetArtifactBase +{ + TargetFilesystemArtifact() {} // NOLINT(modernize-use-equals-default) + + int NumExpectedParameters() const override { return 1; } + + std::string Evaluate( + const std::vector<std::string>& parameters, + cmGeneratorExpressionContext* context, + const GeneratorExpressionContent* content, + cmGeneratorExpressionDAGChecker* dagChecker) const override + { + cmGeneratorTarget* target = + this->GetTarget(parameters, context, content, dagChecker); + if (!target) { return std::string(); } context->DependTargets.insert(target); |