| 441 | } |
| 442 | |
| 443 | cm::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 |
| 480 | std::string FindMSYSTEM_PREFIX(std::vector<std::string> prefixes) |
no test coverage detected
searching dependent graphs…