No subject


Thu Apr 9 10:40:16 EDT 2009


the port files, and then all the files in a port are moved into
/opt/local/var/macports/software/<port> and from there they are hard linked
into the prefix /opt/local (with most paths below that mapping to the
conventional /usr/local paths, such as /opt/local/lib, /opt/local/include).
To avoid using any environment variables for the dynamic loader, all the
dynamic libraries need to set the rpath (or install_name).  Hence, the
configuration for several vtk ports contains an assortment of cmake
variables to set the install_name and/or rpath.

Here is a snippet of some cmake command line settings for the vtk port
(vtk-4.4.2) in macports:

        -D BUILD_SHARED_LIBS:BOOL=ON \
        -D CMAKE_INSTALL_PREFIX:PATH=${prefix} \
        -D CMAKE_SKIP_RPATH:BOOL=OFF \
        -D CMAKE_INSTALL_NAME_DIR:STRING=${prefix}/lib/vtk \
        -D CMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON

With these settings, we get this result in the $DESTROOT:

$ otool -L ${DESTROOT}/opt/local/lib/vtk/libvtkRendering.dylib
destroot/opt/local/lib/vtk/libvtkRendering.dylib:
    /opt/local/lib/vtk/libvtkRendering.dylib (compatibility version 0.0.0,
current version 0.0.0)
    /opt/local/lib/vtk/libvtkGraphics.dylib (compatibility version 0.0.0,
current version 0.0.0)
    /opt/local/lib/vtk/libvtkImaging.dylib (compatibility version 0.0.0,
current version 0.0.0)
    /opt/local/lib/vtk/libvtkIO.dylib (compatibility version 0.0.0, current
version 0.0.0)
    /opt/local/lib/vtk/libvtkftgl.dylib (compatibility version 0.0.0,
current version 0.0.0)
    /opt/local/lib/vtk/libvtkfreetype.dylib (compatibility version 0.0.0,
current version 0.0.0)
    /System/Library/Frameworks/AGL.framework/Versions/A/AGL (compatibility
version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
(compatibility version 1.0.0, current version 1.0.0)
    /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
(compatibility version 1.0.0, current version 12.0.0)
    /opt/local/lib/vtk/libvtkFiltering.dylib (compatibility version 0.0.0,
current version 0.0.0)
    /opt/local/lib/vtk/libvtkCommon.dylib (compatibility version 0.0.0,
current version 0.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
111.1.3)
    /opt/local/lib/vtk/libvtkDICOMParser.dylib (compatibility version 0.0.0,
current version 0.0.0)
    /opt/local/lib/vtk/libvtkpng.dylib (compatibility version 0.0.0, current
version 0.0.0)
    /opt/local/lib/vtk/libvtktiff.dylib (compatibility version 0.0.0,
current version 0.0.0)
    /opt/local/lib/vtk/libvtkzlib.dylib (compatibility version 0.0.0,
current version 0.0.0)
    /opt/local/lib/vtk/libvtkjpeg.dylib (compatibility version 0.0.0,
current version 0.0.0)
    /opt/local/lib/vtk/libvtkexpat.dylib (compatibility version 0.0.0,
current version 0.0.0)
    /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
(compatibility version 45.0.0, current version 949.43.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version
7.4.0)
    /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version
1.0.0)


Notice how this dylib has been installed under
${DESTROOT}/opt/local/lib/vtk, ie ${DESTROOT}/${INSTALL_NAME_DIR}, yet all
the rpath settings are specified correctly for the final installation
destination into ${INSTALL_NAME_DIR}, which is handled by macports not by
cmake or gmake.  This process works during both the linking during the build
phase and for the dynamic loader after the final installation under
/opt/local/.

Here is a snippet of some cmake command line settings for the vtk5 port
(vtk-5.2.1) in macports:

        -D BUILD_SHARED_LIBS:BOOL=ON \
        -D VTK_USE_RPATH:BOOL=ON \
        -D CMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON \
        -D CMAKE_INSTALL_RPATH:STRING=${prefix}/lib/vtk-5.2 \
        -D CMAKE_INSTALL_NAME_DIR:STRING=${prefix}/lib/vtk-5.2 \
        -D CMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=ON \
        -D CMAKE_LIBRARY_PATH:PATH=${prefix}/lib \
        -D CMAKE_INCLUDE_PATH:PATH=${prefix}/include \
        -D CMAKE_INSTALL_PREFIX:PATH=${prefix} \
        -D VTK_INSTALL_PREFIX:PATH=${prefix} \

