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:
@@ -124,6 +124,7 @@ else()
|
||||
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}}")
|
||||
@@ -573,6 +574,9 @@ if(WITH_TURBOJPEG)
|
||||
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)
|
||||
@@ -1278,7 +1282,6 @@ endif()
|
||||
if(WIN32)
|
||||
set(EXE ".exe")
|
||||
endif()
|
||||
SET(CMAKE_INSTALL_RPATH ${LIBDIR})
|
||||
|
||||
if(WITH_TURBOJPEG)
|
||||
if(ENABLE_SHARED)
|
||||
|
||||
@@ -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