[CMake] How can I install something into an absolute directory?

Alexander Neundorf a.neundorf-work at gmx.net
Mon Feb 16 16:04:26 EST 2009


On Monday 16 February 2009, Andreas Pakulat wrote:
> On 16.02.09 21:12:46, Kermit Mei wrote:
> > How can I install something into an absolute directory?
> > For example, I want to install the directory under /usr/share.
> > When I use the following command:
> > INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/dict/mydir DESTINATION share)
> >
> > 'mydir' may be installed into /usr/local/share, if I run
> > cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..
>
> Thats correct and the right thing to happen.
>
> > How to avoid it, and guarantee it can be install under /usr/share
> > whatevery I
> > pointed with cmake PREFIX ?
>
> Your app should not need that, in particular nothing that builds from
> source should install into a directory thats controlled by a distributions
> packaging system. Apart from that, something like this would probably break
> how distributions build a package from such sources.

Andreas is right, but if you really want it, you can simply put the absolute 
path as the destination:
INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/dict/mydir DESTINATION /usr/share)

(haven't tried this with DIRECTORY mode, but works for files and targets).

Alex


More information about the CMake mailing list