build(cmake): guard libtiff's missing Deflate target#5313
Open
zachlewis wants to merge 3 commits into
Open
Conversation
Static libtiff package exports can reference Deflate::Deflate without importing the target. Quietly load libdeflate's config and supply the alias before TIFF discovery when needed. Fixes AcademySoftwareFoundation#4439 Assisted-by: Codex / GPT-5 Signed-off-by: Zach Lewis <zachcanbereached@gmail.com>
Reference the upstream libtiff report from the defensive target guard. Assisted-by: Codex / GPT-5 Signed-off-by: Zach Lewis <zachcanbereached@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a CMake-side compatibility guard in OIIO’s dependency discovery to prevent configuration failures when a previously installed/static libtiff config exports TIFF::tiff with an unresolved link interface dependency on Deflate::Deflate (libtiff config-mode defect).
Changes:
- Before
checked_find_package(TIFF), conditionallyfind_package(libdeflate CONFIG QUIET)ifDeflate::Deflatedoes not already exist. - Alias
Deflate::Deflatetolibdeflate::libdeflate_staticorlibdeflate::libdeflate_sharedwhen available.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Define libtiff's missing Deflate target before the installed static OpenImageIO package resolves its TIFF dependency. Assisted-by: Codex / GPT-5 Signed-off-by: Zach Lewis <zachcanbereached@gmail.com>
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.
Description
Fixes configuration failures when OIIO finds a previously autobuilt static libtiff package whose exported
TIFF::tifftarget referencesDeflate::Deflatewithout importing or defining that target.Before TIFF discovery, this adds a narrow compatibility guard that quietly loads libdeflate's config package and aliases its static or shared target as
Deflate::Deflatewhen necessary.Fixes #4439.
Root cause
libtiff links static TIFF builds against
Deflate::Deflate, causing the installedTIFF::tifftarget to export$<LINK_ONLY:Deflate::Deflate>.However, libtiff's installed
tiff-config.cmakeloads that exported target without importing its dependencies. The corresponding upstream template still contains# TODO: import dependencies.Upstream report: https://gitlab.com/libtiff/libtiff/-/work_items/871
OIIO encounters this during
checked_find_package(TIFF). CMake'sFindTIFFmodule first attempts libtiff's config package, which exposes the malformed export. This is not specific to CMake 4.3: I reproduced it with CMake 3.29.6 and 4.3.1. Issue #4439 likewise originally reported CMake 3.29+ on Linux and macOS rather than a Homebrew-specific failure.Why fix this in OIIO?
The underlying package-export defect belongs in libtiff, but an upstream fix will not repair already-installed libtiff releases or OIIO dependency caches. OIIO also builds the affected static libtiff configuration itself.
This also breaks OIIO's ability to self-build (some) dependencies that [in]directly depend on libtiff or deflate. (Not for any dependencies for which we currently have self-building recipes so far; but this has blocked me in the past from submitting PRs for some of the more complex (sub)dependencies (libheif comes to mind; maybe jxl...? can't remember, it was more than a year ago when I last looked into this)
The guard is intentionally defensive:
Deflate::Deflatedoes not already exist;Testing
Tested on:
Verification performed:
Steps taken to verify:
SKBUILD_BUILD_DIR,IGNORE_HOMEBREWED_DEPS=1, and without forcing a local TIFF rebuild. The first build autobuilt static TIFF 4.7.1 and libdeflate 1.23; the second found the cached TIFF package and completed without the previousDeflate::Deflateerror.No robots worth speaking of were harmed in the making of this PR
Assisted-by: Codex / GPT-5
Codex was used to trace the CMake package-discovery chain, inspect the libtiff exports, reproduce the failure, prepare the compatibility guard, and run the verification described above.