CPack Deb lacks a way to configure copyright files by component
When doing a componentized CPack build with multiple trees (ie. via CPACK_INSTALL_CMAKE_PROJECTS
) it is not possible to externally manage the copyright files. Ubuntu/Debian policy, enforced by lintian
, requires that every package have a /usr/share/doc/<package-name>/copyright
file, but adding install()
calls directly to the project presumes a component-name-to-package-name mapping. If you're trying to package multiple components together in a group, you're out of luck.
I propose creating variables CPACK_DEBIAN_RESOURCE_FILE_LICENSE
and CPACK_DEBIAN_<COMPONENT>_RESOURCE_FILE_LICENSE
that configure their target files to the mandated path (/usr/share/doc/<package-name>/copyright
). They could take their default value from CPACK_RESOURCE_FILE_LICENSE
(with a policy) or do nothing if not set.
It would be especially useful if the copyright files could be configured with packaging variables available: @CPACK_PACKAGE_NAME@
, @CPACK_PACKAGE_CONTACT@
, @CPACK_DEBIAN_PACKAGE_HOMEPAGE@
, etc.
I'm currently hacking around this with a pre-build script (CPACK_PRE_BUILD_SCRIPTS
) that looks like:
cmake_minimum_required(VERSION 3.19)
foreach(comp IN LISTS CPACK_COMPONENTS_ALL)
string(TOUPPER "CPACK_DEBIAN_${comp}_PACKAGE_NAME" package_name_var)
string(TOLOWER "${${package_name_var}}" package_name)
set(copyright_dir "${CPACK_TEMPORARY_DIRECTORY}/${comp}/usr/share/doc/${package_name}")
configure_file("${CPACK_RESOURCE_FILE_LICENSE}" "${copyright_dir}/copyright"
@ONLY NO_SOURCE_PERMISSIONS)
endforeach()
Of course this works for me only because I happen to know all the intermediate variables exist.