diff options
author | Brad King <brad.king@kitware.com> | 2020-09-01 13:59:00 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-09-01 13:59:08 (GMT) |
commit | 8f73ff0c3707e5b3f27f54f2b94e03ccb193d698 (patch) | |
tree | 78acec97adb3be0f9433847a138eddd0e19860d7 /Source | |
parent | 3001e8b5d9caac4e941870509545c9b3c808dd70 (diff) | |
parent | f14b390198222f5d7eca9e5109fabcb0188da762 (diff) | |
download | CMake-8f73ff0c3707e5b3f27f54f2b94e03ccb193d698.zip CMake-8f73ff0c3707e5b3f27f54f2b94e03ccb193d698.tar.gz CMake-8f73ff0c3707e5b3f27f54f2b94e03ccb193d698.tar.bz2 |
Merge topic 'target_genex_dependency'
f14b390198 GenEx: Remove unneeded dependencies from target info queries
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Raul Tambre <raul@tambre.ee>
Merge-request: !5127
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorExpressionNode.cxx | 70 | ||||
-rw-r--r-- | Source/cmPolicies.h | 7 |
2 files changed, 74 insertions, 3 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 83e9aac..1cc1d18 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1902,6 +1902,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 { @@ -2154,8 +2218,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, diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 1a12dab..bf6e531 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -330,6 +330,10 @@ class cmMakefile; SELECT(POLICY, CMP0111, \ "An imported target with a missing location fails during " \ "generation.", \ + 3, 19, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0112, \ + "Target file component generator expressions do not add target " \ + "dependencies.", \ 3, 19, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) @@ -363,7 +367,8 @@ class cmMakefile; F(CMP0099) \ F(CMP0104) \ F(CMP0105) \ - F(CMP0108) + F(CMP0108) \ + F(CMP0112) /** \class cmPolicies * \brief Handles changes in CMake behavior and policies |