From 6349e94a0a4fe361ad78921ff84bfe3be94b2028 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Thu, 10 Mar 2022 23:11:14 +0300 Subject: [PATCH] Do not install RPATH for install tree by default In ce8be2385b5fee16859a630fca0c98ad290c8e21 ("cmake: set rpath for libraries on linux") RPATH was first instroduced. Later in 6d09efe8686de824adf3d8810bbe0d5c386643e4 ("Set RPATH only if installation is done into non system directory") it was set only if it was installed to non system directory. But absolute RPATH not a good default, let's change this. Fixes: #920 --- CMakeLists.txt | 1 + PreLoad.cmake | 7 +++++++ test-export/test-export.py | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 PreLoad.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index ffe7aa58..aeb8ce7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1670,6 +1670,7 @@ message(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}") message(STATUS "CMAKE_SYSTEM_VERSION: ${CMAKE_SYSTEM_VERSION}") message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}") message(STATUS "CMAKE_SKIP_RPATH: ${CMAKE_SKIP_RPATH}") +message(STATUS "CMAKE_SKIP_INSTALL_RPATH: ${CMAKE_SKIP_INSTALL_RPATH}") message(STATUS "CMAKE_INSTALL_RPATH: ${CMAKE_INSTALL_RPATH}") message(STATUS "CMAKE_VERBOSE_MAKEFILE: ${CMAKE_VERBOSE_MAKEFILE}") message(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}") diff --git a/PreLoad.cmake b/PreLoad.cmake new file mode 100644 index 00000000..d1b739cc --- /dev/null +++ b/PreLoad.cmake @@ -0,0 +1,7 @@ +# Disable RPATH for install tree by default. +# +# PreLoad is used to change the default, since CMakeLists.txt will already have +# the default, and it will NO. +if (NOT DEFINED CMAKE_SKIP_INSTALL_RPATH) + set(CMAKE_SKIP_INSTALL_RPATH ON CACHE STRING "" FORCE) +endif() diff --git a/test-export/test-export.py b/test-export/test-export.py index a6def1ca..3320e3b2 100644 --- a/test-export/test-export.py +++ b/test-export/test-export.py @@ -176,7 +176,7 @@ if platform.system() == "Windows": dllpath = os.path.join(prefix, "lib") else: prefix = "/usr/local" -exec_cmd('cmake -DCMAKE_INSTALL_PREFIX="%s" ..' % prefix, True) +exec_cmd('cmake -DCMAKE_SKIP_INSTALL_RPATH=OFF -DCMAKE_INSTALL_PREFIX="%s" ..' % prefix, True) exec_cmd('cmake --build . --target install', True) config_backup() os.environ["CMAKE_PREFIX_PATH"] = os.path.join(prefix, "lib/cmake/libevent") @@ -191,7 +191,7 @@ del os.environ["CMAKE_PREFIX_PATH"] print("[test-export] test for install tree(in non-system-wide path)") exec_cmd("cmake --build . --target uninstall", True) tempdir = tempfile.TemporaryDirectory() -cmd = 'cmake -DCMAKE_INSTALL_PREFIX="%s" ..' % tempdir.name +cmd = 'cmake -DCMAKE_SKIP_INSTALL_RPATH=OFF -DCMAKE_INSTALL_PREFIX="%s" ..' % tempdir.name exec_cmd(cmd, True) exec_cmd("cmake --build . --target install", True) config_backup() -- 2.40.0