Help: Improve documentation of project SPDX_LICENSE

Currently, CMake allows specifying a license (`SPDX_LICENSE`) for both
projects and targets, which is largely motivated by CPS export. The
design of CPS is geared toward components (targets) only expressing an
explicit license when that component's license differs from the license
that applies to the package as a whole (or, at least, the license
generally used by the package's software components). Accordingly, the
project license is not used to initialize the `SPDX_LICENSE` target
property at export time. This, however, was not documented previously.

Add a note explaining this to the `SPDX_LICENSE` option of the `project`
command.

Fixes: #27295
This commit is contained in:
Matthew Woehlke
2025-10-27 10:38:40 -04:00
parent b27be83f4a
commit ebf0a359ad

View File

@@ -124,6 +124,17 @@ The options are:
See the :prop_tgt:`SPDX_LICENSE` property for specifying the license(s) on
individual software artifacts.
.. note::
The project license is *not* used to initialize the
:prop_tgt:`SPDX_LICENSE` property of individual targets. This allows the
package license and default component license, which are specified when
exporting package information, to be meaningful. Only |CPS| exports make
use of this information.
The project license *is* inherited as the package license in some cases.
Refer to the ``PROJECT`` option and related documentation of the
:command:`export` and :command:`install` commands for more information.
.. _SPDX: https://spdx.dev/
.. |SPDX| replace:: System Package Data Exchange
@@ -179,8 +190,6 @@ intended for use as default values in package metadata and documentation.
The :command:`export` and :command:`install` commands use these accordingly
when generating |CPS| package descriptions.
.. |CPS| replace:: Common Package Specification
.. _`Code Injection`:
Code Injection
@@ -249,3 +258,5 @@ call exists, CMake will issue a warning and pretend there is a
other commands whose behavior they may affect and for this reason the
``project()`` command will issue a warning if this order is not kept.
See also policy :policy:`CMP0000`.
.. |CPS| replace:: Common Package Specification