Skip to content

Commit

Permalink
build: Add IGNORE_HOMEBREWED_DEPS CMake option
Browse files Browse the repository at this point in the history
When `-DIGNORE_HOMEBREWED_DEPS=ON` is provided, ignore libraries that live under the following paths:
 - /opt/homebrew
 - /usr/local
 - /usr/X11
 - /usr/X11R6

Also, builds invoked with `build_dependency_with_cmake` will now inherit CMAKE_IGNORE_PATH and CMAKE_IGNORE_PREFIX_PATH values set in a higher-level scope. This prevents dependencies from finding sub-dependencies where it shouldn't. For example, if we're ignoring homebrewed dependencies, even though brew-installed PNG and brew-installed freetype may be ignored when first trying to find the dependencies, we need to make sure that when we build freetype locally, we take care _not_ to link brew-installed PNG.

Signed-off-by: Zach Lewis <[email protected]>
  • Loading branch information
zachlewis committed Oct 15, 2024
1 parent d45e634 commit 4929455
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 18 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ jobs:
SKBUILD_CMAKE_ARGS: |
-DOpenImageIO_BUILD_LOCAL_DEPS=TIFF;
-DOpenImageIO_BUILD_MISSING_DEPS=all;
-DCMAKE_IGNORE_PREFIX_PATH=/opt/homebrew
-DIGNORE_HOMEBREWED_DEPS=ON;
-DLINKSTATIC=ON
- uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
Expand Down Expand Up @@ -341,10 +342,11 @@ jobs:
CIBW_BUILD: ${{ matrix.python }}
CIBW_ARCHS: ${{ matrix.arch }}
# Ignore dependencies installed by homebrew (e.g. freetype)
SKBUILD_CMAKE_ARGS: |
-DOpenImageIO_BUILD_LOCAL_DEPS=TIFF;
-DOpenImageIO_BUILD_MISSING_DEPS=all;
-DCMAKE_IGNORE_PREFIX_PATH=/opt/homebrew
CMAKE_ARGS: |
-DOpenImageIO_BUILD_LOCAL_DEPS=TIFF
-DOpenImageIO_BUILD_MISSING_DEPS=all
-DIGNORE_HOMEBREWED_DEPS=ON
-DLINKSTATIC=ON
#TODO: Re-enable the PNG plugin until we can figure out why the system PNG is causing problems
ENABLE_PNG: 'OFF'

Expand Down
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ option (EMBEDPLUGINS "Embed format plugins in libOpenImageIO" ON)
set (PLUGIN_SEARCH_PATH "" CACHE STRING "Default plugin search path")
file (TO_NATIVE_PATH "${PLUGIN_SEARCH_PATH}" PLUGIN_SEARCH_PATH_NATIVE)
set (CMAKE_DEBUG_POSTFIX "_d" CACHE STRING "Library naming postfix for Debug builds")
option (IGNORE_HOMEBREWED_DEPS "If ON, will ignore homebrew-installed dependencies" OFF)

# Ignore prefixes for dependencies managed by homebrew on macOS
# https://gitlab.kitware.com/cmake/cmake/-/issues/21918#note_920016
if (IGNORE_HOMEBREWED_DEPS)
set (CMAKE_IGNORE_PATH)
foreach (_prefix /opt/homebrew /usr/local /usr/X11 /usr/X11R6)
list (APPEND CMAKE_IGNORE_PATH ${_prefix}/lib ${_prefix}/bin ${_prefix}/include)
endforeach ()
message (STATUS "Ignoring homebrewed dependencies.")
endif ()


if (CMAKE_UNITY_BUILD_BATCH_SIZE)
set (UNITY_SMALL_BATCH_SIZE "${CMAKE_UNITY_BUILD_BATCH_SIZE}" CACHE STRING "Unity batch mode size for expensive files")
Expand Down
27 changes: 14 additions & 13 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,19 +230,20 @@ Make targets you should know about:

Additionally, a few helpful modifiers alter some build-time options:

