summaryrefslogtreecommitdiff
path: root/Source/cmGeneratorExpressionNode.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmGeneratorExpressionNode.cxx')
-rw-r--r--Source/cmGeneratorExpressionNode.cxx144
1 files changed, 110 insertions, 34 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index e4fb67e699..4ca7405b5b 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -37,6 +37,7 @@
#include "cmPolicies.h"
#include "cmProperty.h"
#include "cmRange.h"
+#include "cmStandardLevelResolver.h"
#include "cmState.h"
#include "cmStateSnapshot.h"
#include "cmStateTypes.h"
@@ -714,7 +715,8 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
static const CompilerIdNode cCompilerIdNode("C"), cxxCompilerIdNode("CXX"),
cudaCompilerIdNode("CUDA"), objcCompilerIdNode("OBJC"),
- objcxxCompilerIdNode("OBJCXX"), fortranCompilerIdNode("Fortran");
+ objcxxCompilerIdNode("OBJCXX"), fortranCompilerIdNode("Fortran"),
+ ispcCompilerIdNode("ISPC");
struct CompilerVersionNode : public cmGeneratorExpressionNode
{
@@ -779,7 +781,7 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode
static const CompilerVersionNode cCompilerVersionNode("C"),
cxxCompilerVersionNode("CXX"), cudaCompilerVersionNode("CUDA"),
objcCompilerVersionNode("OBJC"), objcxxCompilerVersionNode("OBJCXX"),
- fortranCompilerVersionNode("Fortran");
+ fortranCompilerVersionNode("Fortran"), ispcCompilerVersionNode("ISPC");
struct PlatformIdNode : public cmGeneratorExpressionNode
{
@@ -881,7 +883,7 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
{
ConfigurationTestNode() {} // NOLINT(modernize-use-equals-default)
- int NumExpectedParameters() const override { return OneOrZeroParameters; }
+ int NumExpectedParameters() const override { return ZeroOrMoreParameters; }
std::string Evaluate(
const std::vector<std::string>& parameters,
@@ -899,13 +901,15 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
return std::string();
}
context->HadContextSensitiveCondition = true;
- if (context->Config.empty()) {
- return parameters.front().empty() ? "1" : "0";
- }
-
- if (cmsysString_strcasecmp(parameters.front().c_str(),
- context->Config.c_str()) == 0) {
- return "1";
+ for (auto& param : parameters) {
+ if (context->Config.empty()) {
+ if (param.empty()) {
+ return "1";
+ }
+ } else if (cmsysString_strcasecmp(param.c_str(),
+ context->Config.c_str()) == 0) {
+ return "1";
+ }
}
if (context->CurrentTarget && context->CurrentTarget->IsImported()) {
@@ -922,10 +926,12 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
"MAP_IMPORTED_CONFIG_", cmSystemTools::UpperCase(context->Config));
if (cmProp mapValue = context->CurrentTarget->GetProperty(mapProp)) {
cmExpandList(cmSystemTools::UpperCase(*mapValue), mappedConfigs);
- return cm::contains(mappedConfigs,
- cmSystemTools::UpperCase(parameters.front()))
- ? "1"
- : "0";
+
+ for (auto& param : parameters) {
+ if (cm::contains(mappedConfigs, cmSystemTools::UpperCase(param))) {
+ return "1";
+ }
+ }
}
}
}
@@ -962,9 +968,10 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode
const std::vector<std::string>& parameters,
cmGeneratorExpressionContext* context,
const GeneratorExpressionContent* content,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
+ cmGeneratorExpressionDAGChecker* dagChecker) const override
{
- if (context->Language.empty()) {
+ if (context->Language.empty() &&
+ (!dagChecker || !dagChecker->EvaluatingCompileExpression())) {
reportError(
context, content->GetOriginalExpression(),
"$<COMPILE_LANGUAGE:...> may only be used to specify include "
@@ -1009,7 +1016,9 @@ static const struct CompileLanguageAndIdNode : public cmGeneratorExpressionNode
const GeneratorExpressionContent* content,
cmGeneratorExpressionDAGChecker* dagChecker) const override
{
- if (!context->HeadTarget || context->Language.empty()) {
+ if (!context->HeadTarget ||
+ (context->Language.empty() &&
+ (!dagChecker || !dagChecker->EvaluatingCompileExpression()))) {
// reportError(context, content->GetOriginalExpression(), "");
reportError(
context, content->GetOriginalExpression(),
@@ -1468,8 +1477,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
}
if (isInterfaceProperty) {
- return target->EvaluateInterfaceProperty(propertyName, context,
- dagCheckerParent);
+ return cmGeneratorExpression::StripEmptyListElements(
+ target->EvaluateInterfaceProperty(propertyName, context,
+ dagCheckerParent));
}
cmGeneratorExpressionDAGChecker dagChecker(
@@ -1555,8 +1565,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
}
if (!interfacePropertyName.empty()) {
- result = this->EvaluateDependentExpression(result, context->LG, context,
- target, &dagChecker, target);
+ result = cmGeneratorExpression::StripEmptyListElements(
+ this->EvaluateDependentExpression(result, context->LG, context, target,
+ &dagChecker, target));
std::string linkedTargetsContent = getLinkedTargetsContent(
target, interfacePropertyName, context, &dagChecker);
if (!linkedTargetsContent.empty()) {
@@ -1653,9 +1664,8 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
if (context->EvaluateForBuildsystem) {
// Use object file directory with buildsystem placeholder.
obj_dir = gt->ObjectDirectory;
- // Here we assume that the set of object files produced
- // by an object library does not vary with configuration
- // and do not set HadContextSensitiveCondition to true.
+ context->HadContextSensitiveCondition =
+ gt->HasContextDependentSources();
} else {
// Use object file directory with per-config location.
obj_dir = gt->GetObjectDirectory(context->Config);
@@ -1703,12 +1713,12 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
static LangMap availableFeatures;
LangMap testedFeatures;
-
+ cmStandardLevelResolver standardResolver(context->LG->GetMakefile());
for (std::string const& p : parameters) {
std::string error;
std::string lang;
- if (!context->LG->GetMakefile()->CompileFeatureKnown(
- context->HeadTarget->Target, p, lang, &error)) {
+ if (!standardResolver.CompileFeatureKnown(
+ context->HeadTarget->Target->GetName(), p, lang, &error)) {
reportError(context, content->GetOriginalExpression(), error);
return std::string();
}
@@ -1716,7 +1726,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
if (availableFeatures.find(lang) == availableFeatures.end()) {
const char* featuresKnown =
- context->LG->GetMakefile()->CompileFeaturesAvailable(lang, &error);
+ standardResolver.CompileFeaturesAvailable(lang, &error);
if (!featuresKnown) {
reportError(context, content->GetOriginalExpression(), error);
return std::string();
@@ -1730,7 +1740,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
for (auto const& lit : testedFeatures) {
std::vector<std::string> const& langAvailable =
availableFeatures[lit.first];
- cmProp standardDefault = context->LG->GetMakefile()->GetDef(
+ cmProp standardDefault = context->LG->GetMakefile()->GetDefinition(
"CMAKE_" + lit.first + "_STANDARD_DEFAULT");
for (std::string const& it : lit.second) {
if (!cm::contains(langAvailable, it)) {
@@ -1741,10 +1751,10 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
// All features known for the language are always available.
continue;
}
- if (!context->LG->GetMakefile()->HaveStandardAvailable(
- target->Target, lit.first, it)) {
+ if (!standardResolver.HaveStandardAvailable(target, lit.first,
+ context->Config, it)) {
if (evalLL) {
- cmProp l = target->GetProperty(lit.first + "_STANDARD");
+ cmProp l = target->GetLanguageStandard(lit.first, context->Config);
if (!l) {
l = standardDefault;
}
@@ -1891,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
{
@@ -2143,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,