CMake: Fix $ORIGIN rpaths to work when passed on the command line
The CMAKE_INSTALL_RPATH cache var had the PATH type, which made CMake transform the value into an absolute path, getting rid of the $ORIGIN value. Fix that by changing the cache var type to STRING. Also clean up the all-caps commands, add a usage example and print the install RPATH. Change-Id: Ibf40cfde4283369ddfcf52609143799cc8e47d68 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
parent
786b48878f
commit
e835a6853b
@ -101,18 +101,22 @@ if(NOT QT_MKSPECS_DIR)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# the default RPATH to be used when installing, but only if it's not a system directory
|
# the default RPATH to be used when installing, but only if it's not a system directory
|
||||||
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}" isSystemDir)
|
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}" isSystemDir)
|
||||||
IF("${isSystemDir}" STREQUAL "-1")
|
if("${isSystemDir}" STREQUAL "-1")
|
||||||
SET(_default_install_rpath "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}")
|
set(_default_install_rpath "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}")
|
||||||
ENDIF("${isSystemDir}" STREQUAL "-1")
|
endif("${isSystemDir}" STREQUAL "-1")
|
||||||
|
|
||||||
# Default rpath settings: Use rpath for build tree as well as a full path for the installed binaries.
|
# Default rpath settings: Use rpath for build tree as well as a full path for the installed binaries.
|
||||||
# For origin builds, one needs to override CMAKE_INSTALL_RPATH for example with $ORIGIN/../lib
|
# For origin builds, one needs to override CMAKE_INSTALL_RPATH for example with $ORIGIN/../lib
|
||||||
SET(CMAKE_INSTALL_RPATH "${_default_install_rpath}" CACHE PATH "RPATH for installed binaries")
|
# Example: -DCMAKE_INSTALL_RPATH=\$ORIGIN/../lib (backslash to escape the $ in the shell)
|
||||||
|
# Implementation note: the cache var must be STRING and not PATH or FILEPATH, otherwise CMake will
|
||||||
|
# transform the value into an absolute path, getting rid of '$ORIGIN'.
|
||||||
|
set(CMAKE_INSTALL_RPATH "${_default_install_rpath}" CACHE STRING "RPATH for installed binaries")
|
||||||
|
message(STATUS "Install RPATH set to: ${CMAKE_INSTALL_RPATH}")
|
||||||
|
|
||||||
# add the automatically determined parts of the RPATH
|
# add the automatically determined parts of the RPATH
|
||||||
# which point to directories outside the build tree to the install RPATH
|
# which point to directories outside the build tree to the install RPATH
|
||||||
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||||
|
|
||||||
# Generate a module description file based on the template in ModuleDescription.json.in
|
# Generate a module description file based on the template in ModuleDescription.json.in
|
||||||
function(qt_describe_module target)
|
function(qt_describe_module target)
|
||||||
|
Loading…
Reference in New Issue
Block a user