[CMake] granular install advice

Michael Hertling mhertling at online.de
Fri Dec 17 17:03:12 EST 2010


On 12/17/2010 03:31 PM, luxInteg wrote:
> Greetings,
> 
> I am learning cmake.
> 
> If I were to have  some  homebrewed "ModulesForCMakeIdiots.cmake" from my 
> learning project in say ${CMAKE_SOURCE_DIR}/modules
> and I set this command:-
> 
> install(FILES ${CMAKE_SOURCE_DIR}/modules/*.cmake /usr/local/someplace )
> 
> do be done  AT INSTALL time  
> (i.e. I want to  install the modules on  the file syatem say 
> /usr/local/someplace) -the above is like to   copy   the modules to 
> ${INSTALL_PREFIX}/usr/local/someplace.
> 
> So how do I  tell cmake to  copy to   /usr/local/someplace instead?

The correct signature of the INSTALL(FILES ...) command is

INSTALL(FILES ... DESTINATION /usr/local/someplace ...)
                  ^^^^^^^^^^^
and the manual - which you've studied thoroughly, I suppose - states:

DESTINATION arguments specify the directory on disk to which a file
will be installed. If a *full path* (with a leading slash or drive
letter) is given it is used directly. If a relative path is given
it is interpreted relative to the value of CMAKE_INSTALL_PREFIX.

Besides, you can't specify the files for INSTALL(FILES ...) using the
'*' and other globbing characters as they are meaningful only for the
shell or specialized CMake commands like FILE(GLOB ...).

Regards,

Michael


More information about the CMake mailing list