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

Method CheckVersion

Source/cmExportPackageInfoGenerator.cxx:100–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100bool cmExportPackageInfoGenerator::CheckVersion() const
101{
102 if (!this->PackageVersion.empty()) {
103 std::string const& schema = [&] {
104 if (this->PackageVersionSchema.empty()) {
105 return std::string{ "simple" };
106 }
107 return cmSystemTools::LowerCase(this->PackageVersionSchema);
108 }();
109 bool (*validator)(std::string const&) = nullptr;
110 bool result = true;
111
112 if (schema == "simple"_s) {
113 validator = &CheckSimpleVersion;
114 } else if (schema == "dpkg"_s || schema == "rpm"_s ||
115 schema == "pep440"_s) {
116 // TODO
117 // We don't validate these at this time. Eventually, we would like to do
118 // so, but will probably need to introduce a policy whether to treat
119 // invalid versions as an error.
120 } else if (schema != "custom"_s) {
121 this->IssueMessage(MessageType::AUTHOR_WARNING,
122 cmStrCat("Package \""_s, this->GetPackageName(),
123 "\" uses unrecognized version schema \""_s,
124 this->PackageVersionSchema, "\"."_s));
125 }
126
127 if (validator) {
128 if (!(*validator)(this->PackageVersion)) {
129 this->ReportError(cmStrCat("Package \""_s, this->GetPackageName(),
130 "\" version \""_s, this->PackageVersion,
131 "\" does not conform to the \""_s, schema,
132 "\" schema."_s));
133 result = false;
134 }
135 if (!this->PackageVersionCompat.empty() &&
136 !(*validator)(this->PackageVersionCompat)) {
137 this->ReportError(
138 cmStrCat("Package \""_s, this->GetPackageName(),
139 "\" compatibility version \""_s, this->PackageVersionCompat,
140 "\" does not conform to the \""_s, schema, "\" schema."_s));
141 result = false;
142 }
143 }
144
145 return result;
146 }
147
148 return true;
149}
150
151bool cmExportPackageInfoGenerator::CheckDefaultTargets() const
152{

Callers 1

CheckPackageMethod · 0.95

Calls 5

GetPackageNameMethod · 0.80
cmStrCatFunction · 0.70
emptyMethod · 0.45
IssueMessageMethod · 0.45
ReportErrorMethod · 0.45

Tested by

no test coverage detected