Despite reading the output of 'cmake -LAH <srcpath>' and the documentation
in the Cmake book, the meaning and interactions among these variable
settings remains obscure to me, in the context of the macports DESTROOT
installation.

Any help from CMake experts to understand the optimal way to set these
variables would be greatly appreciated, in the context of a pseudo destroot
installation, with rpath on for both the dylibs and the executables (eg:
examples).  Of most help would be a simple explanation of (a) when these
variables are applied during the build or install phase and (b) how these
variables interact with each other (if at all).

Of the variables that I've found documented, those above and the following
appear to be relevant:

CMAKE_BUILD_WITH_INSTALL_RPATH
CMAKE_INSTALL_NAME_DIR
CMAKE_INSTALL_RPATH
CMAKE_INSTALL_RPATH_USE_LINK_PATH
CMAKE_SKIP_RPATH
CMAKE_SKIP_BUILD_RPATH
VTK_USE_RPATH

CMAKE_RUNTIME_OUTPUT_DIRECTORY
CMAKE_LIBRARY_OUTPUT_DIRECTORY
CMAKE_LIBRARY_PATH_FLAG
CMAKE_LINK_LIBRARY_FLAG
EXECUTABLE_OUTPUT_PATH
LIBRARY_OUTPUT_PATH
CMAKE_DL_LIBS


Many thanks, Darren

--0016e644de5e79bb840468904a00
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br>I need to understand how to use CMake command line variables to specify=
 the install name and rpath settings when building VTK and installing it in=
to a destroot (which is not the final installation path).=C2=A0 In macports=
, everything is installed into a &quot;holding bay&quot; that is defined by=
 $DESTROOT.=C2=A0 From the temporary $DESTROOT installation, macports does =
some analysis of the port files, and then all the files in a port are moved=
 into /opt/local/var/macports/software/&lt;port&gt; and from there they are=
 hard linked into the prefix /opt/local (with most paths below that mapping=
 to the conventional /usr/local paths, such as /opt/local/lib, /opt/local/i=
nclude).=C2=A0 To avoid using any environment variables for the dynamic loa=
der, all the dynamic libraries need to set the rpath (or install_name).=C2=
=A0 Hence, the configuration for several vtk ports contains an assortment o=
f cmake variables to set the install_name and/or rpath.<br>
<br>Here is a snippet of some cmake command line settings for the vtk port =
(vtk-4.4.2) in macports:<br><br><font size=3D"2"><span style=3D"font-family=
: courier new,monospace;">=C2=A0 =C2=A0=C2=A0 =C2=A0=C2=A0 -D BUILD_SHARED_=
LIBS:BOOL=3DON \</span><br style=3D"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 =C2=
=A0=C2=A0=C2=A0 -D CMAKE_INSTALL_PREFIX:PATH=3D${prefix} \</span><br style=
=3D"font-family: courier new,monospace;"><span style=3D"font-family: courie=
r new,monospace;">=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 -D CMAKE_SKIP_RPATH=
:BOOL=3DOFF \</span><br style=3D"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 =C2=
=A0=C2=A0=C2=A0 -D CMAKE_INSTALL_NAME_DIR:STRING=3D${prefix}/lib/vtk \</spa=
n><br style=3D"font-family: courier new,monospace;"><span style=3D"font-fam=
ily: courier new,monospace;">=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 -D CMAKE=
_BUILD_WITH_INSTALL_RPATH:BOOL=3DON</span></font><br>
<br>With these settings, we get this result in the $DESTROOT:<br><br><font =
size=3D"1"><span style=3D"font-family: courier new,monospace;">$ otool -L $=
{DESTROOT}/opt/local/lib/vtk/libvtkRendering.dylib </span><br style=3D"font=
-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">destroot/opt/local/lib/=
vtk/libvtkRendering.dylib:</span><br style=3D"font-family: courier new,mono=
space;"><span style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=
=A0 /opt/local/lib/vtk/libvtkRendering.dylib (compatibility version 0.0.0, =
current version 0.0.0)</span><br style=3D"font-family: courier new,monospac=
e;">
<span style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /opt=
/local/lib/vtk/libvtkGraphics.dylib (compatibility version 0.0.0, current v=
ersion 0.0.0)</span><br style=3D"font-family: courier new,monospace;"><span=
 style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /opt/loca=
