From: Vsevolod Stakhov Date: Tue, 30 Dec 2025 11:09:18 +0000 (+0000) Subject: [Fix] Add Homebrew LLVM libc++ library path on macOS X-Git-Tag: 3.14.3~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81a8363b314eb7653b8acf587cf96238acfad142;p=thirdparty%2Frspamd.git [Fix] Add Homebrew LLVM libc++ library path on macOS --- diff --git a/cmake/Toolset.cmake b/cmake/Toolset.cmake index 4e7017dfdc..c3cc2f5493 100644 --- a/cmake/Toolset.cmake +++ b/cmake/Toolset.cmake @@ -67,6 +67,18 @@ int main() { return 0; } set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") set(CLANG_DEFAULT_CXX_STDLIB "libc++") endif () + + # Homebrew LLVM on macOS needs its bundled libc++ (https://github.com/Homebrew/homebrew-core/issues/169820) + if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") + get_filename_component(COMPILER_DIR "${CMAKE_CXX_COMPILER}" DIRECTORY) + get_filename_component(COMPILER_PREFIX "${COMPILER_DIR}" DIRECTORY) + set(HOMEBREW_LIBCXX_PATH "${COMPILER_PREFIX}/lib/c++") + if (EXISTS "${HOMEBREW_LIBCXX_PATH}") + message(STATUS "Using Homebrew libc++: ${HOMEBREW_LIBCXX_PATH}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${HOMEBREW_LIBCXX_PATH}") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${HOMEBREW_LIBCXX_PATH}") + endif () + endif () else () message (WARNING "You are using an unsupported compiler ${CMAKE_C_COMPILER_ID}. Compilation has only been tested with Clang 4+ and GCC 4+.") endif ()