mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
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.
42 lines
1.4 KiB
ReStructuredText
42 lines
1.4 KiB
ReStructuredText
CMAKE_PROJECT_SPDX_LICENSE
|
|
--------------------------
|
|
|
|
.. versionadded:: 4.2
|
|
|
|
.. note::
|
|
|
|
Experimental. Gated by ``CMAKE_EXPERIMENTAL_EXPORT_PACKAGE_INFO``.
|
|
|
|
The license(s) of the top level project.
|
|
|
|
This variable holds the license expression of the project as specified in the
|
|
top level CMakeLists.txt file by a :command:`project` command. In the event
|
|
that the top level CMakeLists.txt contains multiple :command:`project` calls,
|
|
the most recently called one from that top level CMakeLists.txt will determine
|
|
the value that ``CMAKE_PROJECT_SPDX_LICENSE`` contains. For example, consider
|
|
the following top level CMakeLists.txt:
|
|
|
|
.. code-block:: cmake
|
|
|
|
cmake_minimum_required(VERSION 4.2)
|
|
project(First SPDX_LICENSE "BSD-3-Clause")
|
|
project(Second SPDX_LICENSE "BSD-3-Clause AND CC-BY-SA-4.0")
|
|
add_subdirectory(sub)
|
|
project(Third SPDX_LICENSE "BSD-3-Clause AND CC0-1.0")
|
|
|
|
And ``sub/CMakeLists.txt`` with the following contents:
|
|
|
|
.. code-block:: cmake
|
|
|
|
project(SubProj SPDX_LICENSE Apache-2.0)
|
|
message("CMAKE_PROJECT_SPDX_LICENSE = ${CMAKE_PROJECT_SPDX_LICENSE}")
|
|
|
|
The most recently seen :command:`project` command from the top level
|
|
CMakeLists.txt would be ``project(Second ...)``, so this will print::
|
|
|
|
CMAKE_PROJECT_SPDX_LICENSE = BSD-3-Clause AND CC-BY-SA-4.0
|
|
|
|
To obtain the version from the most recent call to :command:`project` in
|
|
the current directory scope or above, see the :variable:`PROJECT_SPDX_LICENSE`
|
|
variable.
|