Skip to content

fix(pj_media): pull libjpeg-turbo through Conan instead of pkg-config#66

Merged
facontidavide merged 3 commits into
developmentfrom
fix/pj-media-find-libjpeg-turbo
Apr 23, 2026
Merged

fix(pj_media): pull libjpeg-turbo through Conan instead of pkg-config#66
facontidavide merged 3 commits into
developmentfrom
fix/pj-media-find-libjpeg-turbo

Conversation

@pabloinigoblasco
Copy link
Copy Markdown
Collaborator

@pabloinigoblasco pabloinigoblasco commented Apr 23, 2026

Summary

pj_media_core and pj_media/demos were resolving turbojpeg via pkg_check_modules(TURBOJPEG libturbojpeg), which relied on the system package libturbojpeg0-dev being installed on the build machine. As a result every CI runner (Linux, macOS, Windows) currently fails configure with:

CMake Error at pj_media/pj_media_core/CMakeLists.txt:40 (target_link_libraries):
  Target "pj_media_core" links to:
    PkgConfig::TURBOJPEG
  but the target was not found.

This PR switches the dependency to the Conan-provided libjpeg-turbo package, so the library is fetched and exposed consistently across every platform without any per-runner system-package setup.

Changes

  • conanfile.txt — add libjpeg-turbo/3.1.0.
  • pj_media/pj_media_core/CMakeLists.txt — drop pkg_check_modules for turbojpeg, add find_package(libjpeg-turbo REQUIRED), replace PkgConfig::TURBOJPEG with libjpeg-turbo::libjpeg-turbo on every target_link_libraries.
  • pj_media/demos/CMakeLists.txt — same.

The umbrella target libjpeg-turbo::libjpeg-turbo is used intentionally — it's the one Conan suggests and abstracts over the shared=True/False option (which otherwise changes the component target names to turbojpeg-static / turbojpeg).

Verification

Validated locally that Conan's libjpeg-turbo/3.1.0 exposes the libjpeg-turbo::libjpeg-turbo target after conan install . -g CMakeDeps (default shared=False option set).

The existing pkg_check_modules for libpng, libavcodec, libavformat, libavutil, libswscale are left untouched — moving those to Conan is a separate scope.

Test plan

  • Linux CI configures and builds cleanly without libturbojpeg0-dev on the runner
  • Windows CI configures cleanly
  • macOS CI configures cleanly
  • pj_media_core unit tests still link and run

pj_media_core and pj_media/demos were resolving turbojpeg via
pkg_check_modules(TURBOJPEG libturbojpeg), which relied on the
system package libturbojpeg0-dev being installed on the build
machine. That made every CI runner fail configure with:

    Target "pj_media_core" links to: PkgConfig::TURBOJPEG
    but the target was not found.

Switch to the Conan-provided libjpeg-turbo package so the
dependency is fetched and exposed consistently on Linux, macOS
and Windows — no more system-package gymnastics per runner.

Changes:
- conanfile.txt: add libjpeg-turbo/3.1.0
- pj_media/pj_media_core/CMakeLists.txt: drop pkg_check_modules
  for turbojpeg, add find_package(libjpeg-turbo REQUIRED), replace
  PkgConfig::TURBOJPEG with libjpeg-turbo::libjpeg-turbo on every
  target_link_libraries
- pj_media/demos/CMakeLists.txt: same
Same rationale as the previous commit for libjpeg-turbo: pj_media_core
resolved libpng via pkg_check_modules, which relied on pkg-config being
installed on the runner. Linux has it, Windows does not, so configure
fell through to:

    Target "pj_media_core" links to: PkgConfig::LIBPNG
    but the target was not found.

Switch libpng to the Conan package (exposed as the standard PNG::PNG
CMake target) so all three platforms resolve it the same way.

Changes:
- conanfile.txt: add libpng/1.6.47
- pj_media/pj_media_core/CMakeLists.txt: drop pkg_check_modules for
  libpng, add find_package(PNG REQUIRED), replace every
  PkgConfig::LIBPNG with PNG::PNG
libpng's error handling is setjmp-based, which MSVC flags with C4611
(interaction between _setjmp and C++ object destruction is
non-portable). Because pj_media_core builds with warnings-as-errors,
Windows compile now fails on image_decoder.cpp and codecs.cpp.

Suppress C4611 for the pj_media_core target on MSVC only. The
decoders follow the standard libpng error-handling pattern, which is
used by every C++ project consuming libpng (Chromium, Qt, OpenCV…).

Note: there are std::vector / std::shared_ptr locals between setjmp
and the png_read_* calls that could technically leak on a longjmp,
but that is an existing design issue to be addressed separately —
this commit only unblocks the Windows build.
@facontidavide facontidavide merged commit e3d84cc into development Apr 23, 2026
2 checks passed
@facontidavide facontidavide deleted the fix/pj-media-find-libjpeg-turbo branch May 4, 2026 12:13
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.

2 participants