mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 19:00:54 -06:00
macOS: Restore RPATH entry for libraries linked from /usr/local/lib
Since commit 7b19531291 (macOS: Do not pass any SDK/-isysroot to
compilers by default, 2024-11-06, v4.0.0-rc1~511^2) our default
invocation of compilers targeting macOS no longer passes `-isysroot`.
Without that, Xcode's compilers search `-L/usr/local/lib` by default
even though the macOS dynamic loader does not. Since `/usr/local/lib`
is not a fully-implemented implicit link directory, exclude it from our
detected `CMAKE_<LANG>_IMPLICIT_LINK_LIBRARIES` so that our generators
do not suppress `RPATH` entries for dependencies in that directory.
Fixes: #26867
This commit is contained in:
@@ -256,6 +256,11 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Filter out implicit link directories excluded by our Platform/<os>* modules.
|
||||
if(DEFINED CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES_EXCLUDE)
|
||||
list(REMOVE_ITEM implicit_dirs ${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES_EXCLUDE})
|
||||
endif()
|
||||
|
||||
# Filter out implicit link directories excluded by the environment.
|
||||
if(DEFINED ENV{CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES_EXCLUDE})
|
||||
list(REMOVE_ITEM implicit_dirs $ENV{CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES_EXCLUDE})
|
||||
|
||||
@@ -292,4 +292,11 @@ if(NOT CMAKE_OSX_SYSROOT)
|
||||
RESULT_VARIABLE _result
|
||||
)
|
||||
unset(_sdk_macosx)
|
||||
|
||||
list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES_EXCLUDE
|
||||
# Without -isysroot, some compiler drivers implicitly pass -L/usr/local/lib
|
||||
# to the linker. Since the macOS dynamic loader does not search it by
|
||||
# default, it is not a fully-implemented implicit link directory.
|
||||
/usr/local/lib
|
||||
)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user