[CMake] How to build a target on install (only)?

Paul Smith paul at mad-scientist.net
Sun Feb 15 14:59:43 EST 2015


On Sun, 2015-02-15 at 12:16 -0500, David Cole wrote:
> The easiest thing is probably to use the install(SCRIPT or
> install(CODE signature of the install command rather than having a
> "build time" custom command.

Hm.  That has the disadvantage that it runs every time, even if the
binary hasn't been modified, but it does work:

  install(CODE "message(STATUS \"Creating dSYM for ${target} in ${dir}\")")
  install(CODE "execute_process(COMMAND dsymutil \"${dir}/${target}\" OUTPUT_QUIET)")

It's too bad that execute_process() doesn't have a COMMENT field, but
this works OK.  It wasn't clear to me how to pass arguments to a SCRIPT
so I used CODE instead.

It'd be nice if I could make it a real target that only is invoked on
install, so that we'd not re-run the command if it wasn't necessary, but
this gets the work done; thanks for the pointer!



More information about the CMake mailing list