summaryrefslogtreecommitdiffstats
path: root/Help
diff options
context:
space:
mode:
authorAlex Opie <alex@opie.nz>2024-06-01 03:46:48 (GMT)
committerBrad King <brad.king@kitware.com>2024-06-03 15:28:49 (GMT)
commit0f4d3664a94c96a131e1a4aec0698ed7f5f92521 (patch)
tree88923a2cb0a4dba2af81761769a4673590b17ebc /Help
parent140766867b2c8f8dff0e4d0d73e481b6944b5284 (diff)
downloadCMake-0f4d3664a94c96a131e1a4aec0698ed7f5f92521.zip
CMake-0f4d3664a94c96a131e1a4aec0698ed7f5f92521.tar.gz
CMake-0f4d3664a94c96a131e1a4aec0698ed7f5f92521.tar.bz2
CPack/NuGet: Build dependencies in groups
This allows particular frameworks to be targeted by particular dependencies, and for empty dependency groups to satisfy NuGet's framework-matching requirements.
Diffstat (limited to 'Help')
-rw-r--r--Help/cpack_gen/nuget.rst77
-rw-r--r--Help/release/dev/cpack-nuget-dependency-groups.rst7
2 files changed, 81 insertions, 3 deletions
diff --git a/Help/cpack_gen/nuget.rst b/Help/cpack_gen/nuget.rst
index 8ee2816..ad3ec9f 100644
--- a/Help/cpack_gen/nuget.rst
+++ b/Help/cpack_gen/nuget.rst
@@ -233,7 +233,7 @@ List of CPack NuGet generator specific variables:
.. variable:: CPACK_NUGET_PACKAGE_DEPENDENCIES
CPACK_NUGET_<compName>_PACKAGE_DEPENDENCIES
- A list of package dependencies.
+ A list of default (not framework-specific) package dependencies.
:Mandatory: No
:Default: None
@@ -242,8 +242,44 @@ List of CPack NuGet generator specific variables:
CPACK_NUGET_<compName>_PACKAGE_DEPENDENCIES_<dependency>_VERSION
A `version specification`_ for the particular dependency, where
- ``<dependency>`` is an item of the dependency list (see above)
- transformed with :command:`string(MAKE_C_IDENTIFIER)` command.
+ ``<dependency>`` is an item of the dependency list (see above).
+
+ :Mandatory: No
+ :Default: None
+
+.. variable:: CPACK_NUGET_PACKAGE_TFMS
+ CPACK_NUGET_<compName>_PACKAGE_TFMS
+
+ .. versionadded:: 3.30
+
+ A list of Target Framework Monikers (TFMs) for the package, e.g., "net47;netcoreapp21".
+ For each of these TFMs a `dependency group`_ will be generated in the dependencies block of the NuGet
+ package. Framework-specific dependencies can be added to these groups with the TFM
+ dependency lists (see below).
+
+ This variable is particularly useful for fixing warnings `NU5128`_.
+
+ :Mandatory: No
+ :Default: None
+
+.. variable:: CPACK_NUGET_PACKAGE_DEPENDENCIES_<tfm>
+ CPACK_NUGET_<compName>_PACKAGE_DEPENDENCIES_<tfm>
+
+ .. versionadded:: 3.30
+
+ A list of package dependencies that apply specifically to the ``<tfm>`` framework, where ``<tfm>``
+ is an item from the TFMs list (see above).
+
+ :Mandatory: No
+ :Default: None
+
+.. variable:: CPACK_NUGET_PACKAGE_DEPENDENCIES_<tfm>_<dependency>_VERSION
+ CPACK_NUGET_<compName>_PACKAGE_DEPENDENCIES_<tfm>_<dependency>_VERSION
+
+ .. versionadded:: 3.30
+
+ A `version specification`_ for the particular framework-specific dependency, where
+ ``<dependency>`` is an item of the ``<tfm>``-specific dependency list (see above).
:Mandatory: No
:Default: None
@@ -256,9 +292,44 @@ List of CPack NuGet generator specific variables:
:Default: ``OFF``
+Example usage
+^^^^^^^^^^^^^
+
+.. code-block:: cmake
+
+ set(CPACK_GENERATOR NuGet)
+ # Set up package metadata
+ set(CPACK_PACKAGE_NAME SamplePackage)
+ set(CPACK_PACKAGE_VERSION "1.0.0") # Why doesn't this pick up the version from the project?
+ set(CPACK_PACKAGE_VENDOR "Example Inc")
+ set(CPACK_NUGET_PACKAGE_OWNERS "Example Inc")
+ set(CPACK_PACKAGE_DESCRIPTION "A .NET wrapper around the foobar library for frobbling bratchens")
+ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A .NET wrapper around the foobar library for frobbling bratchens")
+ set(CPACK_PACKAGE_HOMEPAGE_URL "https://www.example.com")
+ set(CPACK_NUGET_PACKAGE_REPOSITORY_URL "https://github.com/example/libfoobar.git")
+ set(CPACK_NUGET_PACKAGE_REPOSITORY_TYPE git)
+ set(CPACK_NUGET_PACKAGE_LICENSE_EXPRESSION "MIT")
+ # Set up dependencies
+ set(CPACK_NUGET_PACKAGE_TFMS "net4;net6.0")
+ set(CPACK_NUGET_PACKAGE_DEPENDENCIES_net4 "Foo;Bar")
+ # NB: If a version number is omitted, the dependency will not be created
+ set(CPACK_NUGET_PACKAGE_DEPENDENCIES_net4_Foo_VERSION "1.23")
+ set(CPACK_NUGET_PACKAGE_DEPENDENCIES_net4_Bar_VERSION "4.3.2")
+ # NB: General dependencies (not framework-specific) go in this variable
+ set(CPACK_NUGET_PACKAGE_DEPENDENCIES "Baz")
+ set(CPACK_NUGET_PACKAGE_DEPENDENCIES_Baz_VERSION "9.8.6")
+ # NB: Since "net6.0" was listed but no dependencies have been specified, an empty group
+ # will be added to the nuspec file for this framework. This can be used to address `NU5128`_.
+
+ include(CPack)
+
+
+
.. _nuget.org: https://www.nuget.org
.. _version specification: https://learn.microsoft.com/en-us/nuget/concepts/package-versioning#version-ranges
.. _SPDX license identifier: https://spdx.org/licenses
.. _SPDX specification: https://spdx.github.io/spdx-spec/v2.3/SPDX-license-expressions
+.. _dependency group: https://learn.microsoft.com/en-us/nuget/reference/nuspec#dependency-groups
+.. _NU5128: https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu5128
.. NuGet spec docs https://docs.microsoft.com/en-us/nuget/reference/nuspec
diff --git a/Help/release/dev/cpack-nuget-dependency-groups.rst b/Help/release/dev/cpack-nuget-dependency-groups.rst
new file mode 100644
index 0000000..37944f7
--- /dev/null
+++ b/Help/release/dev/cpack-nuget-dependency-groups.rst
@@ -0,0 +1,7 @@
+cpack-nuget-dependency-groups
+-----------------------------
+
+* The :cpack_gen:`CPack NuGet Generator` can now generate dependency groups
+ for framework-specific dependencies. The :variable:`CPACK_NUGET_PACKAGE_TFMS`
+ was added to specify a list of framework TFMs for which groups should be
+ generated.