Re: [CMake] cmake variables to control full path in shared lib on OSX

2008-09-19 Thread Martin Costabel

Darren Weber wrote:

I'm exploring how to build and install VTK-5-2-0 on OSX.  I'm trying
to use shared libraries, but the default settings do not put full
paths in the .dylib file links for the libvtk* libraries.  I am using
a non-standard install path (macports /opt/local), so I may need to
set full paths for the libvtk* links.  For example, this is just one
of the dylib files and I may need all the links to libvtk* to contain
the full path (/opt/local/lib/vtk-5.2/):

[]

What are the right cmake variables that will enable full paths in the
shared libraries?


Here is what works for me (I am creating a Fink package, which is a very 
similar situation to yours):


  -DBUILD_SHARED_LIBS:BOOL=ON \
  -DVTK_INSTALL_LIB_DIR:STRING=/lib/vtk52 \
  -DCMAKE_INSTALL_PREFIX:PATH=%p \
  -DCMAKE_INSTALL_NAME_DIR:STRING=%p/lib/vtk52 \
  -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=ON \
  -DVTK_USE_RPATH=ON \

Here %p corresponds to your ${prefix}. There is one catch, however:

VTK builds a couple of executables that are used during building like 
ProcessShader. If you use the above flags, these executables will 
crash, because they look for the dylibs they are linked with at their 
install location, where they are not yet installed. They must be told to 
look for the dylibs in the build tree instead.


Gnu libtool has a mechanism to deal with this situation (creating 
temporary wrapper scripts for each executable), but if cmake has one, I 
haven't found it. What works for me is to set


 export DYLD_FALLBACK_LIBRARY_PATH=`pwd`/bin

after the cmake run, just before running `make`. This uses the fact that 
the dylibs are built in the same directory build/bin as the executables. 
But it is not an optimal workaround, because if you have an older 
version of vtk installed, the binaries will find these older versions 
first and perhaps not run either. Setting DYLD_LIBRARY_PATH instead of 
DYLD_FALLBACK_LIBRARY_PATH has too many side effects to be usable.


--
Martin

___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] cmake variables to control full path in shared lib on OSX

2008-09-19 Thread Martin Costabel

Darren Weber wrote:
[]

Gnu libtool has a mechanism to deal with this situation (creating temporary
wrapper scripts for each executable), but if cmake has one, I haven't found
it. 



I have a testing build that seems to create paths within the build
tree that are specific to the build, but once they are installed all
the paths are updated to the install path, ie:


It works for me now, too, without using DYLD_FALLBACK_LIBRARY_PATH. I 
thought I had tried all other possible combinations without success, but 
now I tried the most obvious again, and it did what it was supposed to. 
The flags are now


   -DBUILD_SHARED_LIBS:BOOL=ON \
   -DVTK_INSTALL_LIB_DIR:STRING=/lib/vtk52 \
   -DCMAKE_INSTALL_PREFIX:PATH=%p \
   -DCMAKE_INSTALL_NAME_DIR:STRING=%p/lib/vtk52 \
   -DVTK_USE_RPATH=ON \
   -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF \
   -DCMAKE_INSTALL_RPATH:STRING=${CMAKE_INSTALL_NAME_DIR} \

Maybe the upgrade to cmake-2.6.2_rc4 helped. The nice thing about the 
latest cmake version is that it defines a reasonable 
compatibility_version now, such as:


otool -L /sw/lib/vtk52-cocoa//libvtkInfovisTCL.5.2.0.dylib
/sw//lib/vtk52-cocoa//libvtkInfovisTCL.5.2.0.dylib:
	/sw/lib/vtk52-cocoa/libvtkInfovisTCL.5.2.dylib (compatibility version 
5.2.0, current version 5.2.0)
	/sw/lib/vtk52-cocoa/libvtkInfovis.5.2.dylib (compatibility version 
5.2.0, current version 5.2.0)
	/sw/lib/vtk52-cocoa/libvtkWidgetsTCL.5.2.dylib (compatibility version 
5.2.0, current version 5.2.0)


etc.

--
Martin





___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


[CMake] cmake variables to control full path in shared lib on OSX

2008-09-18 Thread Darren Weber
I'm exploring how to build and install VTK-5-2-0 on OSX.  I'm trying
to use shared libraries, but the default settings do not put full
paths in the .dylib file links for the libvtk* libraries.  I am using
a non-standard install path (macports /opt/local), so I may need to
set full paths for the libvtk* links.  For example, this is just one
of the dylib files and I may need all the links to libvtk* to contain
the full path (/opt/local/lib/vtk-5.2/):

