Discussion:
[CMake] Howto create an empty directory during 'make install'?
Enrico Scholz
2006-11-25 11:39:03 UTC
Permalink
Hello,

how can I create an empty directory during 'make install'? With ordinary
make I would write:

| install-data-local:
| mkdir -p ${DESTDIR}${mydir}


How can I do this with cmake?

Ditto, how can I create symlinks like

| ${DESTDIR}${bindir}/foo -> foo-1


I tried things like

| INSTALL(CODE "EXECUTE_PROCESS(COMMAND mkdir -p ${DESTDIR}${mydir})")

but '${DESTDIR}' was not expanded by 'make install DESTDIR=/tmp/foo' and
cmake tried to make the directory in the top filesystem.



Enrico
Alan W. Irwin
2006-11-25 17:22:11 UTC
Permalink
Post by Enrico Scholz
how can I create an empty directory during 'make install'? With ordinary
| mkdir -p ${DESTDIR}${mydir}
How can I do this with cmake?
Ditto, how can I create symlinks like
| ${DESTDIR}${bindir}/foo -> foo-1
I tried things like
| INSTALL(CODE "EXECUTE_PROCESS(COMMAND mkdir -p ${DESTDIR}${mydir})")
but '${DESTDIR}' was not expanded by 'make install DESTDIR=/tmp/foo' and
cmake tried to make the directory in the top filesystem.
I suggest you drop all mention of DESTDIR within cmake or trying anything
special to beat the system. Instead work on getting a normal install to
work properly. My experience with cmake is that once the normal "make
install" works properly, then

make install DESTDIR='/temporary/staging/area'

works fine as well.

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
__________________________
Enrico Scholz
2006-11-25 17:47:04 UTC
Permalink
"Alan W. Irwin"
Post by Alan W. Irwin
Post by Enrico Scholz
how can I create an empty directory during 'make install'? With ordinary
| mkdir -p ${DESTDIR}${mydir}
How can I do this with cmake?
...
I suggest you drop all mention of DESTDIR within cmake or trying anything
special to beat the system.
Sorry, I do not see how this helps for the current problem.



Enrico
Alan W. Irwin
2006-11-25 19:23:31 UTC
Permalink
Post by Enrico Scholz
"Alan W. Irwin"
Post by Alan W. Irwin
Post by Enrico Scholz
how can I create an empty directory during 'make install'? With ordinary
| mkdir -p ${DESTDIR}${mydir}
How can I do this with cmake?
...
I suggest you drop all mention of DESTDIR within cmake or trying anything
special to beat the system.
Sorry, I do not see how this helps for the current problem.
I am pretty sure you already know this, but just to make sure, DESTDIR has a
special meaning for both autotools-related and cmake-related projects. It's
a temporary staging area used for e.g., rpm and deb generation. For
autotools, you often have to worry about the DESTDIR details in your
Makefile.am files to make sure "make install DESTDIR=/my/staging/area" works
properly.

In contrast for CMake, my experience is that once you have configured cmake
so that an ordinary "make install" works, then "make install
DESTDIR=/my/staging/area" just works as well without having to worry about
any DESTDIR details from within cmake.

Your post seemed focussed on such DESTDIR details from within cmake.
Instead, I suggest you temporarily forget about DESTDIR functionality and
instead concentrate on the simpler problem of configuring cmake so that the
ordinary "make install" works properly (i.e., empty directory and symlinks
installed in the correct place relative to your install prefix). Once you
have a good "make install" result with cmake, then I believe "make install
DESTDIR=/my/staging/area" should just work to create a temporary staging
area suitable for rpm and deb building.

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
__________________________
Enrico Scholz
2006-11-25 19:41:07 UTC
Permalink
"Alan W. Irwin"
Post by Alan W. Irwin
Post by Enrico Scholz
how can I create an empty directory during 'make install'?
...
Instead, I suggest you temporarily forget about DESTDIR functionality
and instead concentrate on the simpler problem of configuring cmake so
that the ordinary "make install" works properly
ok, I have now

| 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


Ditto for the symlink case.



Enrico
Alan W. Irwin
2006-11-26 00:51:41 UTC
Permalink
Post by Enrico Scholz
| 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
__________________________
Thomas Arcila
2006-11-26 04:14:17 UTC
Permalink
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
Post by Alan W. Irwin
Post by Enrico Scholz
| 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
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
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
http://www.cmake.org/mailman/listinfo/cmake
-------------------------------------------------
envoy� via Webmail/IMAG !

Loading...