CPack: Create debian packge for each sub-project

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

CPack: Create debian packge for each sub-project

DKLind
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

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 calling install as:
install(TARGETS ${PROGRAM_NAME} DESTINATION lib COMPONENT ${PROGRAM_NAME})
This way each sub-project is a unique component.

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)".

Here are my requrements:
1. Each package must have a unique control file info (version, description, etc).
2. Each package filename must be ${PROGRAM_NAME}_${VERSION}_${ARCHITECTURE}.deb
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CPack: Create debian packge for each sub-project

Domen Vrankar
2017-07-22 1:55 GMT+02:00 DKLind <[hidden email]>:
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

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CPack: Create debian packge for each sub-project

DKLind
Domen,

Thanks for the reply to my question. I was aware of the Debian packaging generator page and I also was already setting the component value to uppercase.

As documented, I had to use PARENT_SCOPE when setting CPACK_DEBIAN_<COMPONENT>_PACKAGE_XXX values from sub-projects' CMakeLists.txt.

Also, curious why CPACK_COMPONENT_<COMPONENT>_DESCRIPTION is different from the other CPACK_DEBIAN_<COMPONENT>_PACKAGE_XXX?

With your help, I have individual packaging working now, except for unique version. I also realize that I would like to be able to set the contributor for some packages to be unique.

I would like to contribute to CMake. I see the page https://cmake.org/gitweb?p=cmake.git;a=blob_plain;f=CONTRIBUTING.rst;hb=master. It mentions submitting contributions in patch form. Are pull requests also accepted?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CPack: Create debian packge for each sub-project

DKLind
I forgot, I also have a question about "make package". How do I build and package just an individual sub-project. As expected, "make <sub-project>" works to build, but there isn't a default target to package an individual sub-project.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CPack: Create debian packge for each sub-project

Domen Vrankar
In reply to this post by DKLind
2017-07-23 17:19 GMT+02:00 DKLind <[hidden email]>:
Also, curious why CPACK_*COMPONENT*_<COMPONENT>_DESCRIPTION is different
from the other CPACK_*DEBIAN*_<COMPONENT>_PACKAGE_XXX?

Most variables are debian package specific/allow to override general CPack variables specifically for debian packages. For e.g. package description is set to:
  if CPACK_DEBIAN_PACKAGE_DESCRIPTION # debian specific override
  else if CPACK_PACKAGE_DESCRIPTION_SUMMARY # general package description

There is no particular reason why per component version can't be overridden by a debian packager specific variable - you would usually want to have a single description for the same component no matter the package format (deb, rpm, ...).

With your help, I have individual packaging working now, except for unique
version. I also realize that I would like to be able to set the contributor
for some packages to be unique.

Per component variable for these variables was not introduced since
 
I would like to contribute to CMake. I see the page
https://cmake.org/gitweb?p=cmake.git;a=blob_plain;f=CONTRIBUTING.rst;hb=master.
It mentions submitting contributions in patch form. Are pull requests also
accepted?

As described in the link that you've provided create a gitlab account here: https://gitlab.kitware.com/cmake/cmake
and create a merge request (gitlab equivalent to pull request on github).

2017-07-23 17:37 GMT+02:00 DKLind <[hidden email]>:
I forgot, I also have a question about "make package". How do I build and
package just an individual sub-project. As expected, "make <sub-project>"
works to build, but there isn't a default target to package an individual
sub-project.
 
You can set CPACK_COMPONENTS_ALL variable to contain only the components that you wish to package:

set(CPACK_COMPONENTS_ALL applications libraries headers)

By default it's set by CPack to contain all components.

Regards,
Domen


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CPack: Create debian packge for each sub-project

Gonzalo Garramuño
In reply to this post by DKLind


El 23/07/17 a las 12:37, DKLind escribió:
> I forgot, I also have a question about "make package". How do I build and
> package just an individual sub-project. As expected, "make <sub-project>"
> works to build, but there isn't a default target to package an individual
> sub-project.
AFAIK, it is not possible. I would also like to know this for separate
packager generators. How to call "make package" on just one package
generator (like build just DEB and not RPM).

--
Gonzalo Garramuño

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CPack: Create debian packge for each sub-project

Craig Scott-3


On Mon, Jul 24, 2017 at 6:13 AM, Gonzalo Garramuño <[hidden email]> wrote:


El 23/07/17 a las 12:37, DKLind escribió:
I forgot, I also have a question about "make package". How do I build and
package just an individual sub-project. As expected, "make <sub-project>"
works to build, but there isn't a default target to package an individual
sub-project.
AFAIK, it is not possible. I would also like to know this for separate packager generators. How to call "make package" on just one package generator (like build just DEB and not RPM).


If you want to pick the package generator, run cpack directly rather than "make package". You'd need to manually run just "make" first to ensure the packaged targets are built. You may want/need other options too when using some CMake generators (e.g. -C for the build configuration with Xcode or Visual Studio most likely).

make
cpack -G RPM



--
Craig Scott
Melbourne, Australia

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: CPack: Create debian packge for each sub-project

DKLind
In reply to this post by Domen Vrankar
Here's a little trick I learned. Executing the custom target, "make package_target target=xyz", will build the target and call cpack to create the package. Additional parameters can be passed by putting the target value in quotes (make package_target target="xyz -j4").

Executing cpack causes the target to be built. But, if you want to see the output of make, before cpack, "COMMAND make ${PARAMS}" will do that.

    set(PARAMS
        "$(if $(target),$(target))"
    )
    string(REPLACE " " ";" PARAMS ${PARAMS})

    add_custom_target(package_target
        COMMAND make ${PARAMS}
        COMMAND cpack -D CPACK_COMPONENTS_ALL=${PARAMS}
    )
Loading...