[CMake] copy on install

Ryan Pavlik rpavlik at iastate.edu
Fri Feb 5 11:21:21 EST 2010


Instead of using the LOCATION property, you might consider doing 
something along these lines, using the LOCATION_Release, LOCATION_Debug, 
etc. properties. I do something similar to this on windows/MSVC to toss 
extra files around that have an executable's full path:

foreach(_configname ${CMAKE_CONFIGURATION_TYPES})
             get_target_property(${_configname}_BINARY
                 ${_targetname}
                 LOCATION_${_configname})
             install(FILES ${_configname}_BINARY DESTINATION wherever 
RENAME whatever-you-need)
endforeach()


On 02/05/2010 07:53 AM, Tim St. Clair wrote:
> Response Below
> Inline...
>
> On Fri, Feb 5, 2010 at 12:05 AM, Alan W. Irwin
> <irwin at beluga.phys.uvic.ca>  wrote:
>    
>> On 2010-02-04 22:44-0600 Tim St. Clair wrote:
>>      
>>> On Thu, Feb 4, 2010 at 6:14 PM, Alan W. Irwin<irwin at beluga.phys.uvic.ca>
>>> wrote:
>>>        
>>>> 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.
>>>        
>> I have never had trouble with the LOCATION property.  I use it as follows:
>>
>> get_target_property(variable_name target_name LOCATION)
>> message(STATUS "variable_name=${variable_name}")
>>
>> which outputs the full path name of the target.  Don't you get that?
>>
>>      
> Yup, on windows LOCATION output =
> c:\My_Src_Path\$(OutDir)\my_target.exe
>
> I was thinking about using ${CMAKE_BUILD_TYPE}_LOCATION($(OutDir) =
> Release, Debug...) but on windows there is no guarantee that will be
> the default config, and when you change build configurations your
> install and package targets will light on fire because they are pin'd
> to a certain config.
>
> For the time being I have just duplicated the targets (which is
> non-ideal) as it increases the build time.  I'm thinking this is a
> limitation in CMAKE.  It would be nice if you could have aliases for
> install targets which would copy on windows, and soflink&&|| copy on
> *nix.
>
> Cheers,
> Tim
>
>    
>> 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
>> __________________________
>>
>>      
>
>
>    

-- 
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

rpavlik at iastate.edu
http://academic.cleardefinition.com
Internal VRAC/HCI Site: http://tinyurl.com/rpavlik



More information about the CMake mailing list