summaryrefslogtreecommitdiffstats
path: root/Modules/Internal
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-11-06 13:01:33 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-11-06 13:01:41 (GMT)
commit02d6c98210bcb975b61a9aadab14dbf593014d6a (patch)
tree86215ecb740dd2416124c328ba6d67eafa0ddb05 /Modules/Internal
parent3a69c7779a58d3baa4494c7b414ecec915125c9e (diff)
parent41ae7c4e5161427eb46319231dcb475386862760 (diff)
downloadCMake-02d6c98210bcb975b61a9aadab14dbf593014d6a.zip
CMake-02d6c98210bcb975b61a9aadab14dbf593014d6a.tar.gz
CMake-02d6c98210bcb975b61a9aadab14dbf593014d6a.tar.bz2
Merge topic 'cpack-nuget'
41ae7c4e51 CPack/NuGet: Add settings for the license, icon, and language Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5415
Diffstat (limited to 'Modules/Internal')
-rw-r--r--Modules/Internal/CPack/CPack.NuGet.nuspec.in5
-rw-r--r--Modules/Internal/CPack/CPackNuGet.cmake78
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)