88 Per-module SPDX metadata is declared in each module's itk-module.cmake via
99 the itk_module() macro arguments:
1010 SPDX_LICENSE - SPDX license identifier (e.g. "Apache-2.0")
11+ SPDX_VERSION - Version of the vendored dependency
1112 SPDX_DOWNLOAD_LOCATION - URL for the upstream source
1213 SPDX_COPYRIGHT - Copyright text
1314 SPDX_CUSTOM_LICENSE_TEXT - Extracted text for custom LicenseRef-* IDs
@@ -38,16 +39,34 @@ endif()
3839# COPYRIGHT "Copyright Example Inc."
3940# )
4041#
41- define_property (GLOBAL PROPERTY ITK_SBOM_EXTRA_PACKAGES
42- BRIEF_DOCS "Additional SBOM package entries registered by remote modules."
43- FULL_DOCS "A list of JSON-formatted package entries for the SBOM."
42+ define_property (
43+ GLOBAL
44+ PROPERTY ITK_SBOM_EXTRA_PACKAGES
45+ BRIEF_DOCS
46+ "Additional SBOM package entries registered by remote modules."
47+ FULL_DOCS
48+ "A list of JSON-formatted package entries for the SBOM."
4449)
4550
4651function (itk_sbom_register_package )
4752 set (_options "" )
48- set (_one_value NAME VERSION SPDX_LICENSE DOWNLOAD_LOCATION SUPPLIER COPYRIGHT)
53+ set (
54+ _one_value
55+ NAME
56+ VERSION
57+ SPDX_LICENSE
58+ DOWNLOAD_LOCATION
59+ SUPPLIER
60+ COPYRIGHT
61+ )
4962 set (_multi_value "" )
50- cmake_parse_arguments (_pkg "${_options} " "${_one_value} " "${_multi_value} " ${ARGN} )
63+ cmake_parse_arguments (
64+ _pkg
65+ "${_options} "
66+ "${_one_value} "
67+ "${_multi_value} "
68+ ${ARGN}
69+ )
5170
5271 if (NOT _pkg_NAME)
5372 message (FATAL_ERROR "itk_sbom_register_package: NAME is required." )
@@ -76,18 +95,38 @@ function(itk_sbom_register_package)
7695 string (APPEND _entry " \" SPDXID\" : \" SPDXRef-${_spdx_id} \" ,\n " )
7796 string (APPEND _entry " \" name\" : \" ${_pkg_NAME} \" ,\n " )
7897 string (APPEND _entry " \" versionInfo\" : \" ${_pkg_VERSION} \" ,\n " )
79- string (APPEND _entry " \" downloadLocation\" : \" ${_pkg_DOWNLOAD_LOCATION} \" ,\n " )
98+ string (
99+ APPEND
100+ _entry
101+ " \" downloadLocation\" : \" ${_pkg_DOWNLOAD_LOCATION} \" ,\n "
102+ )
80103 string (APPEND _entry " \" supplier\" : \" ${_pkg_SUPPLIER} \" ,\n " )
81- string (APPEND _entry " \" licenseConcluded\" : \" ${_pkg_SPDX_LICENSE} \" ,\n " )
104+ string (
105+ APPEND
106+ _entry
107+ " \" licenseConcluded\" : \" ${_pkg_SPDX_LICENSE} \" ,\n "
108+ )
82109 string (APPEND _entry " \" licenseDeclared\" : \" ${_pkg_SPDX_LICENSE} \" ,\n " )
83110 string (APPEND _entry " \" copyrightText\" : \" ${_pkg_COPYRIGHT} \" ,\n " )
84111 string (APPEND _entry " \" filesAnalyzed\" : false\n " )
85112 string (APPEND _entry " }" )
86113
87- set_property (GLOBAL APPEND PROPERTY ITK_SBOM_EXTRA_PACKAGES "${_entry} " )
114+ set_property (
115+ GLOBAL
116+ APPEND
117+ PROPERTY
118+ ITK_SBOM_EXTRA_PACKAGES
119+ "${_entry} "
120+ )
88121
89122 # Also store the SPDX ID for relationship generation
90- set_property (GLOBAL APPEND PROPERTY ITK_SBOM_EXTRA_SPDX_IDS "SPDXRef-${_spdx_id} " )
123+ set_property (
124+ GLOBAL
125+ APPEND
126+ PROPERTY
127+ ITK_SBOM_EXTRA_SPDX_IDS
128+ "SPDXRef-${_spdx_id} "
129+ )
91130endfunction ()
92131
93132#-----------------------------------------------------------------------------
@@ -114,8 +153,10 @@ function(itk_generate_sbom)
114153 string (TIMESTAMP _sbom_timestamp "%Y-%m-%dT%H:%M:%SZ" UTC )
115154 string (TIMESTAMP _sbom_uid "%Y%m%d%H%M%S" UTC )
116155
117- set (_sbom_namespace
118- "https://spdx.org/spdxdocs/ITK-${ITK_VERSION} -${_sbom_uid} " )
156+ set (
157+ _sbom_namespace
158+ "https://spdx.org/spdxdocs/ITK-${ITK_VERSION} -${_sbom_uid} "
159+ )
119160
120161 # --- Begin JSON document ---
121162 set (_json "" )
@@ -144,11 +185,19 @@ function(itk_generate_sbom)
144185 string (APPEND _json " \" SPDXID\" : \" SPDXRef-ITK\" ,\n " )
145186 string (APPEND _json " \" name\" : \" ITK\" ,\n " )
146187 string (APPEND _json " \" versionInfo\" : \" ${ITK_VERSION} \" ,\n " )
147- string (APPEND _json " \" downloadLocation\" : \" https://github.com/InsightSoftwareConsortium/ITK\" ,\n " )
188+ string (
189+ APPEND
190+ _json
191+ " \" downloadLocation\" : \" https://github.com/InsightSoftwareConsortium/ITK\" ,\n "
192+ )
148193 string (APPEND _json " \" supplier\" : \" Organization: NumFOCUS\" ,\n " )
149194 string (APPEND _json " \" licenseConcluded\" : \" Apache-2.0\" ,\n " )
150195 string (APPEND _json " \" licenseDeclared\" : \" Apache-2.0\" ,\n " )
151- string (APPEND _json " \" copyrightText\" : \" Copyright 1999-2019 Insight Software Consortium, Copyright 2020-present NumFOCUS\" ,\n " )
196+ string (
197+ APPEND
198+ _json
199+ " \" copyrightText\" : \" Copyright 1999-2019 Insight Software Consortium, Copyright 2020-present NumFOCUS\" ,\n "
200+ )
152201 string (APPEND _json " \" filesAnalyzed\" : false\n " )
153202 string (APPEND _json " }" )
154203
@@ -169,8 +218,12 @@ function(itk_generate_sbom)
169218 continue ()
170219 endif ()
171220
221+ set (_pkg_version "${ITK_MODULE_${_mod} _SPDX_VERSION}" )
172222 set (_pkg_download "${ITK_MODULE_${_mod} _SPDX_DOWNLOAD_LOCATION}" )
173223 set (_pkg_copyright "${ITK_MODULE_${_mod} _SPDX_COPYRIGHT}" )
224+ if (NOT _pkg_version)
225+ set (_pkg_version "NOASSERTION" )
226+ endif ()
174227 if (NOT _pkg_download)
175228 set (_pkg_download "NOASSERTION" )
176229 endif ()
@@ -201,7 +254,7 @@ function(itk_generate_sbom)
201254 string (APPEND _json " {\n " )
202255 string (APPEND _json " \" SPDXID\" : \" SPDXRef-${_spdx_id} \" ,\n " )
203256 string (APPEND _json " \" name\" : \" ${_mod} \" ,\n " )
204- string (APPEND _json " \" versionInfo\" : \" NOASSERTION \" ,\n " )
257+ string (APPEND _json " \" versionInfo\" : \" ${_pkg_version} \" ,\n " )
205258 string (APPEND _json " \" downloadLocation\" : \" ${_pkg_download} \" ,\n " )
206259 string (APPEND _json " \" supplier\" : \" NOASSERTION\" ,\n " )
207260 string (APPEND _json " \" licenseConcluded\" : \" ${_pkg_license} \" ,\n " )
@@ -229,12 +282,24 @@ function(itk_generate_sbom)
229282 string (APPEND _json " \" SPDXID\" : \" SPDXRef-FFTW\" ,\n " )
230283 string (APPEND _json " \" name\" : \" FFTW\" ,\n " )
231284 string (APPEND _json " \" versionInfo\" : \" ${_fftw_version} \" ,\n " )
232- string (APPEND _json " \" downloadLocation\" : \" https://www.fftw.org\" ,\n " )
285+ string (
286+ APPEND
287+ _json
288+ " \" downloadLocation\" : \" https://www.fftw.org\" ,\n "
289+ )
233290 string (APPEND _json " \" supplier\" : \" Organization: MIT\" ,\n " )
234291 string (APPEND _json " \" licenseConcluded\" : \" ${_fftw_license} \" ,\n " )
235292 string (APPEND _json " \" licenseDeclared\" : \" ${_fftw_license} \" ,\n " )
236- string (APPEND _json " \" copyrightText\" : \" Copyright Matteo Frigo and Massachusetts Institute of Technology\" ,\n " )
237- string (APPEND _json " \" description\" : \" Fastest Fourier Transform in the West\" ,\n " )
293+ string (
294+ APPEND
295+ _json
296+ " \" copyrightText\" : \" Copyright Matteo Frigo and Massachusetts Institute of Technology\" ,\n "
297+ )
298+ string (
299+ APPEND
300+ _json
301+ " \" description\" : \" Fastest Fourier Transform in the West\" ,\n "
302+ )
238303 string (APPEND _json " \" filesAnalyzed\" : false\n " )
239304 string (APPEND _json " }" )
240305 list (APPEND _thirdparty_spdx_ids "SPDXRef-FFTW" )
@@ -296,10 +361,12 @@ function(itk_generate_sbom)
296361 string (APPEND _json ",\n " )
297362 endif ()
298363 set (_first_custom FALSE )
364+ _itk_sbom_json_escape ("${_lic_name} " _lic_name_escaped )
365+ _itk_sbom_json_escape ("${_lic_text} " _lic_text_escaped )
299366 string (APPEND _json " {\n " )
300367 string (APPEND _json " \" licenseId\" : \" ${_lic_id} \" ,\n " )
301- string (APPEND _json " \" name\" : \" ${_lic_name } \" ,\n " )
302- string (APPEND _json " \" extractedText\" : \" ${_lic_text } \"\n " )
368+ string (APPEND _json " \" name\" : \" ${_lic_name_escaped } \" ,\n " )
369+ string (APPEND _json " \" extractedText\" : \" ${_lic_text_escaped } \"\n " )
303370 string (APPEND _json " }" )
304371 endforeach ()
305372 string (APPEND _json "\n ]" )
0 commit comments