[CMake] Setting RPATH to install lib when building bin/lib in project

Albert Chin cmake at mlists.thewrittenword.com
Wed Jun 24 18:32:29 EDT 2009


I'm building OpenJPEG which uses cmake. It builds both a library and
binary. The binaries are linked to the library it builds. Both are
installed to a directory outside the normal ld search path so, rather
than setting LD_LIBRARY_PATH, I'd like to embed the installation library
into the RPATH of the installed binaries. I can do this with:
  cmake --debug-output --debug-trycompile . \
  -DCMAKE_LIBRARY_RPATH="[install dir]/lib"
  -DBUILD_SHARED_LIBS:BOOL=ON -DBUILD_EXAMPLES:BOOL=OFF \
  -DCMAKE_INSTALL_PREFIX:PATH=[install dir] \
  -DLIBDIR="[install dir]/lib/"

At install time, the binary is relinked, giving:
  cd /opt/build/OpenJPEG_v1_3/mj2 && /usr/bin/gcc  -Wall -std=c99 -O2
  -fPIC "CMakeFiles/wrap_j2k_in_mj2.dir/wrap_j2k_in_mj2.o"
  "CMakeFiles/wrap_j2k_in_mj2.dir/mj2.o"   -o
  CMakeFiles/CMakeRelink.dir/wrap_j2k_in_mj2 -rdynamic
  -L/opt/build/OpenJPEG_v1_3/bin -lopenjpeg -lm
  -Wl,-rpath,/opt/TWWfsw/libopenjpeg13/lib 

How do I replace -L/opt/build/OpenJPEG_v1_3/bin with
-L/opt/TWWfsw/libopenjpeg13/lib? This is necessary on HP-UX to record
the correct library path in the binary.

-- 
albert chin (china at thewrittenword.com)


More information about the CMake mailing list