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 into a
destroot (which is not the final installation path).  In macports,
everything is installed into a "holding bay" that is defined by $DESTROOT.
>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/<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
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to