[CMake] Standard template for building and installing a library

Matthew Woehlke matthew.woehlke at kitware.com
Wed Sep 11 12:33:31 EDT 2013


On 2013-09-10 19:12, Littlefield, Tyler wrote:
> On 9/10/2013 6:43 PM, Matthew Woehlke wrote:
>> On 2013-09-10 17:38, Littlefield, Tyler wrote:
>>> My final question is how to make the debug/release build work, as well
>>> as to allow to let this install. I need to install libxlog.a and the
>>> include directory
>>> as well to includedir/xlog/*. Is there a typical method to do this?
>>
>> See the 'install' command.
>
> Awesome, thanks. I've found that actually, I should have been more
> specific. I need to figure out which directory the user wants them
> installed in. Is there a standard method for pulling that information?
> Thanks,

Convention is to install into a well-defined tree structure beneath the 
install prefix, which is specified by the DESTINATION argument¹ to 
install(). I wouldn't recommend deviating from that.

The user can control the prefix by setting CMAKE_INSTALL_PREFIX; maybe 
that is what you are looking for?

(¹...which is sometimes per library-type, e.g. 'RUNTIME', etc. See the 
documentation for install().)

-- 
Matthew



More information about the CMake mailing list