[CMake] Re: Howto create an empty directory during 'make install'?

Thomas Arcila thomas.arcila at imag.fr
Sat Nov 25 23:14:17 EST 2006


Hi,

DESTDIR at install time is not available as a CMake variable but as an
environment variable : you should access it using $ENV{DESTDIR}
Here is a line from FlowVR project (to be release with a complete
CMake build system in about a week):

INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_directory 
${CMAKE_CURRENT_SOURCE_DIR}/share 
\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/share/flowvr/glgraph)")

Symlinking should work the same way replacing copy_directory with 
create_symlink. 

To create an empty directory, one should use:
INSTALL(CODE "FILE(MAKE_DIRECTORY \${ENV}\${CMAKE_INSTALL_PREFIX}${mydir})")

Note that $ should be escaped so variables are not interpreted at generation 
time (at least for $ENV).

I hope this can help.

Thomas

Surlignage "Alan W. Irwin" <irwin at beluga.phys.uvic.ca>:
> Enrico said:
> 
> > | INSTALL(CODE "EXECUTE_PROCESS(COMMAND mkdir -p /var/lib/foo)")
> > 
> > and 'make install' works perfectly.
> > 
> > But 'make install DESTDIR=/var/tmp/foo-root' still fails with
> > 
> > | mkdir: cannot create directory /var/lib/foo': Permission denied
> 
> Hi Enrico:
> 
> I think the above will always create /var/lib/foo regardless of install
> prefix.  It would be better to use ${CMAKE_INSTALL_DATADIR}/foo (or wherever
> you really want to install foo underneath the installation prefix).
> 
> An even better possibility is to use the FILE(MAKE_DIRECTORY ...) to create
> an empty directory in the build tree, then use INSTALL(DIRECTORY ...)
> to install it.  I suspect your DESTDIR issue should go away then.
> 
> I worked on your other issue (creating a symlink in the install
> directory) since PLplot has an example.
> 
> Here is essentially what we did (which follows the style of what you
> did although with a specific prefixed installation directory):
> 
> set(DATA_DIR ${CMAKE_INSTALL_DATADIR}/share/plplot5.7.0)
> install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
> ../c/lena.pgm lena.pgm WORKING_DIRECTORY ${DATA_DIR}/examples/c++)")
> 
> and that worked fine for the usual "make install" regardless of the prefix
> we chose with the cmake -DCMAKE_INSTALL_DATADIR="..." option.
> 
> However, prompted by your remarks I just discovered it fails silently (at
> least for cmake-2.4.4) for the case of
> 
> make install DESTDIR=whatever
> 
> I have temporarily changed PLplot to install a copy of the file rather than
> a symlink until this issue is resolved.
> 
> To recap, I think FILE(MAKE_DIRECTORY ...) then INSTALL(DIRECTORY ...)
> should work for the empty directory case. However, there appears to be no
> similar solution available for installed symlinks.  For example, it is easy
> to create a symlink in the build tree using cmake -E create_symlink, but I
> can find no INSTALL signature that will install it properly.  Thus, the only
> recourse seems to be INSTALL(CODE ...) tricks, but then DESTDIR appears not
> to be supported by such low-level code.
> 
> Does anybody know how to make a symlink in the install tree with DESTDIR
> supported? In the above case lena.pgm is a relatively large image so I
> much prefer a symlink to the (current) file copy I am using to work around
> the problem.
> 
> 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 Yorick front-end to PLplot (yplot.sf.net); the
> Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project
> (lbproject.sf.net).
> __________________________
> 
> Linux-powered Science
> __________________________
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
> 




-------------------------------------------------
envoyé via Webmail/IMAG !



More information about the CMake mailing list