ECMCheckOutboundLicenseΒΆ

Assert that source file licenses are compatible with a desired outbound license of a compiled binary artifact (e.g., library, plugin or application).

This module provides the ecm_check_outbound_license function that generates unit tests for checking the compatibility of license statements. The license statements in all tested files are required to be added by using the SPDX marker SPDX-License-Identifier.

During the CMake configuration of the project, a temporary license bill of materials (BOM) in SPDX format is generated by calling the REUSE tool (see <https://reuse.software>). That BOM is parsed and license computations based on an internal compatibility matrix are performed.

Preconditions for using this module:
  • All tested input source files must contain the SPDX-License-Identifier tag.

  • Python3 must be available.

  • The REUSE tool must be available, which generates the bill-of-materials by running reuse spdx on the tested directory.

When this module is included, a SKIP_LICENSE_TESTS option is added (default OFF). Turning this option on skips the generation of license tests, which might be convenient if licenses shall not be tested in all build configurations.

ecm_check_outbound_license(LICENSES <outbound-licenses>
                           FILES <source-files>
                           [TEST_NAME <name>]
                           [WILL_FAIL])

This method adds a custom unit test to ensure the specified outbound license to be compatible with the specified license headers. Note that a convenient way is to use the CMake GLOB argument of the FILE function.

LICENSESList of one or multiple outbound license regarding which the compatibility of the source code files shall be tested.
Currently, the following values are supported (values are SPDX registry identifiers):
  • MIT

  • BSD-2-Clause

  • BSD-3-Clause

  • LGPL-2.0-only

  • LGPL-2.1-only

  • LGPL-3.0-only

  • GPL-2.0-only

  • GPL-3.0-only

FILES:List of source files that contain valid SPDX-License-Identifier markers.

The paths can be relative to the CMake file that generates the test case or be absolute paths.

TEST_NAMEOptional parameter that defines the name of the generated test case.

If no name is defined, the relative path to the test directory with appended license name is used. Every test has licensecheck_ as prefix.

WILL_FAILOptional parameter that inverts the test result. This parameter is usually only

used for tests of the module.

Since 5.75.0