[CMake] Using cpack for custom/local deployment
Michael Hertling
mhertling at online.de
Wed Nov 16 08:35:58 EST 2011
On 11/16/2011 02:11 PM, Alexander Broekhuis wrote:
> Hi all,
>
> I have some questions regarding the use of CPack and CMake.
>
> What I'd like to do is have the a target execute multiple cpack
> configurations (additionally, have a possibility to execute only one
> configuration).
> The cpack config can use a component to do filtering on the artifacts
> needed for one target. The set of artifacts needs to end up in a directory
> in the project.
>
> For example, I have three libraries/targets:
>
> - A
> - B
> - C
>
> Then I have 2 deployment targets (CPack configs):
>
> - Deploy1
> - Deploy2
>
> The result has to be something like:
>
> - Deploy1: A and B in a directory named Deploy1
> - Deploy2: A and C in a directory named Deploy2
>
>
> I currently have a solution which uses a macro and copies the artifacts to
> the correct directory, but custom targets always assume "out-of-date". Is
> it possible to introduce a target which depends on several others targets
> and uses their "out-of-date" state?
You might use custom targets in conjunction with custom commands: An
OUTPUT-style custom command, i.e. ADD_CUSTOM_COMMAND(OUTPUT ...), is
run only if its OUTPUTs don't exist or if they are're older than the
prerequisites, i.e. the files/directories mentioned in the DEPENDS
clause. So, you can do the following:
ADD_CUSTOM_COMMAND(OUTPUT y COMMAND ... DEPENDS x)
ADD_CUSTOM_TARGET(z DEPENDS y)
The custom target z is always out-of-date, so the prerequisite custom
command is always checked, but the latter's COMMAND is run only if y
doesn't exist or is older than x. Thus, use custom commands for the
actual operations, and custom targets to set up these operations'
dependencies.
Regards,
Michael
> Also, can CPack be used to deploy to an exploded directory? There doesn't
> seem to be a Directory Generator.
>
> TiA!
More information about the CMake
mailing list