From 13d8de7c674aecb1e8e9e9a45fd82edef4dd2709 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Tue, 13 Oct 2026 11:20:12 +0000 Subject: build: relocate Homebrew bottle runtime search paths Co-Authored-By: Claude Fable 5.1 --- cmake/HomebrewPackages.cmake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'cmake') diff --git a/cmake/HomebrewPackages.cmake b/cmake/HomebrewPackages.cmake index edb40f4..30c0e70 100644 --- a/cmake/HomebrewPackages.cmake +++ b/cmake/HomebrewPackages.cmake @@ -77,6 +77,21 @@ function(cpsc_prepare_homebrew_packages) list(APPEND options -change "${old}" "${new}") endif() endforeach() + execute_process(COMMAND "${cpsc_otool}" -l "${binary}" + OUTPUT_VARIABLE commands ERROR_QUIET RESULT_VARIABLE result) + if(NOT result EQUAL 0) + message(FATAL_ERROR "Cannot inspect Mach-O load commands in ${binary}") + endif() + string(REGEX MATCHALL "cmd LC_RPATH\n[^\n]*\n[ \t]*path [^\n]+" rpaths "${commands}") + foreach(rpath IN LISTS rpaths) + string(REGEX REPLACE + "^cmd LC_RPATH\n[^\n]*\n[ \t]*path (.*) \\(offset [0-9]+\\)$" + "\\1" old "${rpath}") + cpsc_homebrew_path("${old}" new) + if(NOT old STREQUAL new) + list(APPEND options -rpath "${old}" "${new}") + endif() + endforeach() execute_process(COMMAND "${cpsc_otool}" -D "${binary}" OUTPUT_VARIABLE identity ERROR_QUIET) string(REGEX MATCH "\n([^\n]+)" match "${identity}") -- cgit v1.3.1-4-g156e