From fb2207d3281a1cbc1a54c909ccd95c5455bbf507 Mon Sep 17 00:00:00 2001 From: Zach Lewis Date: Mon, 3 Aug 2026 17:09:41 -0400 Subject: [PATCH] build(deps): keep Homebrew out of local dependency child builds IGNORE_HOMEBREWED_DEPS pruned prefix paths and set CMAKE_IGNORE_PATH, but CMAKE_IGNORE_PATH does not stop config-package searches, and local dependency child builds could still quietly resolve Homebrew packages we are ignoring. Concretely: with a Homebrew Imath 3.2 installed, the local OpenEXR build resolved Imath_DIR=/opt/homebrew/lib/cmake/Imath while OpenImageIO itself used the locally built Imath 3.1.10, and libOpenImageIO then failed to link with Imath_3_2 vs Imath_3_1 namespace-mangled symbol mismatches. Set CMAKE_IGNORE_PREFIX_PATH for the Homebrew prefixes (honored by config searches) and forward it to dependency child builds alongside CMAKE_IGNORE_PATH. Verified: the OpenEXR child build resolves the local deps Imath and libOpenImageIO links clean. Assisted-by: Claude Code (Fable 5) Signed-off-by: Zach Lewis --- CMakeLists.txt | 6 ++++++ src/cmake/dependency_utils.cmake | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ed1589cfc..79f3612b8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,6 +216,12 @@ if (IGNORE_HOMEBREWED_DEPS) ) endforeach () + # Also ignore the whole prefixes, which (unlike CMAKE_IGNORE_PATH) is + # honored by config-package searches, and is forwarded to local + # dependency child builds so they can't quietly resolve a Homebrew + # package (e.g. a mismatched Imath) that we ourselves are ignoring. + list (APPEND CMAKE_IGNORE_PREFIX_PATH ${HOMEBREW_PREFIXES}) + message (STATUS "CMAKE_IGNORE_PATH: ${CMAKE_IGNORE_PATH}") endif () diff --git a/src/cmake/dependency_utils.cmake b/src/cmake/dependency_utils.cmake index 25a1172555..79decedde6 100644 --- a/src/cmake/dependency_utils.cmake +++ b/src/cmake/dependency_utils.cmake @@ -694,6 +694,10 @@ macro (build_dependency_with_cmake pkgname) string(REPLACE ";" "\\;" CMAKE_IGNORE_PATH_ESCAPED "${CMAKE_IGNORE_PATH}") list(APPEND _pkg_CMAKE_ARGS "-DCMAKE_IGNORE_PATH=${CMAKE_IGNORE_PATH_ESCAPED}") endif() + if (CMAKE_IGNORE_PREFIX_PATH) + string(REPLACE ";" "\\;" CMAKE_IGNORE_PREFIX_PATH_ESCAPED "${CMAKE_IGNORE_PREFIX_PATH}") + list(APPEND _pkg_CMAKE_ARGS "-DCMAKE_IGNORE_PREFIX_PATH=${CMAKE_IGNORE_PREFIX_PATH_ESCAPED}") + endif() # Pass along any CMAKE_MSVC_RUNTIME_LIBRARY if (WIN32 AND CMAKE_MSVC_RUNTIME_LIBRARY)