diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2020-08-18 12:25:31 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-09-01 13:25:19 (GMT) |
commit | f14b390198222f5d7eca9e5109fabcb0188da762 (patch) | |
tree | ad67bb4af6f85bf6fb2f4b157881a2f1e1a4a9da /Source/cmGeneratorExpressionNode.cxx | |
parent | 5294febcaf378589dba49801321d19f93f67464e (diff) | |
download | CMake-f14b390198222f5d7eca9e5109fabcb0188da762.zip CMake-f14b390198222f5d7eca9e5109fabcb0188da762.tar.gz CMake-f14b390198222f5d7eca9e5109fabcb0188da762.tar.bz2 |
GenEx: Remove unneeded dependencies from target info queries
Only generate a graph dependency between a custom command and
a target when the custom command queries for the file path
of an artifact of the target.
This makes generator expressions such as `TARGET_FILE_DIR`
behave the same way as `TARGET_PROPERTY` which never generated
a graph dependency.
Diffstat (limited to 'Source/cmGeneratorExpressionNode.cxx')
-rw-r--r-- | Source/cmGeneratorExpressionNode.cxx | 70 |
1 files changed, 68 insertions, 2 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index fdc8f29..d9cdf11 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1901,6 +1901,70 @@ class ArtifactSonameTag; class ArtifactBundleDirTag; class ArtifactBundleContentDirTag; +template <typename ArtifactT, typename ComponentT> +struct TargetFilesystemArtifactDependency +{ + static void AddDependency(cmGeneratorTarget* target, + cmGeneratorExpressionContext* context) + { + context->DependTargets.insert(target); + context->AllTargets.insert(target); + } +}; + +struct TargetFilesystemArtifactDependencyCMP0112 +{ + static void AddDependency(cmGeneratorTarget* target, + cmGeneratorExpressionContext* context) + { + context->AllTargets.insert(target); + cmLocalGenerator* lg = context->LG; + switch (target->GetPolicyStatusCMP0112()) { + case cmPolicies::WARN: + if (lg->GetMakefile()->PolicyOptionalWarningEnabled( + "CMAKE_POLICY_WARNING_CMP0112")) { + std::string err = + cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0112), + "\nDependency being added to target:\n \"", + target->GetName(), "\"\n"); + lg->GetCMakeInstance()->IssueMessage(MessageType ::AUTHOR_WARNING, + err, context->Backtrace); + } + CM_FALLTHROUGH; + case cmPolicies::OLD: + context->DependTargets.insert(target); + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + break; + } + } +}; + +template <typename ArtifactT> +struct TargetFilesystemArtifactDependency<ArtifactT, ArtifactNameTag> + : TargetFilesystemArtifactDependencyCMP0112 +{ +}; +template <typename ArtifactT> +struct TargetFilesystemArtifactDependency<ArtifactT, ArtifactDirTag> + : TargetFilesystemArtifactDependencyCMP0112 +{ +}; +template <> +struct TargetFilesystemArtifactDependency<ArtifactBundleDirTag, + ArtifactPathTag> + : TargetFilesystemArtifactDependencyCMP0112 +{ +}; +template <> +struct TargetFilesystemArtifactDependency<ArtifactBundleContentDirTag, + ArtifactPathTag> + : TargetFilesystemArtifactDependencyCMP0112 +{ +}; + template <typename ArtifactT> struct TargetFilesystemArtifactResultCreator { @@ -2153,8 +2217,10 @@ struct TargetFilesystemArtifact : public TargetArtifactBase if (!target) { return std::string(); } - context->DependTargets.insert(target); - context->AllTargets.insert(target); + // Not a dependent target if we are querying for ArtifactDirTag, + // ArtifactNameTag, ArtifactBundleDirTag, and ArtifactBundleContentDirTag + TargetFilesystemArtifactDependency<ArtifactT, ComponentT>::AddDependency( + target, context); std::string result = TargetFilesystemArtifactResultCreator<ArtifactT>::Create(target, context, |