Genex: Add TARGET_BUNDLE_DIR_NAME

Evaluate to the name of the bundle directory for a given bundle target.

Fixes: #23409
This commit is contained in:
Ben Leadbetter
2022-04-14 15:44:49 +02:00
committed by Brad King
parent 627b2eba6c
commit 997af2e1a6
12 changed files with 88 additions and 1 deletions

View File

@@ -2098,6 +2098,7 @@ class ArtifactPathTag;
class ArtifactPdbTag;
class ArtifactSonameTag;
class ArtifactBundleDirTag;
class ArtifactBundleDirNameTag;
class ArtifactBundleContentDirTag;
template <typename ArtifactT, typename ComponentT>
@@ -2158,6 +2159,12 @@ struct TargetFilesystemArtifactDependency<ArtifactBundleDirTag,
{
};
template <>
struct TargetFilesystemArtifactDependency<ArtifactBundleDirNameTag,
ArtifactPathTag>
: TargetFilesystemArtifactDependencyCMP0112
{
};
template <>
struct TargetFilesystemArtifactDependency<ArtifactBundleContentDirTag,
ArtifactPathTag>
: TargetFilesystemArtifactDependencyCMP0112
@@ -2284,6 +2291,31 @@ struct TargetFilesystemArtifactResultCreator<ArtifactBundleDirTag>
}
};
template <>
struct TargetFilesystemArtifactResultCreator<ArtifactBundleDirNameTag>
{
static std::string Create(cmGeneratorTarget* target,
cmGeneratorExpressionContext* context,
const GeneratorExpressionContent* content)
{
if (target->IsImported()) {
::reportError(
context, content->GetOriginalExpression(),
"TARGET_BUNDLE_DIR_NAME not allowed for IMPORTED targets.");
return std::string();
}
if (!target->IsBundleOnApple()) {
::reportError(
context, content->GetOriginalExpression(),
"TARGET_BUNDLE_DIR_NAME is allowed only for Bundle targets.");
return std::string();
}
return target->GetAppBundleDirectory(context->Config,
cmGeneratorTarget::BundleDirLevel);
}
};
template <>
struct TargetFilesystemArtifactResultCreator<ArtifactBundleContentDirTag>
{
@@ -2417,7 +2449,8 @@ struct TargetFilesystemArtifact : public TargetArtifactBase
return std::string();
}
// Not a dependent target if we are querying for ArtifactDirTag,
// ArtifactNameTag, ArtifactBundleDirTag, and ArtifactBundleContentDirTag
// ArtifactNameTag, ArtifactBundleDirTag, ArtifactBundleDirNameTag,
// and ArtifactBundleContentDirTag
TargetFilesystemArtifactDependency<ArtifactT, ComponentT>::AddDependency(
target, context);
@@ -2458,6 +2491,10 @@ static const TargetFilesystemArtifactNodeGroup<ArtifactPdbTag>
static const TargetFilesystemArtifact<ArtifactBundleDirTag, ArtifactPathTag>
targetBundleDirNode;
static const TargetFilesystemArtifact<ArtifactBundleDirNameTag,
ArtifactNameTag>
targetBundleDirNameNode;
static const TargetFilesystemArtifact<ArtifactBundleContentDirTag,
ArtifactPathTag>
targetBundleContentDirNode;
@@ -2783,6 +2820,7 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode(
{ "TARGET_SONAME_FILE_DIR", &targetSoNameNodeGroup.FileDir },
{ "TARGET_PDB_FILE_DIR", &targetPdbNodeGroup.FileDir },
{ "TARGET_BUNDLE_DIR", &targetBundleDirNode },
{ "TARGET_BUNDLE_DIR_NAME", &targetBundleDirNameNode },
{ "TARGET_BUNDLE_CONTENT_DIR", &targetBundleContentDirNode },
{ "STREQUAL", &strEqualNode },
{ "EQUAL", &equalNode },