[CMake] Fwd: how to install files outside /usr in rpm?
Erik Sjölund
erik.sjolund at sbc.su.se
Tue May 13 10:28:11 EDT 2008
On Mon, 2008-05-12 at 18:01 +0200, Eric NOULARD wrote:
> Le Mon, 12 May 2008 15:12:06 +0200,
> Erik Sjölund <erik.sjolund at sbc.su.se> a écrit :
>
> > On Sat, 2008-05-10 at 13:40 +0200, Eric Noulard wrote:
> > > 2008/5/7 Timenkov Yuri <ytimenkov at parallels.com>:
> > >
> > > > Also, bunch of problems with building from non-root account, can
> > > > be solved by setting CPACK_SET_DESTDIR option.
> > >
> > > You are right and I think we can make this the default behavior for
> > > CPäckRPM.
> > >
> > > I did file a bug+patch for this:
> > > http://public.kitware.com/Bug/view.php?id=7000
> > >
> >
> > Following that link, there is a nice example of installing files
> > outside /usr in an rpm.
> >
> > esjolund at otto:/tmp/y$ rpm -qlp /tmp/y/myscript-1.0.rpm
> > /opt
> > /opt/sbin
> > /opt/sbin/myabsolutescript
> > /usr
> > /usr/local
> > /usr/local/sbin
> > /usr/local/sbin/myscript
> >
> > But if I have an additional requirement that a normal user should be
> > able to install the software in his home directory like this,
> >
> > cmake -DCMAKE_INSTALL_PREFIX=/home/erik /tmp/myscript-1.0-src && make
> > && make install
>
>
> CMAKE_INSTALL_PREFIX is only used for file which are not installed
> using "absolute path" (myscript in the example) and this is the
> wanted/expected behavior.
>
> However you can relocate the installation using DESTDIR with make
> install (just as CPack does)
>
> Just replace your:
>
> make install
>
> with
>
> DESTDIR=/home/erik make install
>
> Note that DESTDIR will be prepend for ALL installed file so
> you may prefer to set INSTALL_PREFIX as ""
>
> cmake -DCMAKE_INSTALL_PREFIX="" /tmp/myscript-1.0-src && make &&
> DESTDIR=/home/erik make install
>
>
> >
> > I get the error:
> >
> > ----------
> > CMake Error at cmake_install.cmake:40 (FILE):
> > file cannot create directory: /opt/sbin. Maybe need administrative
> > privileges.
> > ----------
> >
> > Is there a way to a the same time fullfill these needs?
> > * the need to install files outside /usr in an rpm
>
> The question is do you need BOTH absolute and relative (to
> CMAKE_INSTALL_PREFIX) installed file in your project.
>
> > * the need for a non-root user to be able to install the software in
> > his home directory?
>
> Use either CMAKE_INSTALL_PREFIX if your project does not have
> absolute path file install or use DESTDIR if it does.
>
> If you use both your will have relative path installed file
> which will be in:
>
> <DESTDIR>/<CMAKE_INSTALL_PREFIX>/relativefile
>
> whereas absolute path installed file will be in:
>
> <DESTDIR>/abolute/path/file
>
> --
> Erk
>
Thanks for the info!
That works if the installed files are unmodified but what if I would
like to use
configure_file(InputFile OutputFile
[COPYONLY] [ESCAPE_QUOTES] [@ONLY])
to accomodate for e.g. the default location of a configure file?
configure_file() only has access to to CMAKE_INSTALL_PREFIX and not DESTDIR.
cheers,
Erik Sjölund
More information about the CMake
mailing list