summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorTarget.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-05-12 15:27:11 (GMT)
committerBrad King <brad.king@kitware.com>2020-05-12 16:44:32 (GMT)
commit6c5d4522bcc242361895e72c3fcbd91710abb64c (patch)
tree7d4b9023b8e6196be4835611dcea9a137468caa2 /Source/cmGeneratorTarget.cxx
parent8daa140c6a293b14e6f28a8fc84122c2c24296fe (diff)
downloadCMake-6c5d4522bcc242361895e72c3fcbd91710abb64c.zip
CMake-6c5d4522bcc242361895e72c3fcbd91710abb64c.tar.gz
CMake-6c5d4522bcc242361895e72c3fcbd91710abb64c.tar.bz2
INTERFACE_SOURCES: Fix per-config link libs on multi-config generators
In multi-config generators we memoize the computed set of source files for a target to avoid repeating the computation when the set does not depend on the configuration. We already track whether generator expressions in `SOURCES` or `INTERFACE_SOURCES` reference the configuration (`$<CONFIG:...>`). However, we previously forgot to track whether the set of libraries whose `INTERFACE_SOURCES` are considered depends on the configuration. This caused multi-config generators to use the first configuration's set of sources for all configurations in cases such as target_link_libraries(tgt PRIVATE $<$<CONFIG:Debug>:iface_debug>) where the `iface_debug` target has `INTERFACE_SOURCES`. Fix this by also tracking config-dependence of the list of libraries for evaluation of the list of source files. Fixes: #20683
Diffstat (limited to 'Source/cmGeneratorTarget.cxx')
-rw-r--r--Source/cmGeneratorTarget.cxx8
1 files changed, 7 insertions, 1 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index d253bc7..a44126c 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -241,6 +241,7 @@ EvaluatedTargetPropertyEntry EvaluateTargetPropertyEntry(
struct EvaluatedTargetPropertyEntries
{
std::vector<EvaluatedTargetPropertyEntry> Entries;
+ bool HadContextSensitiveCondition = false;
};
EvaluatedTargetPropertyEntries EvaluateTargetPropertyEntries(
@@ -1251,6 +1252,9 @@ std::string cmGeneratorTarget::EvaluateInterfaceProperty(
if (cmLinkInterfaceLibraries const* iface = this->GetLinkInterfaceLibraries(
context->Config, headTarget, usage_requirements_only)) {
+ context->HadContextSensitiveCondition =
+ context->HadContextSensitiveCondition ||
+ iface->HadContextSensitiveCondition;
for (cmLinkItem const& lib : iface->Libraries) {
// Broken code can have a target in its own link interface.
// Don't follow such link interface entries so as not to create a
@@ -1378,6 +1382,7 @@ void AddInterfaceEntries(cmGeneratorTarget const* headTarget,
{
if (cmLinkImplementationLibraries const* impl =
headTarget->GetLinkImplementationLibraries(config)) {
+ entries.HadContextSensitiveCondition = impl->HadContextSensitiveCondition;
for (cmLinkImplItem const& lib : impl->Libraries) {
if (lib.Target) {
EvaluatedTargetPropertyEntry ee(lib, lib.Backtrace);
@@ -1404,6 +1409,7 @@ void AddObjectEntries(cmGeneratorTarget const* headTarget,
{
if (cmLinkImplementationLibraries const* impl =
headTarget->GetLinkImplementationLibraries(config)) {
+ entries.HadContextSensitiveCondition = impl->HadContextSensitiveCondition;
for (cmLinkImplItem const& lib : impl->Libraries) {
if (lib.Target &&
lib.Target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
@@ -1436,7 +1442,7 @@ bool processSources(cmGeneratorTarget const* tgt,
{
cmMakefile* mf = tgt->Target->GetMakefile();
- bool contextDependent = false;
+ bool contextDependent = entries.HadContextSensitiveCondition;
for (EvaluatedTargetPropertyEntry& entry : entries.Entries) {
if (entry.ContextDependent) {