| 1434 | } |
| 1435 | |
| 1436 | void cmFindPackageCommand::SetModuleVariables() |
| 1437 | { |
| 1438 | this->AddFindDefinition("CMAKE_FIND_PACKAGE_NAME", this->Name); |
| 1439 | |
| 1440 | // Nested find calls are not automatically required. |
| 1441 | this->AddFindDefinition("CMAKE_FIND_REQUIRED", ""_s); |
| 1442 | |
| 1443 | // Store the list of components and associated variable definitions. |
| 1444 | std::string components_var = this->Name + "_FIND_COMPONENTS"; |
| 1445 | this->AddFindDefinition(components_var, this->Components); |
| 1446 | for (auto const& component : this->OptionalComponents) { |
| 1447 | this->AddFindDefinition( |
| 1448 | cmStrCat(this->Name, "_FIND_REQUIRED_"_s, component), "0"_s); |
| 1449 | } |
| 1450 | for (auto const& component : this->RequiredComponents) { |
| 1451 | this->AddFindDefinition( |
| 1452 | cmStrCat(this->Name, "_FIND_REQUIRED_"_s, component), "1"_s); |
| 1453 | } |
| 1454 | |
| 1455 | if (this->Quiet) { |
| 1456 | // Tell the module that is about to be read that it should find |
| 1457 | // quietly. |
| 1458 | std::string quietly = cmStrCat(this->Name, "_FIND_QUIETLY"); |
| 1459 | this->AddFindDefinition(quietly, "1"_s); |
| 1460 | } |
| 1461 | |
| 1462 | if (this->IsRequired()) { |
| 1463 | // Tell the module that is about to be read that it should report |
| 1464 | // a fatal error if the package is not found. |
| 1465 | std::string req = cmStrCat(this->Name, "_FIND_REQUIRED"); |
| 1466 | this->AddFindDefinition(req, "1"_s); |
| 1467 | } |
| 1468 | |
| 1469 | if (!this->VersionComplete.empty()) { |
| 1470 | std::string req = cmStrCat(this->Name, "_FIND_VERSION_COMPLETE"); |
| 1471 | this->AddFindDefinition(req, this->VersionComplete); |
| 1472 | } |
| 1473 | |
| 1474 | // Tell the module that is about to be read what version of the |
| 1475 | // package has been requested. |
| 1476 | auto addDefinition = [this](std::string const& variable, |
| 1477 | cm::string_view value) { |
| 1478 | this->AddFindDefinition(variable, value); |
| 1479 | }; |
| 1480 | |
| 1481 | if (!this->Version.empty()) { |
| 1482 | auto prefix = cmStrCat(this->Name, "_FIND_VERSION"_s); |
| 1483 | this->SetVersionVariables(addDefinition, prefix, this->Version, |
| 1484 | this->VersionCount, this->VersionMajor, |
| 1485 | this->VersionMinor, this->VersionPatch, |
| 1486 | this->VersionTweak); |
| 1487 | |
| 1488 | // Tell the module whether an exact version has been requested. |
| 1489 | auto exact = cmStrCat(this->Name, "_FIND_VERSION_EXACT"); |
| 1490 | this->AddFindDefinition(exact, this->VersionExact ? "1"_s : "0"_s); |
| 1491 | } |
| 1492 | if (!this->VersionRange.empty()) { |
| 1493 | auto prefix = cmStrCat(this->Name, "_FIND_VERSION_MIN"_s); |
no test coverage detected