From 918db88a34e686be149d0ebcdc4c7b9a49af96e6 Mon Sep 17 00:00:00 2001 From: Jonas Holzman Date: Mon, 16 Jun 2025 08:44:43 +0200 Subject: [PATCH] Deps: macOS: Prevent accidental linking to system-wide libraries for certain deps On the macOS deps builder, if certain libraries were installed system-wide using Homebrew, they could be prioritized during the linking of dependencies over our own versions, causing breakages when running the built libraries on other systems. For OpenColorIO, homebrew Imath could be linked if installed. For TIFF (& libjpeg as a transitive dep), homebrew libdeflate could be linked if installed. This commit fixes both of these issues by directly specifying the library path to prevent the linker from wrongly inferring it to a system-wide path. --- build_files/build_environment/cmake/opencolorio.cmake | 4 +++- build_files/build_environment/cmake/tiff.cmake | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/build_files/build_environment/cmake/opencolorio.cmake b/build_files/build_environment/cmake/opencolorio.cmake index 85d6ce2483d..06314bce301 100644 --- a/build_files/build_environment/cmake/opencolorio.cmake +++ b/build_files/build_environment/cmake/opencolorio.cmake @@ -32,10 +32,12 @@ set(OPENCOLORIO_EXTRA_ARGS ) if(APPLE) - # Work around issue where minizip-ng_LIBRARY assumes -ng in file name. set(OPENCOLORIO_EXTRA_ARGS ${OPENCOLORIO_EXTRA_ARGS} + # Work around issue where minizip-ng_LIBRARY assumes -ng in file name. -Dminizip_LIBRARY=${LIBDIR}/minizipng/lib/libminizip${LIBEXT} + # Work around issue where homebrew Imath's can be prioritized over our own dependency during linking if installed. + -DImath_LIBRARY=${LIBDIR}/imath/lib/libImath${SHAREDLIBEXT} ) endif() diff --git a/build_files/build_environment/cmake/tiff.cmake b/build_files/build_environment/cmake/tiff.cmake index d5593e4dce5..624182b0dbc 100644 --- a/build_files/build_environment/cmake/tiff.cmake +++ b/build_files/build_environment/cmake/tiff.cmake @@ -18,6 +18,14 @@ set(TIFF_EXTRA_ARGS -Dsphinx=OFF ) +if(APPLE) + set(TIFF_EXTRA_ARGS + ${TIFF_EXTRA_ARGS} + # Work around issue where homebrew's libdeflate can be prioritized over our own dependency during linking if installed. + -DDeflate_LIBRARY=${LIBDIR}/deflate/lib/libdeflate${LIBEXT} + ) +endif() + ExternalProject_Add(external_tiff URL file://${PACKAGE_DIR}/${TIFF_FILE} DOWNLOAD_DIR ${DOWNLOAD_DIR}