Skip to content

Find Threads in the installed CMake package config - #420

Merged
aous72 merged 2 commits into
aous72:masterfrom
daeho-ro:cmake-config-find-threads
Nov 14, 2026
Merged

aous72 merged 2 commits into
aous72:masterfrom
daeho-ro:cmake-config-find-threads

Conversation

@daeho-ro

@daeho-ro daeho-ro commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Since e997575, openjph links Threads::Threads publicly, so the exported openjph-targets.cmake references it, but openjph-config.cmake never finds Threads. Consumers that call find_package(openjph) before finding Threads themselves (e.g. libheif) fail with The link interface of target "openjph" contains: Threads::Threads but the target was not found. This adds find_dependency(Threads) to the config template.

🤖 Generated with Claude Code

@kmilos

kmilos commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Better question is: why is it linked as public and exported at all? @aous72

I.e. I don't see std::call_once used in the public API (nor <thread>, nor <mutex>, let alone pthread.h), and at least in my build of libopenjph pthread_once is only an imported symbol, not an exported (public) one...

cary-ilm added a commit to cary-ilm/openexr that referenced this pull request Nov 8, 2026
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>
cary-ilm added a commit to AcademySoftwareFoundation/openexr that referenced this pull request Nov 8, 2026
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>
cary-ilm added a commit to AcademySoftwareFoundation/openexr that referenced this pull request Nov 9, 2026
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>
@spagu

spagu commented Nov 14, 2026

Copy link
Copy Markdown

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:

CMake Error at /usr/local/lib/cmake/openjph/openjph-targets.cmake:61 (set_target_properties):
  The link interface of target "openjph" contains:

    Threads::Threads

  but the target was not found.

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 find_package(Threads) in src/apps/ojph_stream_expand keeps working. Either way, a release containing one of the two fixes would unblock downstream packagers.

@aous72

aous72 commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Thanks for everyone for raising this issue/PR.
Thank you @kmilos, I think your suggestion is the best option -- I could not have done it without you.
Let's see if @kmilos proposed solution works, because it is the least intrusive.

Kind regards,
Aous.

@aous72

aous72 commented Nov 14, 2026

Copy link
Copy Markdown
Owner

@daeho-ro @cary-ilm @spagu
Please see if this solves your problem.

@daeho-ro

Copy link
Copy Markdown
Contributor Author

Yeap, I have thought there was a reason to use public but if not, then this is feel more appropriate solution.

@aous72
aous72 merged commit d617e85 into aous72:master Nov 14, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants