CMAKE_INSTALL_RPATH has to be set before the targets are defined (oops.)
This also explicitly turns on MACOSX_RPATH for the shared libraries
(which is the default with newer versions of CMake but not with 2.8.x.)
The old autotools/libtool build system hard-coded the install name
directory of the OS X shared libraries to libdir, which meant that any
executable that linked against those libraries would also be hard-coded
to look for the libjpeg-turbo libraries in that directory. @rpath makes
the OS X version of libjpeg-turbo behave like the Linux version, in the
sense that the executables under /opt/libjpeg-turbo/bin will
automatically pick up the libraries under /opt/libjpeg-turbo/lib* by
default, but other executables won't unless they are linked with -rpath.
endif()
set(LIBDIR ${DEFAULT_LIBDIR} CACHE PATH
"Directory into which libraries should be installed (default: ${DEFAULT_LIBDIR})")
+set(CMAKE_INSTALL_RPATH ${LIBDIR})
foreach(var CMAKE_INSTALL_PREFIX BINDIR DATADIR DOCDIR INCLUDEDIR LIBDIR)
message(STATUS "${var} = ${${var}}")
if(MINGW)
set_target_properties(turbojpeg PROPERTIES LINK_FLAGS -Wl,--kill-at)
endif()
+ if(APPLE)
+ set_target_properties(turbojpeg PROPERTIES MACOSX_RPATH 1)
+ endif()
set_target_properties(turbojpeg PROPERTIES
SOVERSION ${TURBOJPEG_SO_MAJOR_VERSION} VERSION ${TURBOJPEG_SO_VERSION})
if(TJMAPFLAG)
if(WIN32)
set(EXE ".exe")
endif()
-SET(CMAKE_INSTALL_RPATH ${LIBDIR})
if(WITH_TURBOJPEG)
if(ENABLE_SHARED)
set_target_properties(jpeg PROPERTIES SOVERSION ${SO_MAJOR_VERSION}
VERSION ${SO_MAJOR_VERSION}.${SO_AGE}.${SO_MINOR_VERSION})
+if(APPLE)
+ set_target_properties(jpeg PROPERTIES MACOSX_RPATH 1)
+endif()
if(MAPFLAG)
set_target_properties(jpeg PROPERTIES
LINK_FLAGS "${MAPFLAG}${CMAKE_BINARY_DIR}/libjpeg.map")