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

Function GetDistribValue

Source/cmCMakeHostSystemInformationCommand.cxx:443–477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

441}
442
443cm::optional<std::string> GetDistribValue(cmExecutionStatus& status,
444 std::string const& key,
445 std::string const& variable)
446{
447 auto const prefix = "DISTRIB_"_s;
448 if (!cmHasPrefix(key, prefix)) {
449 return {};
450 }
451
452 static std::map<std::string, std::string> const s_os_release =
453 GetOSReleaseVariables(status);
454
455 auto& makefile = status.GetMakefile();
456
457 std::string const subkey =
458 key.substr(prefix.size(), key.size() - prefix.size());
459 if (subkey == "INFO"_s) {
460 std::string vars;
461 for (auto const& kv : s_os_release) {
462 auto cmake_var_name = cmStrCat(variable, '_', kv.first);
463 vars += DELIM[!vars.empty()] + cmake_var_name;
464 makefile.AddDefinition(cmake_var_name, kv.second);
465 }
466 return cm::optional<std::string>(std::move(vars));
467 }
468
469 // Query individual variable
470 auto const it = s_os_release.find(subkey);
471 if (it != s_os_release.cend()) {
472 return it->second;
473 }
474
475 // NOTE Empty string means requested variable not set
476 return std::string{};
477}
478
479#ifdef _WIN32
480std::string FindMSYSTEM_PREFIX(std::vector<std::string> prefixes)

Callers 1

Calls 11

cmHasPrefixFunction · 0.85
GetOSReleaseVariablesFunction · 0.85
moveFunction · 0.85
cendMethod · 0.80
cmStrCatFunction · 0.70
GetMakefileMethod · 0.45
substrMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
AddDefinitionMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…