| 550 | |
| 551 | #ifndef CMAKE_BOOTSTRAP |
| 552 | void cmFindCommonDebugState::WriteSearchVariables(cmConfigureLog& log, |
| 553 | cmMakefile const& mf) const |
| 554 | { |
| 555 | auto WriteString = [&log, &mf](std::string const& name) { |
| 556 | if (cmValue value = mf.GetDefinition(name)) { |
| 557 | log.WriteValue(name, *value); |
| 558 | } |
| 559 | }; |
| 560 | auto WriteCMakeList = [&log, &mf](std::string const& name) { |
| 561 | if (cmValue value = mf.GetDefinition(name)) { |
| 562 | cmList values{ *value }; |
| 563 | if (!values.empty()) { |
| 564 | log.WriteValue(name, values); |
| 565 | } |
| 566 | } |
| 567 | }; |
| 568 | auto WriteEnvList = [&log](std::string const& name) { |
| 569 | if (auto value = cmSystemTools::GetEnvVar(name)) { |
| 570 | auto values = cmSystemTools::SplitEnvPath(*value); |
| 571 | if (!values.empty()) { |
| 572 | log.WriteValue(cmStrCat("ENV{", name, '}'), values); |
| 573 | } |
| 574 | } |
| 575 | }; |
| 576 | |
| 577 | auto const* fc = this->FindCommand; |
| 578 | log.BeginObject("search_context"_s); |
| 579 | auto const& packageRootStack = mf.FindPackageRootPathStack; |
| 580 | if (!packageRootStack.empty()) { |
| 581 | bool havePaths = |
| 582 | std::any_of(packageRootStack.begin(), packageRootStack.end(), |
| 583 | [](std::vector<std::string> const& entry) -> bool { |
| 584 | return !entry.empty(); |
| 585 | }); |
| 586 | if (havePaths) { |
| 587 | log.BeginObject("package_stack"); |
| 588 | log.BeginArray(); |
| 589 | for (auto const& pkgPaths : cmReverseRange(packageRootStack)) { |
| 590 | if (!pkgPaths.empty()) { |
| 591 | log.NextArrayElement(); |
| 592 | log.WriteValue("package_paths", pkgPaths); |
| 593 | } |
| 594 | } |
| 595 | log.EndArray(); |
| 596 | log.EndObject(); |
| 597 | } |
| 598 | } |
| 599 | auto cmakePathVar = cmStrCat("CMAKE_", fc->CMakePathName, "_PATH"); |
| 600 | WriteCMakeList(cmakePathVar); |
| 601 | WriteCMakeList("CMAKE_PREFIX_PATH"); |
| 602 | if (fc->CMakePathName == "PROGRAM"_s) { |
| 603 | WriteCMakeList("CMAKE_APPBUNDLE_PATH"); |
| 604 | } else { |
| 605 | WriteCMakeList("CMAKE_FRAMEWORK_PATH"); |
| 606 | } |
| 607 | // Same as above, but ask the environment instead. |
| 608 | WriteEnvList(cmakePathVar); |
| 609 | WriteEnvList("CMAKE_PREFIX_PATH"); |
no test coverage detected