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

Function GetWindowsValue

Source/cmCMakeHostSystemInformationCommand.cxx:560–610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

558}
559
560cm::optional<std::string> GetWindowsValue(cmExecutionStatus& status,
561 std::string const& key)
562{
563 auto* const gg = status.GetMakefile().GetGlobalGenerator();
564 for (auto vs : { 15, 16, 17, 18 }) {
565 if (key == cmStrCat("VS_"_s, vs, "_DIR"_s)) {
566 std::string value;
567 // If generating for the VS nn IDE, use the same instance.
568
569 if (cmHasPrefix(gg->GetName(), cmStrCat("Visual Studio "_s, vs, ' '))) {
570 cmGlobalVisualStudioVersionedGenerator* vsNNgen =
571 static_cast<cmGlobalVisualStudioVersionedGenerator*>(gg);
572 if (vsNNgen->GetVSInstance(value)) {
573 return value;
574 }
575 }
576
577 // Otherwise, find a VS nn instance ourselves.
578 cmVSSetupAPIHelper vsSetupAPIHelper(vs);
579 if (vsSetupAPIHelper.GetVSInstanceInfo(value)) {
580 cmSystemTools::ConvertToUnixSlashes(value);
581 }
582 return value;
583 }
584 }
585
586 if (key == "VS_MSBUILD_COMMAND"_s && gg->IsVisualStudioAtLeast10()) {
587 cmGlobalVisualStudio10Generator* vs10gen =
588 static_cast<cmGlobalVisualStudio10Generator*>(gg);
589 return vs10gen->FindMSBuildCommandEarly(&status.GetMakefile());
590 }
591
592 if (key == "MSYSTEM_PREFIX") {
593 // MSYSTEM_PREFIX is meaningful only under a MSYSTEM environment.
594 cm::optional<std::string> ms = cmSystemTools::GetEnvVar("MSYSTEM");
595 if (!ms || ms->empty()) {
596 return std::string();
597 }
598 // Prefer the MSYSTEM_PREFIX environment variable.
599 if (cm::optional<std::string> msp =
600 cmSystemTools::GetEnvVar("MSYSTEM_PREFIX")) {
601 cmSystemTools::ConvertToUnixSlashes(*msp);
602 if (cmSystemTools::FileIsDirectory(*msp)) {
603 return msp;
604 }
605 }
606 // Fall back to known distribution layouts.
607 return FallbackMSYSTEM_PREFIX(*ms);
608 }
609 return {};
610}
611#endif
612
613cm::optional<std::string> GetValueChained()

Callers 1

Calls 11

cmHasPrefixFunction · 0.85
FallbackMSYSTEM_PREFIXFunction · 0.85
GetVSInstanceMethod · 0.80
GetVSInstanceInfoMethod · 0.80
cmStrCatFunction · 0.70
GetGlobalGeneratorMethod · 0.45
GetMakefileMethod · 0.45
GetNameMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…