[ [EMAIL PROTECTED] ~/src/kitware/VTK_build ]$ otool -L
/opt/local/lib/vtk-5.2/libvtkViewsTCL.5.2.0.dylib
/opt/local/lib/vtk-5.2/libvtkViewsTCL.5.2.0.dylib:
libvtkViewsTCL.5.2.dylib (compatibility version 0.0.0, current version 
0.0.0)
snip, block of libvtk*
libvtkzlib.5.2.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.1)
/opt/local/lib/libhistory.5.2.dylib (compatibility version 5.0.0,
current version 5.2.0)
/opt/local/lib/libreadline.5.2.dylib (compatibility version 5.0.0,
current version 5.2.0)
libvtkGraphicsTCL.5.2.dylib (compatibility version 0.0.0, current
version 0.0.0)
snip, block of libvtk*
libvtkCommon.5.2.dylib (compatibility version 0.0.0, current version 
0.0.0)
/System/Library/Frameworks/Tcl.framework/Versions/8.4/Tcl
(compatibility version 8.4.0, current version 8.4.0)
libvtkfreetype.5.2.dylib (compatibility version 0.0.0, current version 
0.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)
libvtkexoIIc.5.2.dylib (compatibility version 0.0.0, current version 
0.0.0)
snip, block of libvtk*
libvtksys.5.2.dylib (compatibility version 0.0.0, current version 0.0.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)
[ [EMAIL PROTECTED] ~/src/kitware/VTK_build ]$


What are the right cmake variables that will enable full paths in the
shared libraries?

Potential candidates:

CMAKE_INSTALL_NAME_DIR  (eg: /opt/local/lib/vtk-5.2 ?)
CMAKE_SKIP_BUILD_RPATH (FALSE?)
CMAKE_SKIP_RPATH (FALSE?)

CMAKE_INSTALL_RPATH   (eg: /opt/local/lib/vtk-5.2 ?)
CMAKE_INSTALL_RPATH_USE_LINK_PATH  (TRUE?)

CMAKE_BUILD_WITH_INSTALL_RPATH (True?)


When I configured the build with just a switch to turn on shared libs,
then checked CMakeCache.txt, I can't see that any of these were set,
ie:

[ [EMAIL PROTECTED] ~/src/kitware/VTK_build ]$ cat CMakeCache.txt | grep RPATH
VTK_USE_RPATH:BOOL=OFF
//Advanced flag for variable: CMAKE_SKIP_RPATH
CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1
CMAKE_SKIP_RPATH:INTERNAL=1
//Advanced flag for variable: VTK_USE_RPATH
VTK_USE_RPATH-ADVANCED:INTERNAL=1


I then set VTK_USE_RPATH=ON and built again.  This time I got the
wrong paths because I had set CMAKE_INSTALL_NAME_DIR=/opt/local/lib/

[ [EMAIL PROTECTED] ~/src/kitware/VTK_build ]$ otool -L
/opt/local/lib/vtk-5.2/libvtkInfovisTCL.5.2.0.dylib
/opt/local/lib/vtk-5.2/libvtkInfovisTCL.5.2.0.dylib:
/opt/local/lib/libvtkInfovisTCL.5.2.dylib (compatibility version
0.0.0, current version 0.0.0)
/opt/local/lib/libvtkInfovis.5.2.dylib (compatibility version 0.0.0,
current version 0.0.0)
etc.

So I changed CMAKE_INSTALL_NAME_DIR=${prefix}/lib/vtk-5.2 and it
seems right now:

[ [EMAIL PROTECTED] ~/src/kitware/VTK_build ]$ otool -L
/opt/local/lib/vtk-5.2/libvtkInfovisTCL.5.2.0.dylib
/opt/local/lib/vtk-5.2/libvtkInfovisTCL.5.2.0.dylib:
/opt/local/lib/vtk-5.2/libvtkInfovisTCL.5.2.dylib (compatibility
version 0.0.0, current version 0.0.0)
/opt/local/lib/vtk-5.2/libvtkInfovis.5.2.dylib (compatibility version
0.0.0, current version 0.0.0)
/opt/local/lib/vtk-5.2/libvtkWidgetsTCL.5.2.dylib (compatibility
version 0.0.0, current version 0.0.0)
etc.


Are there any major problems with using this installation approach for
the vtk 5.2 library in the macports path?

As a noob to RPATH, I found these links informative:
http://en.wikipedia.org/wiki/Rpath_(linking)
http://wiki.debian.org/RpathIssue
http://www.the-martins.org/index.php?name=Sectionsreq=viewarticleartid=6allpages=1


Thanks, Darren
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake