Skip to content

Fix broken RPATH for Linux binaries

Ammar Nejati requested to merge a.fixRPATH into main
  • Due to recent changes, the RPATH was incorrectly set to, e.g., $$ORIGIN/../lib, with an extra $ -- the correct RPATH being $ORIGIN/../lib.

A minimal CMake example to reproduce the problem:

cmake_minimum_required(VERSION 3.20)

project(testLinkFlags LANGUAGES CXX)

set(link_flags "-Wl,-rpath,\$ORIGIN/../lib")

add_executable(test1 test.cpp)
set_target_properties(test1 PROPERTIES LINK_FLAGS ${link_flags})

add_executable(test2 test.cpp)
target_link_options(test2 PRIVATE ${link_flags})

Compare the RUNPATH attributes of the resulting binaries, test1 and test2 (e.g., readelf -d test1).
[verified with CMake 3.25.1 under Debian 12].

See https://gitlab.kitware.com/cmake/cmake/-/issues/25049.

  • Python3_ROOT_DIR is explicitly used as a hint for CMake to find the Python platform, to avoid any vagueness.
Edited by Ammar Nejati

Merge request reports