[CMake] redefining CMake package target when using CPack

Eric Noulard eric.noulard at gmail.com
Tue Aug 28 02:02:44 EDT 2012


2012/8/28 Bruce Cartland <bruce.cartland at pobox.com>:
> I'm currently generating multiple distinct debian packages (runtime and
> dev).
>
> I have a typical cmake file with cpack commands in it ending with
> "inlude(CPack)" . This generates the targets "package" and "package-source".
> On debian platforms, I want "package_source" but I'd like to
> redefine/override the "package" target with a custom command.
>
> At the moment I define my own target "pkg" which mimics "package":
>     "add_custom_target(pkg DEPENDS deb_runtime deb_dev)" - on debian
> platforms - deb_runtime and deb_dev being custom targets
>     "add_custom_target(pkg COMMAND ........)" - mimic "package" on
> non-debian platforms
>
> It would be nicer to just override "package" (on debian platforms) - e.g.
>     "add_custom_target(package DEPENDS deb_runtime deb_dev)"
> (but this gets ignored.)
>
> Is something like this possible or is the pkg mechanism above the simplest
> way?

Currently I don't think you can override a builtin target like "package".
What you can do is:

Do not include(CPack) but generate the CPackSourceConfig.cmake
in another way. If this file exists in the build tree the CMake generator
should "generate" a package_source target as usual.

Then define your own "package"  custom target.

Another way around is to define your own package and package_source
using custom command (which may call CPack with hand-crafted  config file).

-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org


More information about the CMake mailing list