mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-07 14:50:15 -05:00
Merge topic 'cps-read-default-license'
1d4fb4afa9 find_package: Respect CPS default_license
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !10897
This commit is contained in:
@@ -479,6 +479,14 @@ std::unique_ptr<cmPackageInfoReader> cmPackageInfoReader::Read(
|
||||
}
|
||||
}
|
||||
|
||||
// Check for a default license.
|
||||
Json::Value const& defaultLicense = reader->Data["default_license"];
|
||||
if (!defaultLicense.isNull()) {
|
||||
reader->DefaultLicense = defaultLicense.asString();
|
||||
} else if (parent) {
|
||||
reader->DefaultLicense = parent->DefaultLicense;
|
||||
}
|
||||
|
||||
return reader;
|
||||
}
|
||||
|
||||
@@ -582,12 +590,14 @@ void cmPackageInfoReader::SetImportProperty(cmTarget* target,
|
||||
}
|
||||
}
|
||||
|
||||
void cmPackageInfoReader::SetMetaProperty(cmTarget* target,
|
||||
cm::string_view property,
|
||||
Json::Value const& value) const
|
||||
void cmPackageInfoReader::SetMetaProperty(
|
||||
cmTarget* target, cm::string_view property, Json::Value const& value,
|
||||
std::string const& defaultValue) const
|
||||
{
|
||||
if (!value.isNull()) {
|
||||
target->SetProperty(property.data(), value.asString());
|
||||
} else if (!defaultValue.empty()) {
|
||||
target->SetProperty(property.data(), defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -671,7 +681,8 @@ void cmPackageInfoReader::SetTargetProperties(
|
||||
|
||||
// Add other information.
|
||||
if (configuration.empty()) {
|
||||
this->SetMetaProperty(target, "SPDX_LICENSE"_s, data["license"]);
|
||||
this->SetMetaProperty(target, "SPDX_LICENSE"_s, data["license"],
|
||||
this->DefaultLicense);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,8 @@ private:
|
||||
cm::string_view configuration,
|
||||
Json::Value const& value) const;
|
||||
void SetMetaProperty(cmTarget* target, cm::string_view property,
|
||||
Json::Value const& value) const;
|
||||
Json::Value const& value,
|
||||
std::string const& defaultValue = {}) const;
|
||||
|
||||
std::string ResolvePath(std::string path) const;
|
||||
|
||||
@@ -108,4 +109,5 @@ private:
|
||||
|
||||
std::map<std::string, cmTarget*> ComponentTargets;
|
||||
std::vector<std::string> DefaultConfigurations;
|
||||
std::string DefaultLicense;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user