Browse Source

cmGeneratorExpressionDAGChecker: Construct with initializer list syntax

pull/377/head
Brad King 5 months ago
parent
commit
2ccbad90e6
  1. 7
      Source/cmCommonTargetGenerator.cxx
  2. 26
      Source/cmComputeLinkDepends.cxx
  3. 11
      Source/cmExportTryCompileFileGenerator.cxx
  4. 10
      Source/cmGeneratorExpression.cxx
  5. 20
      Source/cmGeneratorExpressionNode.cxx
  6. 17
      Source/cmGeneratorTarget.cxx
  7. 27
      Source/cmGeneratorTarget_IncludeDirectories.cxx
  8. 10
      Source/cmGeneratorTarget_Link.cxx
  9. 5
      Source/cmGeneratorTarget_LinkDirectories.cxx
  10. 40
      Source/cmGeneratorTarget_Options.cxx
  11. 5
      Source/cmGeneratorTarget_Sources.cxx
  12. 12
      Source/cmGeneratorTarget_TransitiveProperty.cxx
  13. 14
      Source/cmQtAutoGenInitializer.cxx

7
Source/cmCommonTargetGenerator.cxx

@ -500,9 +500,10 @@ std::string cmCommonTargetGenerator::GetLinkerLauncher(
std::string propName = lang + "_LINKER_LAUNCHER";
cmValue launcherProp = this->GeneratorTarget->GetProperty(propName);
if (cmNonempty(launcherProp)) {
cmGeneratorExpressionDAGChecker dagChecker(
this->GeneratorTarget, propName, nullptr, nullptr,
this->LocalCommonGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this->GeneratorTarget, propName, nullptr, nullptr,
this->LocalCommonGenerator, config,
};
std::string evaluatedLinklauncher = cmGeneratorExpression::Evaluate(
*launcherProp, this->LocalCommonGenerator, config, this->GeneratorTarget,
&dagChecker, this->GeneratorTarget, lang);

26
Source/cmComputeLinkDepends.cxx

@ -646,18 +646,18 @@ cmComputeLinkDepends::cmComputeLinkDepends(const cmGeneratorTarget* target,
if (cmValue feature = this->Target->GetProperty(key)) {
if (!feature->empty() && key.length() > lloPrefix.length()) {
auto item = key.substr(lloPrefix.length());
cmGeneratorExpressionDAGChecker dag{
cmGeneratorExpressionDAGChecker dagChecker{
this->Target->GetBacktrace(),
this->Target,
"LINK_LIBRARY_OVERRIDE",
nullptr,
nullptr,
this->Target->GetLocalGenerator(),
config
config,
};
auto overrideFeature = cmGeneratorExpression::Evaluate(
*feature, this->Target->GetLocalGenerator(), config,
this->Target, &dag, this->Target, linkLanguage);
this->Target, &dagChecker, this->Target, linkLanguage);
this->LinkLibraryOverride.emplace(item, overrideFeature);
}
}
@ -666,16 +666,18 @@ cmComputeLinkDepends::cmComputeLinkDepends(const cmGeneratorTarget* target,
// global override property
if (cmValue linkLibraryOverride =
this->Target->GetProperty("LINK_LIBRARY_OVERRIDE")) {
cmGeneratorExpressionDAGChecker dag{ target->GetBacktrace(),
target,
"LINK_LIBRARY_OVERRIDE",
nullptr,
nullptr,
target->GetLocalGenerator(),
config };
cmGeneratorExpressionDAGChecker dagChecker{
target->GetBacktrace(),
target,
"LINK_LIBRARY_OVERRIDE",
nullptr,
nullptr,
target->GetLocalGenerator(),
config,
};
auto overrideValue = cmGeneratorExpression::Evaluate(
*linkLibraryOverride, target->GetLocalGenerator(), config, target, &dag,
target, linkLanguage);
*linkLibraryOverride, target->GetLocalGenerator(), config, target,
&dagChecker, target, linkLanguage);
auto overrideList = cmTokenize(overrideValue, ","_s);
if (overrideList.size() >= 2) {

11
Source/cmExportTryCompileFileGenerator.cxx

@ -86,9 +86,14 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
tgt, "LINK_OPTIONS", nullptr, nullptr, tgt->GetLocalGenerator(),
this->Config);
}
cmGeneratorExpressionDAGChecker dagChecker(
tgt, propName, nullptr, parentDagChecker.get(), tgt->GetLocalGenerator(),
this->Config);
cmGeneratorExpressionDAGChecker dagChecker{
tgt,
propName,
nullptr,
parentDagChecker.get(),
tgt->GetLocalGenerator(),
this->Config,
};
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*prop);

10
Source/cmGeneratorExpression.cxx

@ -425,10 +425,14 @@ const std::string& cmGeneratorExpressionInterpreter::Evaluate(
this->GeneratorExpression.Parse(std::move(expression));
// Specify COMPILE_OPTIONS to DAGchecker, same semantic as COMPILE_FLAGS
cmGeneratorExpressionDAGChecker dagChecker(
cmGeneratorExpressionDAGChecker dagChecker{
this->HeadTarget,
property == "COMPILE_FLAGS" ? "COMPILE_OPTIONS" : property, nullptr,
nullptr, this->LocalGenerator, this->Config);
property == "COMPILE_FLAGS" ? "COMPILE_OPTIONS" : property,
nullptr,
nullptr,
this->LocalGenerator,
this->Config,
};
return this->CompiledGeneratorExpression->Evaluate(
this->LocalGenerator, this->Config, this->HeadTarget, &dagChecker, nullptr,

20
Source/cmGeneratorExpressionNode.cxx

@ -485,10 +485,15 @@ protected:
cmGeneratorExpressionDAGChecker* dagCheckerParent) const
{
if (context->HeadTarget) {
cmGeneratorExpressionDAGChecker dagChecker(
context->Backtrace, context->HeadTarget,
genexOperator + ":" + expression, content, dagCheckerParent,
context->LG, context->Config);
cmGeneratorExpressionDAGChecker dagChecker{
context->Backtrace,
context->HeadTarget,
genexOperator + ":" + expression,
content,
dagCheckerParent,
context->LG,
context->Config,
};
switch (dagChecker.Check()) {
case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE: {
@ -2987,9 +2992,10 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
dagCheckerParent, usage));
}
cmGeneratorExpressionDAGChecker dagChecker(
context->Backtrace, target, propertyName, content, dagCheckerParent,
context->LG, context->Config);
cmGeneratorExpressionDAGChecker dagChecker{
context->Backtrace, target, propertyName, content,
dagCheckerParent, context->LG, context->Config,
};
switch (dagChecker.Check()) {
case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:

17
Source/cmGeneratorTarget.cxx

@ -744,8 +744,9 @@ std::string cmGeneratorTarget::GetLinkerTypeProperty(
std::string propName{ "LINKER_TYPE" };
auto linkerType = this->GetProperty(propName);
if (!linkerType.IsEmpty()) {
cmGeneratorExpressionDAGChecker dagChecker(
this, propName, nullptr, nullptr, this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, propName, nullptr, nullptr, this->LocalGenerator, config,
};
auto ltype =
cmGeneratorExpression::Evaluate(*linkerType, this->GetLocalGenerator(),
config, this, &dagChecker, this, lang);
@ -1200,9 +1201,10 @@ void cmGeneratorTarget::AddSystemIncludeCacheKey(
const std::string& key, const std::string& config,
const std::string& language) const
{
cmGeneratorExpressionDAGChecker dagChecker(
this, "SYSTEM_INCLUDE_DIRECTORIES", nullptr, nullptr, this->LocalGenerator,
config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "SYSTEM_INCLUDE_DIRECTORIES", nullptr,
nullptr, this->LocalGenerator, config,
};
bool excludeImported = this->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED");
@ -1978,8 +1980,9 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector<std::string>& result,
return;
}
cmGeneratorExpressionDAGChecker dagChecker(
this, "AUTOUIC_OPTIONS", nullptr, nullptr, this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "AUTOUIC_OPTIONS", nullptr, nullptr, this->LocalGenerator, config,
};
cmExpandList(cmGeneratorExpression::Evaluate(prop, this->LocalGenerator,
config, this, &dagChecker),
result);

27
Source/cmGeneratorTarget_IncludeDirectories.cxx

@ -47,13 +47,13 @@ std::string AddLangSpecificInterfaceIncludeDirectories(
const std::string& propertyName, IncludeDirectoryFallBack mode,
cmGeneratorExpressionDAGChecker* context)
{
cmGeneratorExpressionDAGChecker dag{
cmGeneratorExpressionDAGChecker dagChecker{
target->GetBacktrace(), target, propertyName, nullptr, context,
target->GetLocalGenerator(), config
target->GetLocalGenerator(), config,
};
switch (dag.Check()) {
switch (dagChecker.Check()) {
case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
dag.ReportError(
dagChecker.ReportError(
nullptr, "$<TARGET_PROPERTY:" + target->GetName() + ",propertyName");
CM_FALLTHROUGH;
case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE:
@ -100,9 +100,9 @@ void AddLangSpecificImplicitIncludeDirectories(
{
if (const auto* libraries =
target->GetLinkImplementationLibraries(config, UseTo::Compile)) {
cmGeneratorExpressionDAGChecker dag{
cmGeneratorExpressionDAGChecker dagChecker{
target->GetBacktrace(), target, propertyName, nullptr, nullptr,
target->GetLocalGenerator(), config
target->GetLocalGenerator(), config,
};
for (const cmLinkImplItem& library : libraries->Libraries) {
@ -128,10 +128,10 @@ void AddLangSpecificImplicitIncludeDirectories(
}
}
cmExpandList(
AddLangSpecificInterfaceIncludeDirectories(
target, dependency, lang, config, propertyName, mode, &dag),
entry.Values);
cmExpandList(AddLangSpecificInterfaceIncludeDirectories(
target, dependency, lang, config, propertyName, mode,
&dagChecker),
entry.Values);
entries.Entries.emplace_back(std::move(entry));
}
}
@ -257,9 +257,10 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories(
std::vector<BT<std::string>> includes;
std::unordered_set<std::string> uniqueIncludes;
cmGeneratorExpressionDAGChecker dagChecker(this, "INCLUDE_DIRECTORIES",
nullptr, nullptr,
this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "INCLUDE_DIRECTORIES", nullptr,
nullptr, this->LocalGenerator, config,
};
cmList debugProperties{ this->Makefile->GetDefinition(
"CMAKE_DEBUG_TARGET_PROPERTIES") };

10
Source/cmGeneratorTarget_Link.cxx

@ -564,8 +564,9 @@ void cmGeneratorTarget::ExpandLinkItems(std::string const& prop,
return;
}
// Keep this logic in sync with ComputeLinkImplementationLibraries.
cmGeneratorExpressionDAGChecker dagChecker(this, prop, nullptr, nullptr,
this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, prop, nullptr, nullptr, this->LocalGenerator, config,
};
// The $<LINK_ONLY> expression may be in a link interface to specify
// private link dependencies that are otherwise excluded from usage
// requirements.
@ -1320,8 +1321,9 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
// Collect libraries directly linked in this configuration.
for (auto const& entry : entryRange) {
// Keep this logic in sync with ExpandLinkItems.
cmGeneratorExpressionDAGChecker dagChecker(
this, "LINK_LIBRARIES", nullptr, nullptr, this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "LINK_LIBRARIES", nullptr, nullptr, this->LocalGenerator, config,
};
// The $<LINK_ONLY> expression may be used to specify link dependencies
// that are otherwise excluded from usage requirements.
if (usage == UseTo::Compile) {

5
Source/cmGeneratorTarget_LinkDirectories.cxx

@ -125,8 +125,9 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDirectories(
std::vector<BT<std::string>> result;
std::unordered_set<std::string> uniqueDirectories;
cmGeneratorExpressionDAGChecker dagChecker(
this, "LINK_DIRECTORIES", nullptr, nullptr, this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "LINK_DIRECTORIES", nullptr, nullptr, this->LocalGenerator, config,
};
cmList debugProperties{ this->Makefile->GetDefinition(
"CMAKE_DEBUG_TARGET_PROPERTIES") };

40
Source/cmGeneratorTarget_Options.cxx

@ -233,8 +233,9 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileOptions(
std::vector<BT<std::string>> result;
std::unordered_set<std::string> uniqueOptions;
cmGeneratorExpressionDAGChecker dagChecker(
this, "COMPILE_OPTIONS", nullptr, nullptr, this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "COMPILE_OPTIONS", nullptr, nullptr, this->LocalGenerator, config,
};
cmList debugProperties{ this->Makefile->GetDefinition(
"CMAKE_DEBUG_TARGET_PROPERTIES") };
@ -274,8 +275,9 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileFeatures(
std::vector<BT<std::string>> result;
std::unordered_set<std::string> uniqueFeatures;
cmGeneratorExpressionDAGChecker dagChecker(
this, "COMPILE_FEATURES", nullptr, nullptr, this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "COMPILE_FEATURES", nullptr, nullptr, this->LocalGenerator, config,
};
cmList debugProperties{ this->Makefile->GetDefinition(
"CMAKE_DEBUG_TARGET_PROPERTIES") };
@ -324,9 +326,10 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
std::vector<BT<std::string>> list;
std::unordered_set<std::string> uniqueOptions;
cmGeneratorExpressionDAGChecker dagChecker(this, "COMPILE_DEFINITIONS",
nullptr, nullptr,
this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "COMPILE_DEFINITIONS", nullptr,
nullptr, this->LocalGenerator, config,
};
cmList debugProperties{ this->Makefile->GetDefinition(
"CMAKE_DEBUG_TARGET_PROPERTIES") };
@ -389,9 +392,9 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetPrecompileHeaders(
}
std::unordered_set<std::string> uniqueOptions;
cmGeneratorExpressionDAGChecker dagChecker(this, "PRECOMPILE_HEADERS",
nullptr, nullptr,
this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "PRECOMPILE_HEADERS", nullptr, nullptr, this->LocalGenerator, config,
};
cmList debugProperties{ this->Makefile->GetDefinition(
"CMAKE_DEBUG_TARGET_PROPERTIES") };
@ -448,8 +451,9 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkOptions(
std::vector<BT<std::string>> result;
std::unordered_set<std::string> uniqueOptions;
cmGeneratorExpressionDAGChecker dagChecker(
this, "LINK_OPTIONS", nullptr, nullptr, this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "LINK_OPTIONS", nullptr, nullptr, this->LocalGenerator, config,
};
cmList debugProperties{ this->Makefile->GetDefinition(
"CMAKE_DEBUG_TARGET_PROPERTIES") };
@ -622,9 +626,10 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetStaticLibraryLinkOptions(
std::vector<BT<std::string>> result;
std::unordered_set<std::string> uniqueOptions;
cmGeneratorExpressionDAGChecker dagChecker(this, "STATIC_LIBRARY_OPTIONS",
nullptr, nullptr,
this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "STATIC_LIBRARY_OPTIONS", nullptr,
nullptr, this->LocalGenerator, config,
};
EvaluatedTargetPropertyEntries entries;
if (cmValue linkOptions = this->GetProperty("STATIC_LIBRARY_OPTIONS")) {
@ -655,8 +660,9 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDepends(
{
std::vector<BT<std::string>> result;
std::unordered_set<std::string> uniqueOptions;
cmGeneratorExpressionDAGChecker dagChecker(
this, "LINK_DEPENDS", nullptr, nullptr, this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "LINK_DEPENDS", nullptr, nullptr, this->LocalGenerator, config,
};
EvaluatedTargetPropertyEntries entries;
if (cmValue linkDepends = this->GetProperty("LINK_DEPENDS")) {

5
Source/cmGeneratorTarget_Sources.cxx

@ -264,8 +264,9 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetSourceFilePaths(
this->DebugSourcesDone = true;
}
cmGeneratorExpressionDAGChecker dagChecker(this, "SOURCES", nullptr, nullptr,
this->LocalGenerator, config);
cmGeneratorExpressionDAGChecker dagChecker{
this, "SOURCES", nullptr, nullptr, this->LocalGenerator, config,
};
EvaluatedTargetPropertyEntries entries = EvaluateTargetPropertyEntries(
this, config, std::string(), &dagChecker, this->SourceEntries);

12
Source/cmGeneratorTarget_TransitiveProperty.cxx

@ -109,9 +109,15 @@ std::string cmGeneratorTarget::EvaluateInterfaceProperty(
// Evaluate $<TARGET_PROPERTY:this,prop> as if it were compiled. This is
// a subset of TargetPropertyNode::Evaluate without stringify/parse steps
// but sufficient for transitive interface properties.
cmGeneratorExpressionDAGChecker dagChecker(
context->Backtrace, this, prop, nullptr, dagCheckerParent,
this->LocalGenerator, context->Config);
cmGeneratorExpressionDAGChecker dagChecker{
context->Backtrace,
this,
prop,
nullptr,
dagCheckerParent,
this->LocalGenerator,
context->Config,
};
switch (dagChecker.Check()) {
case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
dagChecker.ReportError(

14
Source/cmQtAutoGenInitializer.cxx

@ -1922,9 +1922,10 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
if (this->MultiConfig) {
for (auto const& cfg : this->ConfigsList) {
if (!cfg.empty()) {
cmGeneratorExpressionDAGChecker dagChecker(
this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, nullptr,
this->LocalGen, cfg);
cmGeneratorExpressionDAGChecker dagChecker{
this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr,
nullptr, this->LocalGen, cfg,
};
AddInterfaceEntries(this->GenTarget, cfg,
"INTERFACE_AUTOMOC_MACRO_NAMES", "CXX",
&dagChecker, InterfaceAutoMocMacroNamesEntries,
@ -1932,9 +1933,10 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
}
}
} else {
cmGeneratorExpressionDAGChecker dagChecker(
this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, nullptr,
this->LocalGen, this->ConfigDefault);
cmGeneratorExpressionDAGChecker dagChecker{
this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr,
nullptr, this->LocalGen, this->ConfigDefault,
};
AddInterfaceEntries(this->GenTarget, this->ConfigDefault,
"INTERFACE_AUTOMOC_MACRO_NAMES", "CXX", &dagChecker,
InterfaceAutoMocMacroNamesEntries,

Loading…
Cancel
Save