diff options
author | Bob Apthorpe <bob.apthorpe@gmail.com> | 2020-10-22 23:01:30 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-11-05 15:49:25 (GMT) |
commit | 41ae7c4e5161427eb46319231dcb475386862760 (patch) | |
tree | fc729cdcc9b5ac1a03bb2a12f3d831389b68103b /Modules/Internal | |
parent | 3a82ff6a11d643c4a5959f65ea538a3b60784a16 (diff) | |
download | CMake-41ae7c4e5161427eb46319231dcb475386862760.zip CMake-41ae7c4e5161427eb46319231dcb475386862760.tar.gz CMake-41ae7c4e5161427eb46319231dcb475386862760.tar.bz2 |
CPack/NuGet: Add settings for the license, icon, and language
Also update the XML Schema.
Fixes: #21348
Diffstat (limited to 'Modules/Internal')
-rw-r--r-- | Modules/Internal/CPack/CPack.NuGet.nuspec.in | 5 | ||||
-rw-r--r-- | Modules/Internal/CPack/CPackNuGet.cmake | 78 |
2 files changed, 78 insertions, 5 deletions
diff --git a/Modules/Internal/CPack/CPack.NuGet.nuspec.in b/Modules/Internal/CPack/CPack.NuGet.nuspec.in index b7beb5d..d89d69f 100644 --- a/Modules/Internal/CPack/CPack.NuGet.nuspec.in +++ b/Modules/Internal/CPack/CPack.NuGet.nuspec.in @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> +<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <metadata> <!-- Required elements--> <id>@CPACK_NUGET_PACKAGE_NAME@</id> @@ -12,11 +12,14 @@ @_CPACK_NUGET_OWNERS_TAG@ @_CPACK_NUGET_PROJECTURL_TAG@ @_CPACK_NUGET_LICENSEURL_TAG@ + @_CPACK_NUGET_LICENSE_TAG@ @_CPACK_NUGET_ICONURL_TAG@ + @_CPACK_NUGET_ICON_TAG@ @_CPACK_NUGET_REQUIRELICENSEACCEPTANCE_TAG@ @_CPACK_NUGET_SUMMARY_TAG@ @_CPACK_NUGET_RELEASENOTES_TAG@ @_CPACK_NUGET_COPYRIGHT_TAG@ + @_CPACK_NUGET_LANGUAGE_TAG@ @_CPACK_NUGET_TAGS_TAG@ @_CPACK_NUGET_DEPENDENCIES_TAG@ </metadata> diff --git a/Modules/Internal/CPack/CPackNuGet.cmake b/Modules/Internal/CPack/CPackNuGet.cmake index 20eed2e..56bbffd 100644 --- a/Modules/Internal/CPack/CPackNuGet.cmake +++ b/Modules/Internal/CPack/CPackNuGet.cmake @@ -107,21 +107,44 @@ endfunction() function(_cpack_nuget_variable_fallback_and_wrap_into_element ELEMENT NUGET_VAR_NAME) set(_options) set(_one_value_args) - set(_multi_value_args FALLBACK_VARS) - cmake_parse_arguments(PARSE_ARGV 0 _args "${_options}" "${_one_value_args}" "${_multi_value_args}") + set(_multi_value_args FALLBACK_VARS ATTRIBUTES) + cmake_parse_arguments(PARSE_ARGV 2 _args "${_options}" "${_one_value_args}" "${_multi_value_args}") + + if(_args_ATTRIBUTES) + list(JOIN _args_ATTRIBUTES " " _attributes) + string(PREPEND _attributes " ") + endif() _cpack_nuget_variable_fallback(_value ${NUGET_VAR_NAME} ${ARGN} USE_CDATA) + string(TOUPPER "${ELEMENT}" _ELEMENT_UP) if(_value) - string(TOUPPER "${ELEMENT}" _ELEMENT_UP) set( _CPACK_NUGET_${_ELEMENT_UP}_TAG - "<${ELEMENT}>${_value}</${ELEMENT}>" + "<${ELEMENT}${_attributes}>${_value}</${ELEMENT}>" + PARENT_SCOPE + ) + elseif(_attributes) + set( + _CPACK_NUGET_${_ELEMENT_UP}_TAG + "<${ELEMENT}${_attributes} />" PARENT_SCOPE ) endif() endfunction() +# Warn of obsolete nuspec fields, referencing CMake variables and suggested +# replacement, if any +function(_cpack_nuget_deprecation_warning NUGET_ELEMENT VARNAME REPLACEMENT) + if(${VARNAME}) + if(REPLACEMENT) + message(DEPRECATION "nuspec element `${NUGET_ELEMENT}` is deprecated in NuGet; consider replacing `${VARNAME}` with `${REPLACEMENT}`") + else() + message(DEPRECATION "nuspec element `${NUGET_ELEMENT}` is deprecated in NuGet; consider removing `${VARNAME}`") + endif() + endif() +endfunction() + # Print some debug info _cpack_nuget_debug("---[CPack NuGet Input Variables]---") _cpack_nuget_debug_var(CPACK_PACKAGE_NAME) @@ -168,6 +191,21 @@ function(_cpack_nuget_render_spec) set(CPACK_NUGET_PACKAGE_NAME "${CPACK_PACKAGE_NAME}") endif() + # Warn about deprecated nuspec elements; warnings only display if + # variable is set + # Note that while nuspec's "summary" element is deprecated, there + # is no suggested replacement so (for now) no deprecation warning + # is shown for `CPACK_NUGET_*_DESCRIPTION_SUMMARY` + _cpack_nuget_deprecation_warning("licenseUrl" CPACK_NUGET_PACKAGE_LICENSEURL + "CPACK_NUGET_PACKAGE_LICENSE_FILE_NAME or CPACK_NUGET_PACKAGE_LICENSE_EXPRESSION") + _cpack_nuget_deprecation_warning("licenseUrl" CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT}_LICENSEURL + "CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT}_LICENSE_FILE_NAME or CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT}_LICENSE_EXPRESSION") + _cpack_nuget_deprecation_warning("iconUrl" CPACK_NUGET_PACKAGE_ICONURL + "CPACK_NUGET_PACKAGE_ICON") + _cpack_nuget_deprecation_warning("iconUrl" CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT}_ICONURL + "CPACK_NUGET_${CPACK_NUGET_PACKAGE_COMPONENT}_ICON") + + # Set nuspec fields _cpack_nuget_variable_fallback( CPACK_NUGET_PACKAGE_VERSION VERSION FALLBACK_VARS @@ -207,8 +245,35 @@ function(_cpack_nuget_render_spec) FALLBACK_VARS CPACK_PACKAGE_HOMEPAGE_URL ) + + # "licenseUrl" is deprecated in favor of "license" _cpack_nuget_variable_fallback_and_wrap_into_element(licenseUrl LICENSEURL) + + # "iconUrl" is deprecated in favor of "icon" _cpack_nuget_variable_fallback_and_wrap_into_element(iconUrl ICONURL) + + # "license" takes a "type" attribute of either "file" or "expression" + # "file" refers to a file path of a .txt or .md file relative to the installation root + # "expression" refers to simple or compound expression of license identifiers + # listed at https://spdx.org/licenses/ + # Note that only one of CPACK_NUGET_PACKAGE_LICENSE_FILE_NAME and + # CPACK_NUGET_PACKAGE_LICENSE_EXPRESSION may be specified. If both are specified, + # CPACK_NUGET_PACKAGE_LICENSE_FILE_NAME takes precedence and CPACK_NUGET_PACKAGE_LICENSE_EXPRESSION is ignored. + if(CPACK_NUGET_PACKAGE_LICENSE_FILE_NAME) + _cpack_nuget_variable_fallback_and_wrap_into_element( + license LICENSE_FILE_NAME + ATTRIBUTES [[type="file"]] + ) + elseif(CPACK_NUGET_PACKAGE_LICENSE_EXPRESSION) + _cpack_nuget_variable_fallback_and_wrap_into_element( + license LICENSE_EXPRESSION + ATTRIBUTES [[type="expression"]] + ) + endif() + + # "icon" refers to a file path relative to the installation root + _cpack_nuget_variable_fallback_and_wrap_into_element(icon ICON) + # "summary" is deprecated in favor of "description" _cpack_nuget_variable_fallback_and_wrap_into_element( summary DESCRIPTION_SUMMARY FALLBACK_VARS @@ -222,7 +287,12 @@ function(_cpack_nuget_render_spec) endif() _cpack_nuget_variable_fallback_and_wrap_into_element(releaseNotes RELEASE_NOTES) _cpack_nuget_variable_fallback_and_wrap_into_element(copyright COPYRIGHT) + # "language" is a locale identifier such as "en_CA" + _cpack_nuget_variable_fallback_and_wrap_into_element(language LANGUAGE) _cpack_nuget_variable_fallback_and_wrap_into_element(tags TAGS LIST_GLUE " ") + # "repository" holds repository metadata consisting of four optional + # attributes: "type", "url", "branch", and "commit". While all fields are + # considered optional, they are not independent. Currently unsupported. # Handle dependencies _cpack_nuget_variable_fallback(_deps DEPENDENCIES) |