[CMake] copy on install

Alan W. Irwin irwin at beluga.phys.uvic.ca
Thu Feb 4 19:14:31 EST 2010


On 2010-02-04 23:38+0100 Eric Noulard wrote:

> 2010/2/4 Tim St. Clair <timothysc at gmail.com>:
>> Is there a clean way to copy the install target e.g.
>>
>> install (TARGETS foo DESTINATION bin)
>>
>> ~ install(TARGETS foo DESTINATION loc2 RENAME foo_bar) <-doesn't exist.
>>
>> I basically need to install the same target to *multiple* locations
>> with different names.
>
> I think multiple location is already supported just call
>
> install (TARGETS foo DESTINATION loc1)
> install (TARGETS foo DESTINATION loc2)
> install (TARGETS foo DESTINATION loc3)
> etc...
>
> now concerning renaming without building the same target several times?
> May be with add_custom_command
>
> add_custom_command(TARGET foo
>                                   POST_BUILD
>                                   COMMAND ${CMAKE_COMMAND} -E copy
> foo ${CMAKE_BINARY_DIR}/foo_renamed)
>
> +
> install(FILES ${CMAKE_BINARY_DIR}/foo_renamed DESTINATION loc2)
>
>
> this may not really solves the problem because install(FILES djfldfj)
> won't make what install(TARGETS do like rpath handling etc....
>
> a working (but ugly solution) would be to built the target as many
> time as you need to with the needed different name each time.

Why not simply use install(FILES ... PERMISSIONS .... RENAME ...  )?

You would have to use the target property LOCATION to find the
(cross-platform) filename associated with the target, and you would have to
specify the appropriate PERMISSIONS, but I think this method of using
install(FILES ...) should work fine unless and until a feature request for a
RENAME option for install(TARGETS....) is implemented.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list