[CMake] copy on install

Tim St. Clair timothysc at gmail.com
Thu Feb 4 23:44:22 EST 2010


Inline.. Re: Alan



On Thu, Feb 4, 2010 at 6:14 PM, Alan W. Irwin <irwin at beluga.phys.uvic.ca> wrote:
> 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.
>

I like this solution however when I try it... it does not expand the
$(OutDir) which was yielded when I called get_target_property
w/LOCATION.  The only other option I can think of is to use a post
install script.

> 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
> __________________________
>



-- 
Cheers,
Timothy St. Clair


More information about the CMake mailing list