summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-02-25 14:23:10 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-02-25 14:23:17 (GMT)
commitf259e8759ce300cd505e30cda1b5fca3ba100cc5 (patch)
tree44a7303ab6e0003bd19485229ed3129330fbb739 /Source/cmGlobalGenerator.cxx
parentf3b4a12c610e6c4fc37ea03c902c354228208726 (diff)
parent3f685ac3e131cbf89391b9e63163283e1e570a9b (diff)
downloadCMake-f259e8759ce300cd505e30cda1b5fca3ba100cc5.zip
CMake-f259e8759ce300cd505e30cda1b5fca3ba100cc5.tar.gz
CMake-f259e8759ce300cd505e30cda1b5fca3ba100cc5.tar.bz2
Merge topic 'gt-shorter-unique-names'
3f685ac3e1 Use shorter names in internal TARGET_PROPERTY expressions Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3009
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r--Source/cmGlobalGenerator.cxx17
1 files changed, 12 insertions, 5 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 8107a07..a22cd18 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2109,17 +2109,24 @@ void cmGlobalGenerator::IndexGeneratorTarget(cmGeneratorTarget* gt)
}
}
+static char const hexDigits[] = "0123456789abcdef";
+
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.
+ // Use a ":" prefix to avoid conflict with project-defined targets.
// 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;
+ char buf[1 + sizeof(gt) * 2];
+ char* b = buf;
+ *b++ = ':';
+ for (size_t i = 0; i < sizeof(gt); ++i) {
+ unsigned char const c = reinterpret_cast<unsigned char const*>(&gt)[i];
+ *b++ = hexDigits[(c & 0xf0) >> 4];
+ *b++ = hexDigits[(c & 0x0f)];
+ }
+ std::string id(buf, sizeof(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.