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

Paul Smith paul at mad-scientist.net
Sun Feb 15 09:55:44 EST 2015


In my Mac OSX builds I want to run dsymutil to create .dSYM debug
contents.  However, this is very slow so I don't want to do it during
normal builds (where it's not needed because I have all the object
files), I only want it to be done during the install step.

I can create an add_custom_command() to run dsymutil easily enough,
something like:


  function(stagedebug target dir)
      if(APPLE)
          set(destfile "${dir}/${target}.dSYM/Contents/Info.plist")
          add_custom_command(OUTPUT "$destfile"
              COMMAND dsymutil "${dir}/${target}"
              MAIN_DEPENDENCY ${target}
              COMMENT "Staging dSYM for ${target} to ${dir}"
              VERBATIM)

          # Now what?
      endif
  endfunction()


but I have no idea how to hook this into the install step.  I don't see
anything in the install() command that lets me specify a target to be
run, it just seems to be able to copy files.

What am I missing?

Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150215/52f1b63b/attachment.html>


More information about the CMake mailing list