MCPcopy Create free account
hub / github.com/Kitware/CMake / IndexGeneratorTargetUniquely

Method IndexGeneratorTargetUniquely

Source/cmGlobalGenerator.cxx:2723–2746  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2721static char const hexDigits[] = "0123456789abcdef";
2722
2723std::string cmGlobalGenerator::IndexGeneratorTargetUniquely(
2724 cmGeneratorTarget const* gt)
2725{
2726 // Use the pointer value to uniquely identify the target instance.
2727 // Use a ":" prefix to avoid conflict with project-defined targets.
2728 // We must satisfy cmGeneratorExpression::IsValidTargetName so use no
2729 // other special characters.
2730 constexpr size_t sizeof_ptr =
2731 sizeof(gt); // NOLINT(bugprone-sizeof-expression)
2732 char buf[1 + sizeof_ptr * 2];
2733 char* b = buf;
2734 *b++ = ':';
2735 for (size_t i = 0; i < sizeof_ptr; ++i) {
2736 unsigned char const c = reinterpret_cast<unsigned char const*>(&gt)[i];
2737 *b++ = hexDigits[(c & 0xf0) >> 4];
2738 *b++ = hexDigits[(c & 0x0f)];
2739 }
2740 std::string id(buf, sizeof(buf));
2741 // We internally index pointers to non-const generator targets
2742 // but our callers only have pointers to const generator targets.
2743 // They will give up non-const privileges when looking up anyway.
2744 this->GeneratorTargetSearchIndex[id] = const_cast<cmGeneratorTarget*>(gt);
2745 return id;
2746}
2747
2748void cmGlobalGenerator::IndexMakefile(cmMakefile* mf)
2749{

Callers 1

AddObjectEntriesFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected