summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-04-15 11:13:46 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-04-15 11:43:02 +0200
commite835a6853b9c0fb7af32798ed8965de3adf0e15b (patch)
treed7019762dbc267e72a819d2d209c067d84688c4f
parent786b48878f37edafd5eb928ed0f4d046ee1d6bec (diff)
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>
-rw-r--r--cmake/QtBuild.cmake16
1 files changed, 10 insertions, 6 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index bb848ead40..765b5fb961 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -101,18 +101,22 @@ if(NOT QT_MKSPECS_DIR)
endif()
# 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)
-IF("${isSystemDir}" STREQUAL "-1")
- SET(_default_install_rpath "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}")
-ENDIF("${isSystemDir}" STREQUAL "-1")
+list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}" isSystemDir)
+if("${isSystemDir}" STREQUAL "-1")
+ set(_default_install_rpath "${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}")
+endif("${isSystemDir}" STREQUAL "-1")
# 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
-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
# 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
function(qt_describe_module target)