project: Add SPDX_LICENSE argument

Add an argument to the `project` command to allow specifying a license
for a project as a whole. This is in addition to specifying licenses on
individual targets, and will be used to set the license(s) on exported
packages.

Also, move listing of `COMPAT_VERSION` variables to follow
lexicographical order.
This commit is contained in:
Matthew Woehlke
2025-06-13 12:07:02 -04:00
parent f0b419c473
commit fba540daf6
18 changed files with 122 additions and 8 deletions
+5 -2
View File
@@ -38,6 +38,7 @@ struct ProjectArguments : ArgumentParser::ParseResult
cm::optional<std::string> ProjectName;
cm::optional<std::string> Version;
cm::optional<std::string> CompatVersion;
cm::optional<std::string> License;
cm::optional<std::string> Description;
cm::optional<std::string> HomepageURL;
cm::optional<ArgumentParser::MaybeEmpty<std::vector<std::string>>> Languages;
@@ -73,11 +74,12 @@ bool cmProjectCommand(std::vector<std::string> const& args,
.Bind("LANGUAGES"_s, prArgs.Languages);
cmMakefile& mf = status.GetMakefile();
bool enableCompatVersion = cmExperimental::HasSupportEnabled(
bool enablePackageInfo = cmExperimental::HasSupportEnabled(
mf, cmExperimental::Feature::ExportPackageInfo);
if (enableCompatVersion) {
if (enablePackageInfo) {
parser.Bind("COMPAT_VERSION"_s, prArgs.CompatVersion);
parser.Bind("SPDX_LICENSE"_s, prArgs.License);
}
parser.Parse(args, &unparsedArgs, 0);
@@ -263,6 +265,7 @@ bool cmProjectCommand(std::vector<std::string> const& args,
createVariables("VERSION_PATCH"_s, version_components[2]);
createVariables("VERSION_TWEAK"_s, version_components[3]);
createVariables("COMPAT_VERSION"_s, prArgs.CompatVersion.value_or(""));
createVariables("SPDX_LICENSE"_s, prArgs.License.value_or(""));
createVariables("DESCRIPTION"_s, prArgs.Description.value_or(""));
createVariables("HOMEPAGE_URL"_s, prArgs.HomepageURL.value_or(""));