[CMake] Creating two distinct packages w/ CPack from a single project

J. Paul Reed preed at releng-approaches.com
Mon Oct 16 17:45:04 EDT 2017


Hey all,

I have a (potentially?) odd situation: I need to generate multiple packages
using CPack from the same CMake project.

I'm aware of the component-based installers and methodology, but I don't
believe that's what I want here: I want entirely different package
names/versions/etc., containing different artifacts created from a single
CMake project.

I have currently implemented this by setting the various CPack
configuration variables, and then include()ing CPack in different
directories. I then have custom targets that call cpack with --config,
pointed to a non-default-named CPack configuration file.

This seems to work just fine, except during the cmake configuration run, we
get warnings about CPack.cmake having already been included.

I see where this message() gets emitted
(https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/CPack.cmake#L298-302);
perusing that file, it seems to do things I basically want/need (setting
various defaults, etc.) if I want to use cpack with a different config
file.

I can suppress the warning by unsetting CPack_CMake_INCLUDED, which is what
I'm planning to do... but I wanted to ask:

a) whether there are any technical problems or concerns by subverting that
warning message and including CPack.cmake multiple times, and

b) if there's another solution entirely that is better suited. (Again, I'm
aware of component based installs; I don't think they'll do what I want
here.)

thanks,
preed
-- 
J. Paul Reed


More information about the CMake mailing list