Allow disabling the Homebrew dependency search path
Summary
Meta/CMake/compile_options.cmake unconditionally adds /opt/homebrew to CMAKE_PREFIX_PATH on Apple platforms.
When building through Nix on a machine with Homebrew installed, CMake selected JPEG, PNG, and OpenSSL from /opt/homebrew instead of the dependencies supplied by Nix. This makes dependency selection depend on the host machine.
Would you consider a CMake option to disable this behavior? For example:
option(ENABLE_HOMEBREW_SEARCH "Search for dependencies in Homebrew" ON)
if (APPLE)
if (ENABLE_HOMEBREW_SEARCH)
list(APPEND CMAKE_PREFIX_PATH /opt/homebrew)
endif()
add_cxx_link_options(LINKER:-dead_strip)
endif()
This would preserve the existing default while letting package managers pass -DENABLE_HOMEBREW_SEARCH=OFF.
Is there an existing preferred way to opt out? Any other ideas that would help this "issue" would be greatly appreciated instead of having to create .patch files :)
Operating system
macOS
Steps to reproduce
- Have a Mac with nix package manager
- Try building this PR
Expected behavior
Preferably no forced requirement for homebrew
Actual behavior
Homebrew requirement resulting in warnings like these:
ld: warning: dylib (/opt/homebrew/lib/libcrypto.dylib) was built for newer macOS version (26.0) than being linked (15.4)
ld: warning: dylib (/opt/homebrew/lib/libjpeg.dylib) was built for newer macOS version (26.0) than being linked (15.4)
ld: warning: dylib (/opt/homebrew/lib/libpng.dylib) was built for newer macOS version (26.0) than being linked (15.4)
URL for a reduced test case
N/A
HTML/SVG/etc. source for a reduced test case
N/A
Log output and (if possible) backtrace
ld: warning: dylib (/opt/homebrew/lib/libcrypto.dylib) was built for newer macOS version (26.0) than being linked (15.4)
ld: warning: dylib (/opt/homebrew/lib/libjpeg.dylib) was built for newer macOS version (26.0) than being linked (15.4)
ld: warning: dylib (/opt/homebrew/lib/libpng.dylib) was built for newer macOS version (26.0) than being linked (15.4)
Screenshots or screen recordings
No response
Build flags or config settings
No response
Source: LadybirdBrowser/ladybird