summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-09-07 14:56:17 (GMT)
committerBrad King <brad.king@kitware.com>2018-09-12 16:46:25 (GMT)
commit2f708f5d65557ecbfe4ebe7c14b02dbba6bf0ffe (patch)
tree1fa50eade95a0394af49aaca5489839dcfad5d29 /Source/cmGlobalGenerator.cxx
parent94a75801c834891f47358e9f5763c56245dff3fe (diff)
downloadCMake-2f708f5d65557ecbfe4ebe7c14b02dbba6bf0ffe.zip
CMake-2f708f5d65557ecbfe4ebe7c14b02dbba6bf0ffe.tar.gz
CMake-2f708f5d65557ecbfe4ebe7c14b02dbba6bf0ffe.tar.bz2
Make internal TARGET_PROPERTY generator expressions more robust
While collecting usage requirements from the `INTERFACE_*` properties of directly linked targets, we internally generate `TARGET_PROPERTY:` and `TARGET_OBJECTS:` generator expressions to refer to those properties on those targets. At the point we generate these expressions we already have a pointer to an exact `cmGeneratorTarget` instance. Switch from using the target name in these generator expressions to using an internal unique name generated for each `cmGeneratorTarget` instance to be referenced. This avoids depending on the user-facing target name to find the same target we already have.
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r--Source/cmGlobalGenerator.cxx18
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 207d492..0aba67c 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2155,6 +2155,24 @@ void cmGlobalGenerator::IndexGeneratorTarget(cmGeneratorTarget* gt)
}
}
+std::string cmGlobalGenerator::IndexGeneratorTargetUniquely(
+ cmGeneratorTarget const* gt)
+{
+ // Use the pointer value to uniquely identify the target instance.
+ // Use a "T" prefix to indicate that this identifier is for a target.
+ // We must satisfy cmGeneratorExpression::IsValidTargetName so use no
+ // other special characters.
+ char buf[64];
+ sprintf(buf, "::T%p",
+ static_cast<void const*>(gt)); // cast avoids format warning
+ std::string id = gt->GetName() + buf;
+ // We internally index pointers to non-const generator targets
+ // but our callers only have pointers to const generator targets.
+ // They will give up non-const privileges when looking up anyway.
+ this->GeneratorTargetSearchIndex[id] = const_cast<cmGeneratorTarget*>(gt);
+ return id;
+}
+
void cmGlobalGenerator::IndexMakefile(cmMakefile* mf)
{
// FIXME: add_subdirectory supports multiple build directories