summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorTarget.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-07-21 11:58:29 (GMT)
committerBrad King <brad.king@kitware.com>2019-07-23 10:50:31 (GMT)
commitad2b3a32d1b54716d1e87ae89db8c31d614a4730 (patch)
tree7f729169299d109c9a97c585e5396b09247614a5 /Source/cmGeneratorTarget.cxx
parent11fa818ecda0b50446aef891b06976973005e94b (diff)
downloadCMake-ad2b3a32d1b54716d1e87ae89db8c31d614a4730.zip
CMake-ad2b3a32d1b54716d1e87ae89db8c31d614a4730.tar.gz
CMake-ad2b3a32d1b54716d1e87ae89db8c31d614a4730.tar.bz2
Genex: Optimize build setting TARGET_PROPERTY evaluation
For each build setting property (such as `COMPILE_DEFINITIONS` or `INCLUDE_DIRECTORIES`), the value of `$<TARGET_PROPERTY:target,prop>` includes the values of the corresponding `INTERFACE_*` usage requirement property from the transitive closure of link libraries of the target. Previously we computed this by constructing a generator expression string like `$<TARGET_PROPERTY:lib,INTERFACE_COMPILE_DEFINITIONS>` and recursively evaluating it with the generator expression engine. Avoid the string construction and parsing by using the dedicated evaluation method `cmGeneratorTarget::EvaluateInterfaceProperty`. Issue: #18964, #18965
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r--Source/cmGeneratorTarget.cxx22
1 files changed, 8 insertions, 14 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 21da2fd..b22d8b6 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -1227,23 +1227,17 @@ void AddInterfaceEntries(cmGeneratorTarget const* headTarget,
headTarget->GetLinkImplementationLibraries(config)) {
for (cmLinkImplItem const& lib : impl->Libraries) {
if (lib.Target) {
- std::string uniqueName =
- headTarget->GetGlobalGenerator()->IndexGeneratorTargetUniquely(
- lib.Target);
- std::string genex =
- "$<TARGET_PROPERTY:" + std::move(uniqueName) + "," + prop + ">";
- cmGeneratorExpression ge(lib.Backtrace);
- std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(genex);
- cge->SetEvaluateForBuildsystem(true);
-
EvaluatedTargetPropertyEntry ee(lib, lib.Backtrace);
+ // Pretend $<TARGET_PROPERTY:lib.Target,prop> appeared in our
+ // caller's property and hand-evaluate it as if it were compiled.
+ // Create a context as cmCompiledGeneratorExpression::Evaluate does.
+ cmGeneratorExpressionContext context(
+ headTarget->GetLocalGenerator(), config, false, headTarget,
+ headTarget, true, lib.Backtrace, lang);
cmSystemTools::ExpandListArgument(
- cge->Evaluate(headTarget->GetLocalGenerator(), config, false,
- headTarget, dagChecker, lang),
+ lib.Target->EvaluateInterfaceProperty(prop, &context, dagChecker),
ee.Values);
- if (cge->GetHadContextSensitiveCondition()) {
- ee.ContextDependent = true;
- }
+ ee.ContextDependent = context.HadContextSensitiveCondition;
entries.emplace_back(std::move(ee));
}
}