[CMake] Install target after building it

Matthew Woehlke matthew.woehlke at kitware.com
Mon Apr 22 19:46:40 EDT 2013


On 2013-04-22 18:12, Robert Dailey wrote:
> I want to setup a target's header files to be copied to a separate
> directory after that target is built. Any dependent targets will
> reference the INSTALLED header files, so they must be copied after
> that target is built and prior to any other targets (that depend on
> it) that get built.
>
> Is there a way to do this? Right now I use INSTALL( FILES ) but this
> isn't target-specific. Thanks.

I do something similar, although I wouldn't recommend using INSTALL as 
it requires re-running CMake any time you change a header.

What I do is have a function that takes a list of public headers, create 
a target e.g. myLibrary-headers with custom commands to copy the headers 
as needed (i.e. a copy command per header that depends on the original 
header), and then make myLibrary depend on this target.

-- 
Matthew



More information about the CMake mailing list