CMake: set rpath for shared objects

this ensures the correct library is loaded when the install path is not
in the default search path; this matches the behavior of
autoconf/libtool

Change-Id: I7eaa458c353cbdb7f0a1f782a879c59662a5de79
This commit is contained in:
James Zern 2022-07-25 16:48:00 -07:00
parent 94cd711779
commit b4994eaa6d

View File

@ -99,6 +99,12 @@ endif()
include(cmake/deps.cmake)
include(GNUInstallDirs)
if(BUILD_SHARED_LIBS AND NOT CMAKE_INSTALL_RPATH)
# Set the rpath to match autoconf/libtool behavior. Note this must be set
# before target creation.
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
endif()
# ##############################################################################
# Options.
if(WEBP_ENABLE_SWAP_16BIT_CSP)