| Target | Command |
| ------------------------- | ---------------------------------------------- |
| make VERBOSE=1 ... | Show all compilation commands |
| make STOP_ON_WARNING=0 | Do not stop building if compiler warns |
| make EMBEDPLUGINS=0 ... | Don't compile the plugins into libOpenImageIO |
| make USE_OPENGL=0 ... | Skip anything that needs OpenGL |
| make USE_QT=0 ... | Skip anything that needs Qt |
| make MYCC=xx MYCXX=yy ... | Use custom compilers |
| make USE_PYTHON=0 ... | Don't build the Python binding |
| make BUILD_SHARED_LIBS=0 | Build static library instead of shared |
| make LINKSTATIC=1 ... | Link with static external libraries when possible |
| make SOVERSION=nn ... | Include the specified major version number in the shared object metadata |
| make NAMESPACE=name | Wrap everything in another namespace |
| Target | Command |
| ----------------------------- | ------------------------------------------------------------------------- |
| make VERBOSE=1 ... | Show all compilation commands |
| make STOP_ON_WARNING=0 | Do not stop building if compiler warns |
| make EMBEDPLUGINS=0 ... | Don't compile the plugins into libOpenImageIO |
| make USE_OPENGL=0 ... | Skip anything that needs OpenGL |
| make USE_QT=0 ... | Skip anything that needs Qt |
| make MYCC=xx MYCXX=yy ... | Use custom compilers |
| make USE_PYTHON=0 ... | Don't build the Python binding |
| make BUILD_SHARED_LIBS=0 | Build static library instead of shared |
| make IGNORE_HOMEBREWED_DEPS=1 | Ignore homebrew-managed dependencies |
| make LINKSTATIC=1 ... | Link with static external libraries when possible |
| make SOVERSION=nn ... | Include the specified major version number in the shared object metadata |
| make NAMESPACE=name | Wrap everything in another namespace |

The command 'make help' will list all possible options.

Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ ifneq (${BUILD_MISSING_DEPS},)
MY_CMAKE_FLAGS += -DBUILD_MISSING_DEPS:BOOL=${BUILD_MISSING_DEPS}
endif

ifneq ($(IGNORE_HOMEBREWED_DEPS),)
MY_CMAKE_FLAGS += -DIGNORE_HOMEBREWED_DEPS:BOOL=${IGNORE_HOMEBREWED_DEPS}
endif

#$(info MY_CMAKE_FLAGS = ${MY_CMAKE_FLAGS})
#$(info MY_MAKE_FLAGS = ${MY_MAKE_FLAGS})
Expand Down Expand Up @@ -383,6 +386,7 @@ help:
@echo " USE_NUKE=0 Don't build Nuke plugins"
@echo " Nuke_ROOT=path Custom Nuke installation"
@echo " NUKE_VERSION=ver Custom Nuke version"
@echo " IGNORE_HOMEBREWED_DEPS=1 Don't use dependencies installed by Homebrew"
@echo " OIIO build-time options:"
@echo " INSTALL_PREFIX=path Set installation prefix (default: ./${INSTALL_PREFIX})"
@echo " NAMESPACE=name Override namespace base name (default: OpenImageIO)"
Expand Down
8 changes: 8 additions & 0 deletions src/cmake/dependency_utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,14 @@ macro (build_dependency_with_cmake pkgname)
)
endif ()

# Make sure to inherit the CMAKE_IGNORE_PATH and CMAKE_IGNORE_PREFIX_PATHs
if (CMAKE_IGNORE_PATH)
list (APPEND _pkg_CMAKE_ARGS -DCMAKE_IGNORE_PATH=${CMAKE_IGNORE_PATH})
endif ()
if (CMAKE_IGNORE_PREFIX_PATH)
list (APPEND _pkg_CMAKE_ARGS -DCMAKE_IGNORE_PREFIX_PATH=${CMAKE_IGNORE_PREFIX_PATH})
endif ()

execute_process (COMMAND
${CMAKE_COMMAND}
# Put things in our special local build areas
Expand Down

0 comments on commit 4929455

Please sign in to comment.