Build: Fix RPATH handling
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.
This commit is contained in:
@@ -40,6 +40,9 @@ add_library(jpeg SHARED ${JPEG_SRCS} ${DEFFILE} $<TARGET_OBJECTS:simd>
|
||||
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user