l/lib/vtk/libvtkImaging.dylib (compatibility version 0.0.0, current version=
 0.0.0)</span><br style=3D"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /opt=
/local/lib/vtk/libvtkIO.dylib (compatibility version 0.0.0, current version=
 0.0.0)</span><br style=3D"font-family: courier new,monospace;"><span style=
=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /opt/local/lib/=
vtk/libvtkftgl.dylib (compatibility version 0.0.0, current version 0.0.0)</=
span><br style=3D"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /opt=
/local/lib/vtk/libvtkfreetype.dylib (compatibility version 0.0.0, current v=
ersion 0.0.0)</span><br style=3D"font-family: courier new,monospace;"><span=
 style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /System/L=
ibrary/Frameworks/AGL.framework/Versions/A/AGL (compatibility version 1.0.0=
, current version 1.0.0)</span><br style=3D"font-family: courier new,monosp=
ace;">
<span style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /Sys=
tem/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL (compatibility ve=
rsion 1.0.0, current version 1.0.0)</span><br style=3D"font-family: courier=
 new,monospace;">
<span style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /Sys=
tem/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility vers=
ion 1.0.0, current version 12.0.0)</span><br style=3D"font-family: courier =
new,monospace;">
<span style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /opt=
/local/lib/vtk/libvtkFiltering.dylib (compatibility version 0.0.0, current =
version 0.0.0)</span><br style=3D"font-family: courier new,monospace;"><spa=
n style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /opt/loc=
al/lib/vtk/libvtkCommon.dylib (compatibility version 0.0.0, current version=
 0.0.0)</span><br style=3D"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /usr=
/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.=
3)</span><br style=3D"font-family: courier new,monospace;"><span style=3D"f=
ont-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /opt/local/lib/vtk/l=
ibvtkDICOMParser.dylib (compatibility version 0.0.0, current version 0.0.0)=
</span><br style=3D"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /opt=
/local/lib/vtk/libvtkpng.dylib (compatibility version 0.0.0, current versio=
n 0.0.0)</span><br style=3D"font-family: courier new,monospace;"><span styl=
e=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /opt/local/lib=
/vtk/libvtktiff.dylib (compatibility version 0.0.0, current version 0.0.0)<=
/span><br style=3D"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /opt=
/local/lib/vtk/libvtkzlib.dylib (compatibility version 0.0.0, current versi=
on 0.0.0)</span><br style=3D"font-family: courier new,monospace;"><span sty=
le=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /opt/local/li=
b/vtk/libvtkjpeg.dylib (compatibility version 0.0.0, current version 0.0.0)=
</span><br style=3D"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /opt=
/local/lib/vtk/libvtkexpat.dylib (compatibility version 0.0.0, current vers=
ion 0.0.0)</span><br style=3D"font-family: courier new,monospace;"><span st=
yle=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /System/Libr=
ary/Frameworks/AppKit.framework/Versions/C/AppKit (compatibility version 45=
.0.0, current version 949.43.0)</span><br style=3D"font-family: courier new=
,monospace;">
<span style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /usr=
/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)=
</span><br style=3D"font-family: courier new,monospace;"><span style=3D"fon=
t-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0 /usr/lib/libgcc_s.1.dy=
lib (compatibility version 1.0.0, current version 1.0.0)</span></font><br>
<br><br>Notice how this dylib has been installed under ${DESTROOT}/opt/loca=
l/lib/vtk, ie ${DESTROOT}/${INSTALL_NAME_DIR}, yet all the rpath settings a=
re specified correctly for the final installation destination into ${INSTAL=
L_NAME_DIR}, which is handled by macports not by cmake or gmake.=C2=A0 This=
 process works during both the linking during the build phase and for the d=
ynamic loader after the final installation under /opt/local/.<br>
<br>Here is a snippet of some cmake command line settings for the vtk5 port=
 (vtk-5.2.1) in macports:<br>
