diff --git a/CMakeLists.txt b/CMakeLists.txt index 75375d0b0..7027b218f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,7 +81,17 @@ if(APPLE) execute_process(COMMAND brew --prefix OUTPUT_VARIABLE HOMEBREW_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) if(HOMEBREW_PREFIX) link_directories("${HOMEBREW_PREFIX}/lib") - include_directories("${HOMEBREW_PREFIX}/include") + # SYSTEM is load-bearing, not cosmetic. A plain include_directories() + # here is directory-scoped at the TOP level, so it is inherited by every + # add_subdirectory() and initialises every target's INCLUDE_DIRECTORIES + # ahead of whatever that target adds for itself -- which means + # /opt/homebrew/include outranks every vendored include dir in the tree. + # Any Homebrew formula whose headers share a basename with a vendored one + # then silently wins, reversing the choice USE_SYSTEM_* made in CMake: + # ggml.h and whisper.h are both shadowed on the affected setup. + # SYSTEM emits -isystem, which the compiler searches AFTER all -I paths, + # so Homebrew stays findable and stops taking precedence. + include_directories(SYSTEM "${HOMEBREW_PREFIX}/include") endif() endif()