Conversation
Add a helper downloading, building and installing a dependency into <build>/ext/dist at configure time, so that it can then be located with find_package() using the CMake configuration files exported by the dependency itself, instead of hand-written imported targets wrapping an ExternalProject. - Toolchain, compilers, Apple and Android settings, visibility and PIC are forwarded once through a generated initial cache file. - Downloads are verified against the archive hash, and retried to cope with transient network failures. - A stamp file records the build inputs, so that subsequent configure runs skip the build when nothing changed. - Multi-config generators build both Release and Debug side by side, and fail if both configurations install the same library file. - OCIO_<dep>_SOURCE_DIR builds from local sources for offline builds. - PROJECT_DIR allows an OCIO provided CMakeLists.txt for dependencies that don't provide a usable one. ocio_install_dependency uses a share/cmake/deps/<dep>.cmake recipe when one exists, and falls back to the legacy Install<dep>.cmake module. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Rémi Achard <remiachard@gmail.com>
On macOS, the expat and minizip-ng symbols were hidden by adding -L<dir> -hidden-l<name> linker flags, derived from the expat_LIBRARY and minizip-ng_LIBRARY variables set by the find and install modules. The linker could then resolve the name to another library in its search path, e.g. a Homebrew libminizip-ng.dylib, which libOpenColorIO would then depend on at runtime. Pass the exact static archive of the expat::expat and MINIZIP::minizip-ng targets to -load_hidden instead, which also works when the dependencies are located through their CMake configuration files and with multi-config generators. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Rémi Achard <remiachard@gmail.com>
Replace Installyaml-cpp.cmake with a recipe using the yaml-cpp CMake configuration files, which also provide YAML_CPP_STATIC_DEFINE. Remove the yaml-cpp alias from Findyaml-cpp.cmake, which was only needed because of the targets created by Installyaml-cpp.cmake. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Rémi Achard <remiachard@gmail.com>
Replace the corresponding Install modules with recipes using the CMake configuration files of each package. expat ignores CMAKE_DEBUG_POSTFIX and only uses a Debug postfix on Windows, so set it explicitly with multi-config generators to avoid the Debug library overwriting the Release one. pybind11 is header only, so it is installed without searching for Python. The pybind11 CMake configuration files only add /bigobj through pybind11_add_module(), which OCIO doesn't use, while Installpybind11 added it to the pybind11::module target. Add it to the PyOpenColorIO target directly on MSVC instead, whatever the origin of pybind11, and document why pybind11_add_module() is not used. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Rémi Achard <remiachard@gmail.com>
ZLIB 1.3.1 doesn't provide CMake configuration files and always installs both a shared and a static library. Remove the shared library from ext/dist, so that anything searching ZLIB there (minizip-ng, consumers of a static OCIO) uses the static library, and point CMake's FindZLIB module to it. The results of a previous search are discarded first, as a system ZLIB rejected for being too old (e.g. 1.2.7 on manylinux2014, 1.2.12 in the macOS SDK) would otherwise stay in the cache. minizip-ng records the ZLIB library path in its exported targets, so it is built against the per-configuration ZLIB libraries used by OCIO. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Rémi Achard <remiachard@gmail.com>
Replace the 9 hand-written OpenEXR imported targets with the OpenEXR CMake configuration files. OpenEXR is built against the Imath used by OCIO, whether it was found or built by OCIO. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Rémi Achard <remiachard@gmail.com>
These packages don't provide usable CMake builds for OCIO: pystring doesn't install its headers nor configuration files, lcms2 only has Autotools and Meson builds, and openfx requires Conan provided dependencies. Move the OCIO provided CMakeLists.txt files to share/cmake/projects/<dep>, taking the location of the sources in OCIO_DEP_SOURCE_DIR instead of being copied over the sources, and install CMake configuration files for them. Update the CI install scripts accordingly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Rémi Achard <remiachard@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Rémi Achard <remiachard@gmail.com>
With multi-config generators, only build the Release and Debug configurations of the dependencies listed in CMAKE_CONFIGURATION_TYPES. The Python wheels are built with the Visual Studio generator on Windows, only for the Release configuration, so set CMAKE_CONFIGURATION_TYPES accordingly in setup.py, instead of building the Debug dependencies too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Rémi Achard <remiachard@gmail.com>
setup.py ran a full CMake configuration only to read the version from the generated OpenColorABI.h header. With the dependencies now built at configure time, this built all the missing dependencies a first time before building the wheel. Read the version and release type from the top level CMakeLists.txt instead, the same way CMake builds OCIO_VERSION_FULL_STR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Rémi Achard <remiachard@gmail.com>
remia
force-pushed
the
cmake-deps-refactor
branch
from
September 24, 2026 20:01
e0c0e46 to
9c38926
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the
Install<pkg>.cmakemodules, which wrapped anExternalProjectbuild in hand-writtenIMPORTEDtargets, with dependencies built at configure time into<build>/ext/distand then found withfind_package()through their own exported CMake configuration files.With the old approach, every module had to guess library file names (debug postfixes, version suffixes, prefix changes), re-create the link graph between targets (9 targets for OpenEXR alone), and report
<pkg>_FOUNDand<pkg>_VERSIONbefore anything was built. The same toolchain forwarding block was also copied into every module.ocio_build_dependency()helper (share/cmake/macros/ocio_build_dependency.cmake):ext/dist, forwarding the toolchain, compilers, Apple/Android settings, visibility and PIC in one place.CMAKE_CONFIGURATION_TYPESside by side, and configure fails if two configurations would install the same library file.OCIO_<pkg>_SOURCE_DIRbuilds from local sources for offline builds.share/cmake/deps/: expat, yaml-cpp, pystring, Imath, ZLIB, minizip-ng, lcms2, openfx, pybind11, OpenEXR.share/cmake/projects/<pkg>/that install proper package configs. The CI install scripts use them too.-load_hidden <exact archive of the target>instead of-L<dir> -hidden-l<name>. The old flags could resolve to another library in the search path: on a Mac with Homebrew,libOpenColorIO.dylibfrommainends up depending on Homebrew'slibminizip-ng.1.dylib./bigobjis added on MSVC directly. The pybind11 configs only add it throughpybind11_add_module(), which is not a good fit for OCIO; the reasons are documented insrc/bindings/python/CMakeLists.txt.setup.py:CMakeLists.txt, instead of running a full CMake configure that would now build every dependency.OCIO_INSTALL_EXT_PACKAGESkeeps its NONE / MISSING / ALL behavior.Commits
Each commit leaves the build working and can be reviewed on its own:
ocio_build_dependency(plus a fallback to the legacyInstall<pkg>.cmakemodules during the migration)-load_hiddensetup.pyversion fromCMakeLists.txtBehavior changes
cmakeconfigure rather than during the build. The first configure with all dependencies takes about 80 s on a 16-core Mac; later configures skip the builds.ext/dist.-DCMAKE_PREFIX_PATH=<install>;<build>/ext/dist, without the per-package<pkg>_ROOT/<pkg>_STATIC_LIBRARYflags. The CI flags are left unchanged and still work.Testing
On this fork, on the same code as this branch (the runs also included two temporary workflow commits, dropped since):
Locally (macOS, Ninja and Xcode):
libOpenColorIOare identical tomain: no expat, minizip-ng or yaml-cpp symbols leak.CMAKE_PREFIX_PATH.Notes for review
Installyaml-cpp.cmake,InstallZLIB.cmakeandInstallminizip-ng.cmake, which this PR deletes. Whichever merges second needs to carry the version bumps into the recipes (with new archive hashes).mainbecause of numpy 2.5. Adsk Contrib - Support Yaml 0.9.0 and other build fixes AcademySoftwareFoundation/OpenColorIO#2350 fixes it./usr/local/include(Homebrew) can shadow the bundled dependency headers, because clang searches it before-isystemdirectories.ctest -jmakes thetest_cpu_*variants collide on shared temp file names.🤖 Generated with Claude Code