Skip to content

Commit

Permalink
Set lld as macOS linker only if SDK is greater or equal to 15
Browse files Browse the repository at this point in the history
  • Loading branch information
Robertorosmaninho committed Dec 16, 2024
1 parent dafdb9a commit b4cbd35
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions cmake/FixHomebrew.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ if(APPLE)
link_directories(AFTER "${BREW_PREFIX}/lib")
set(ENV{PKG_CONFIG_PATH} "${BREW_PREFIX}/opt/libffi/lib/pkgconfig")

# Use LLD as the linker
# This is necessary as the default linker used by CMake on macOS is
# ld64, which currently has some incompatibilities with Homebrew and XCode15.
# See: https://github.com/orgs/Homebrew/discussions/4794#discussioncomment-7044468
# Adding this flag avoid the following errors:
# ld: warning: duplicate -rpath ... ignored
# ld: warning: ignoring duplicate libraries ...
add_link_options("-fuse-ld=lld")
if(DEFINED CMAKE_OSX_DEPLOYMENT_TARGET)
message(STATUS "Building for macOS deployment target ${CMAKE_OSX_DEPLOYMENT_TARGET}")
if(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_GREATER_EQUAL "15")
# Use LLD as the linker
# This is necessary as the default linker used by CMake on macOS is
# ld64, which currently has some incompatibilities with Homebrew and XCode15.
# See: https://github.com/orgs/Homebrew/discussions/4794#discussioncomment-7044468
# Adding this flag avoid the following errors:
# ld: warning: duplicate -rpath ... ignored
# ld: warning: ignoring duplicate libraries ...
add_link_options("-fuse-ld=lld")
endif()
endif()

endif() # USE_NIX
endif() # APPLE

0 comments on commit b4cbd35

Please sign in to comment.