[CMake] how to define a target that will be run on request only, and always on install?

Alexander Neundorf a.neundorf-work at gmx.net
Sun Mar 30 17:09:41 EDT 2008


On Saturday 29 March 2008, Crni Gorac wrote:
> On Sat, Mar 29, 2008 at 6:01 PM, Crni Gorac <cgorac at gmail.com> wrote:
> > I have some translation files, defined ADD_CUSTOM_COMMAND() to
> >  generate them on request:
> >   ADD_CUSTOM_COMMAND(
>
> Apologies for above; bad GMail, bad!
>
> So:
>
> Say I have a translation file, defined ADD_CUSTOM_COMMAND() to generate
> it on request:
>   ADD_CUSTOM_COMMAND(
>     OUTPUT foo.trans
>     COMMAND abracadabra -o foo.trans
>   )
> Let's say that it would be complicated to specify dependencies of this
> file from all source code files in my project, and that I prefer to not
> have it regenerated each time when some of source files changed anyway.
>
> Further, I have "translations" target defined, so that I could generate
> these files upon request:
>   ADD_CUSTOM_TARGET(
>     translations
>     DEPENDS foo.trans
>     )
>
> Finally, translations file is installed through corresponding INSTALL()
> command:
>   INSTALL(
>     FILES foo.trans
>     DESTINATION translations
>     PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
>   )

Currently "install" depends on "all" and you can't make it depend on more 
targets.

You could create your own "my_install" target, which builds the documentation 
and then executes the "install" target.

Alex


More information about the CMake mailing list