Repository navigation
Find Threads in the installed CMake package config - #420
Conversation
|
Better question is: why is it linked as public and exported at all? @aous72 I.e. I don't see |
A threads-off OpenEXR built against a system OpenJPH 0.33.0 produced an
installed OpenEXRConfig.cmake that broke downstream find_package(OpenEXR):
CMake Error at .../openjph/openjph-targets.cmake (set_target_properties):
The link interface of target "openjph" contains:
Threads::Threads
but the target was not found.
OpenJPH 0.33.0's exported target links Threads::Threads, but its package
config does not find_dependency(Threads). OpenEXRConfig.cmake only looked
for Threads when OpenEXR itself was built with threading enabled, while
find_dependency(openjph) runs whenever OpenJPH is external. So a consuming
project that has not already found Threads -- a threads-off OpenEXR, or any
downstream build that does not use threads itself -- failed when
find_dependency(openjph) pulled in the openjph target.
This mirrors the build-time workaround already present in OpenEXRSetup.cmake:
define Threads::Threads before finding openjph when OpenJPH is external.
Remove once OpenEXR's minimum OpenJPH includes aous72/OpenJPH#420; it must
stay as long as 3.5 is supported, since 3.5 cannot raise the minimum.
Assisted-by: Copilot / Claude Opus 4.8
Signed-off-by: Cary Phillips <seabeepea@gmail.com>
A threads-off OpenEXR built against a system OpenJPH 0.33.0 produced an
installed OpenEXRConfig.cmake that broke downstream find_package(OpenEXR):
CMake Error at .../openjph/openjph-targets.cmake (set_target_properties):
The link interface of target "openjph" contains:
Threads::Threads
but the target was not found.
OpenJPH 0.33.0's exported target links Threads::Threads, but its package
config does not find_dependency(Threads). OpenEXRConfig.cmake only looked
for Threads when OpenEXR itself was built with threading enabled, while
find_dependency(openjph) runs whenever OpenJPH is external. So a consuming
project that has not already found Threads -- a threads-off OpenEXR, or any
downstream build that does not use threads itself -- failed when
find_dependency(openjph) pulled in the openjph target.
This mirrors the build-time workaround already present in OpenEXRSetup.cmake:
define Threads::Threads before finding openjph when OpenJPH is external.
Remove once OpenEXR's minimum OpenJPH includes aous72/OpenJPH#420; it must
stay as long as 3.5 is supported, since 3.5 cannot raise the minimum.
Assisted-by: Copilot / Claude Opus 4.8
Signed-off-by: Cary Phillips <seabeepea@gmail.com>
A threads-off OpenEXR built against a system OpenJPH 0.33.0 produced an
installed OpenEXRConfig.cmake that broke downstream find_package(OpenEXR):
CMake Error at .../openjph/openjph-targets.cmake (set_target_properties):
The link interface of target "openjph" contains:
Threads::Threads
but the target was not found.
OpenJPH 0.33.0's exported target links Threads::Threads, but its package
config does not find_dependency(Threads). OpenEXRConfig.cmake only looked
for Threads when OpenEXR itself was built with threading enabled, while
find_dependency(openjph) runs whenever OpenJPH is external. So a consuming
project that has not already found Threads -- a threads-off OpenEXR, or any
downstream build that does not use threads itself -- failed when
find_dependency(openjph) pulled in the openjph target.
This mirrors the build-time workaround already present in OpenEXRSetup.cmake:
define Threads::Threads before finding openjph when OpenJPH is external.
Remove once OpenEXR's minimum OpenJPH includes aous72/OpenJPH#420; it must
stay as long as 3.5 is supported, since 3.5 cannot raise the minimum.
Assisted-by: Copilot / Claude Opus 4.8
Signed-off-by: Cary Phillips <seabeepea@gmail.com>
|
Confirming the downstream breakage this fixes. In the FreeBSD ports tree, graphics/openjph was updated to 0.33.0 on 2026-11-12 (ports commit 7e24910294). Since then graphics/libheif 1.23.6 fails at configure time in poudriere on FreeBSD 15.1-RELEASE amd64: Packages that depend on libheif (e.g. ImageMagick7) are skipped as a result. With exactly this change applied as a port patch to 0.33.0, libheif and ImageMagick7 build again. On the question of whether Threads needs to be PUBLIC at all: dropping it from the public link interface would also work and is arguably cleaner, as long as |
|
Yeap, I have thought there was a reason to use public but if not, then this is feel more appropriate solution. |
|
@aous72 TBH, the transitive dependency might still need to be exported, but for static builds only. This, however, requires a larger CMake rework and some effort to get it right (separate static and shared targets and exported configurations, see e.g. SDL3 or libavif for ideas, but beware they might not yet have it 100% right either...). |
Since e997575,
openjphlinksThreads::Threadspublicly, so the exportedopenjph-targets.cmakereferences it, butopenjph-config.cmakenever finds Threads. Consumers that callfind_package(openjph)before finding Threads themselves (e.g. libheif) fail withThe link interface of target "openjph" contains: Threads::Threads but the target was not found.This addsfind_dependency(Threads)to the config template.🤖 Generated with Claude Code