<br><span style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 -D BUILD_SHARED_LIBS:BOOL=3DON \</span><br style=
=3D"font-family: courier new,monospace;"><span style=3D"font-family: courie=
r new,monospace;">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -D VTK_USE_RPA=
TH:BOOL=3DON \</span><br style=3D"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 -D CMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=3DON \</span><=
br style=3D"font-family: courier new,monospace;"><span style=3D"font-family=
: courier new,monospace;">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -D CMA=
KE_INSTALL_RPATH:STRING=3D${prefix}/lib/vtk-5.2 \</span><br style=3D"font-f=
amily: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 -D CMAKE_INSTALL_NAME_DIR:STRING=3D${prefix}/lib/vtk-=
5.2 \</span><br style=3D"font-family: courier new,monospace;"><span style=
=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0 -D CMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=3DON \</span><br style=
=3D"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 -D CMAKE_LIBRARY_PATH:PATH=3D${prefix}/lib \</span><b=
r style=3D"font-family: courier new,monospace;"><span style=3D"font-family:=
 courier new,monospace;">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -D CMAK=
E_INCLUDE_PATH:PATH=3D${prefix}/include \</span><br style=3D"font-family: c=
ourier new,monospace;">
<span style=3D"font-family: courier new,monospace;">=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 -D CMAKE_INSTALL_PREFIX:PATH=3D${prefix} \</span><br =
style=3D"font-family: courier new,monospace;"><span style=3D"font-family: c=
ourier new,monospace;">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 -D VTK_IN=
STALL_PREFIX:PATH=3D${prefix} \</span><br style=3D"font-family: courier new=
,monospace;">
<br>Despite reading the output of &#39;cmake -LAH &lt;srcpath&gt;&#39; and =
the documentation in the Cmake book, the meaning and interactions among the=
se variable settings remains obscure to me, in the context of the macports =
DESTROOT installation.<br>
<br>Any help from CMake experts to understand the optimal way to set these =
variables would be greatly appreciated, in the context of a pseudo destroot=
 installation, with rpath on for both the dylibs and the executables (eg: e=
xamples).=C2=A0 Of most help would be a simple explanation of (a) when thes=
e variables are applied during the build or install phase and (b) how these=
 variables interact with each other (if at all).<br>
<br>Of the variables that I&#39;ve found documented, those above and the fo=
llowing appear to be relevant:<br><br><span style=3D"font-family: courier n=
ew,monospace;">CMAKE_BUILD_WITH_INSTALL_RPATH</span><br style=3D"font-famil=
y: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">CMAKE_INSTALL_NAME_DIR<=
/span><br style=3D"font-family: courier new,monospace;"><span style=3D"font=
-family: courier new,monospace;">CMAKE_INSTALL_RPATH</span><br style=3D"fon=
t-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">CMAKE_INSTALL_RPATH_USE=
_LINK_PATH</span><br style=3D"font-family: courier new,monospace;"><span st=
yle=3D"font-family: courier new,monospace;">CMAKE_SKIP_RPATH</span><br styl=
e=3D"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">CMAKE_SKIP_BUILD_RPATH<=
/span><br style=3D"font-family: courier new,monospace;"><span style=3D"font=
-family: courier new,monospace;">VTK_USE_RPATH</span><br style=3D"font-fami=
ly: courier new,monospace;">
<br style=3D"font-family: courier new,monospace;"><span style=3D"font-famil=
y: courier new,monospace;">CMAKE_RUNTIME_OUTPUT_DIRECTORY</span><br style=
=3D"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">CMAKE_LIBRARY_OUTPUT_DI=
RECTORY</span><br style=3D"font-family: courier new,monospace;"><span style=
=3D"font-family: courier new,monospace;">CMAKE_LIBRARY_PATH_FLAG</span><br =
style=3D"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">CMAKE_LINK_LIBRARY_FLAG=
</span><br style=3D"font-family: courier new,monospace;"><span style=3D"fon=
t-family: courier new,monospace;">EXECUTABLE_OUTPUT_PATH</span><br style=3D=
"font-family: courier new,monospace;">
<span style=3D"font-family: courier new,monospace;">LIBRARY_OUTPUT_PATH</sp=
an><br style=3D"font-family: courier new,monospace;"><span style=3D"font-fa=
mily: courier new,monospace;">CMAKE_DL_LIBS</span><br><br><br>Many thanks, =
Darren<br>
<br>

--0016e644de5e79bb840468904a00--


More information about the CMake mailing list