cmake: Explicitly specify Boost_ROOT for Homebrew's package

On macOS, this change ensures that the Boost package is located at its
real path rather than via the symlink in the default prefix.

Github-Pull: #32814
Rebased-From: 8800b5acc1ef7abe6c5260ae0be5386b1d593a19
This commit is contained in:
Hennadii Stepanov 2025-06-25 18:45:43 +01:00 committed by fanquake
parent a990c1002b
commit a3c1939d6e
No known key found for this signature in database
GPG Key ID: 2EEB9F5CC09526C1

View File

@ -17,6 +17,18 @@ function(add_boost_if_needed)
directory and other added INTERFACE properties.
]=]
if(CMAKE_HOST_APPLE)
find_program(HOMEBREW_EXECUTABLE brew)
if(HOMEBREW_EXECUTABLE)
execute_process(
COMMAND ${HOMEBREW_EXECUTABLE} --prefix boost
OUTPUT_VARIABLE Boost_ROOT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
endif()
# We cannot rely on find_package(Boost ...) to work properly without
# Boost_NO_BOOST_CMAKE set until we require a more recent Boost because
# upstream did not ship proper CMake files until 1.82.0.