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

Method WriteSearchVariables

Source/cmFindCommon.cxx:552–650  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

550
551#ifndef CMAKE_BOOTSTRAP
552void 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");

Callers 2

WriteEventMethod · 0.80
WriteEventMethod · 0.80

Calls 13

ExtraSearchVariablesMethod · 0.95
cmReverseRangeFunction · 0.85
WriteValueMethod · 0.80
NextArrayElementMethod · 0.80
cmStrCatFunction · 0.70
GetDefinitionMethod · 0.45
emptyMethod · 0.45
BeginObjectMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
BeginArrayMethod · 0.45
EndArrayMethod · 0.45

Tested by

no test coverage detected