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

Function ImportPackage

Source/cmCMakePkgConfigCommand.cxx:554–596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

552}
553
554cm::optional<cmPkgConfigResult> ImportPackage(
555 std::string const& package, cm::optional<std::string> version,
556 ImportEnv& imEnv, cmPkgConfigEnv& pcEnv)
557{
558 auto result = ReadPackage(package, imEnv, pcEnv);
559
560 if (!result) {
561 if (!imEnv.err) {
562 warn_or_error(cmStrCat("Could not find pkg-config: '", package, '\''),
563 imEnv);
564 }
565 return result;
566 }
567
568 if (imEnv.exact) {
569 std::string ver;
570
571 if (version) {
572 ver = cmPkgConfigResolver::ParseVersion(*version).Version;
573 }
574
575 if (ver != result->Version()) {
576 warn_or_error(
577 cmStrCat("Package '", package, "' version '", result->Version(),
578 "' does not meet exact version requirement '", ver, '\''),
579 imEnv);
580 return {};
581 }
582
583 } else if (version) {
584 auto rv = cmPkgConfigResolver::ParseVersion(*version);
585 if (!cmPkgConfigResolver::CheckVersion(rv, result->Version())) {
586 warn_or_error(
587 cmStrCat("Package '", package, "' version '", result->Version(),
588 "' does not meet version requirement '", *version, '\''),
589 imEnv);
590 return {};
591 }
592 }
593
594 result->env = &pcEnv;
595 return result;
596}
597
598struct pkgStackEntry
599{

Callers 2

HandleExtractCommandFunction · 0.85
PopulatePCTargetFunction · 0.85

Calls 7

ReadPackageFunction · 0.85
warn_or_errorFunction · 0.85
VersionMethod · 0.80
cmStrCatFunction · 0.70
beginMethod · 0.45
endMethod · 0.45
stringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…