[CMake] CPack: Create debian packge for each sub-project
Domen Vrankar
domen.vrankar at gmail.com
Fri Jul 21 20:18:57 EDT 2017
2017-07-22 1:55 GMT+02:00 DKLind <davidklind at gmail.com>:
> I have a large project and I need to create a Debian package for each
> sub-project (essentially each add_subdirectory).
>
> I have been experimenting with CPack components as outlined here:
> https://cmake.org/cmake/help/v3.8/module/CPackComponent.
> html?highlight=cpack_components_grouping#variable:
> CPACK_COMPONENTS_GROUPING
>
Debian packaging generator specific variables are described here:
https://cmake.org/cmake/help/v3.8/module/CPackDeb.html
> I haven't been able to get any CPACK_DEBIAN_<COMPONENT>_PACKAGE_XXX
> variables to work. I've been using the syntax
> CPACK_DEBIAN_${PROJECT_NAME}_PACKAGE_XXX.
>
I'm guessing that ${PROJECT_NAME} contains lower case characters -
<COMPONENT> (called <compName> in documentation) part of the variable name
is supposed to be in upper case.
> I'm calling install as:
> install(TARGETS ${PROGRAM_NAME} DESTINATION lib COMPONENT ${PROGRAM_NAME})
> This way each sub-project is a unique component.
>
This looks fine.
> I would expect that CPackConfig.cmake would contain an entry for each
> CPACK_DEBIAN_<COMPONENT>_PACKAGE_XXX variable. But, I'm seeing only
> variables for the last sub-project that called "include(CPack)".
>
Only the top level CMakeLists.txt should call 'include(CPack)' and the rest
of the CMakeLists.txt (if they can be used stand alone) should only call it
if they are the base binary dir:
if(CMAKE_CURRENT_BINARY_DIR STREQUAL CMAKE_BINARY_DIR)
include(CPack)
endif()
The reason is that including this script generates CPackConfig.cmake and
CPackSourceConfig.cmake files from already set variables.
Here are my requrements:
> 1. Each package must have a unique control file info (version, description,
> etc).
>
Description part is not a problem but the version part is - currently only
one version for all packages is used and can't be set per component. Using
ExternalProject instead of subdirectories would be one solution, the other
would be extending CPackDeb.cmake module (contribution would be welcome).
> 2. Each package filename must be
> ${PROGRAM_NAME}_${VERSION}_${ARCHITECTURE}.deb
>
For package names I'd suggest using:
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
to get the default deb package file name format but if you wish to use your
naming convention you can set the per component version for each package.
Regards,
Domen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170722/ffcdf2ac/attachment-0001.html>
More information about the CMake
mailing list