Skip to content

[libjpeg-turbo] Patch vcpkg dependencies for 3.2.0 - #52891

Merged
Victor Romero (vicroms) merged 53 commits into
microsoft:masterfrom
tartanpaint:libjpeg-turbo-3.2.0-dependencies-patch
Sep 18, 2026
Merged

Victor Romero (vicroms) merged 53 commits into
microsoft:masterfrom
tartanpaint:libjpeg-turbo-3.2.0-dependencies-patch

Conversation

@tartanpaint

@tartanpaint tartanpaint commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor
  • Changes comply with the maintainer guide.
  • SHA512s are updated for each updated download.
  • The "supports" clause reflects platforms that may be fixed by this new version, or no changes were necessary.
  • Any fixed CI baseline and CI feature baseline entries are removed from that file, or no entries needed to be changed.
  • All patch files in the port are applied and succeed.
  • The version database is fixed by rerunning ./vcpkg x-add-version --all and committing the result.
  • Exactly one version is added in each modified versions file.

The port file update will use the zlib and libspng dependencies introduced with libjpeg-turbo 3.2.0 from vcpkg rather than building additional copies of these from the libjpeg-turbo source tree.
The libjpeg-turbo patch files have been generated directly from commits in the upstream project repository and may be removed with a port update to a future version of libjpeg-turbo. Related libjpeg-turbo issue: libjpeg-turbo/libjpeg-turbo#901

@tartanpaint
tartanpaint marked this pull request as draft July 14, 2026 21:56
@BillyONeal

Copy link
Copy Markdown
Member

The static versions are all likely failing due to this problem GPT 5.6 Sol found:

The PR switches static turbojpeg to external libspng/zlib dependencies, but the installed libturbojpeg.pc still publishes only -lturbojpeg. Because upstream already provides pkg-config metadata, vcpkg review checks that integration when present (review guide). Static pkg-config consumers therefore miss the new dependencies introduced by the port changes (vcpkg.json, portfile.cmake); the upstream template has no Requires.private or Libs.private entry for those libraries (libturbojpeg.pc.in).

Fix: update the packaging/patch so pkg-config --static --libs libturbojpeg emits complete static link metadata for the vcpkg build. Since libspng does not currently provide a pkg-config file in vcpkg, Requires.private: spng alone is not enough unless that integration is added; otherwise use appropriate Libs.private entries for the vcpkg dependency chain and verify a static pkg-config consumer links.

You might also want to fix this other bit it found while you are here but that's not blocking:

The manifest still declares only BSD-3-Clause, while upstream documents IJG licensing for the libjpeg API and inherited code in addition to BSD-3-Clause for TurboJPEG (upstream license). vcpkg expects license metadata to match the installed package and upstream terms (manifest license docs. This mismatch predates the PR.

Comment thread ports/libfreenect2/CMake_4_and_OpenCL_headers.patch Outdated
Comment thread ports/libfreenect2/find_libjpegturbo.patch Outdated
Comment on lines +37 to +40
+ find_dependency(PkgConfig)
+ if(PkgConfig_FOUND)
+ pkg_check_modules(spng REQUIRED spng IMPORTED_TARGET)
+ endif()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using imported targets from pkgconfig is complicated for reverse dependencies with MSVC. In other ports we use the variables (and in particular <Prefix>_LINK_LIBRARIES) to get resolved libs instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These patches are generated from upstream libjpeg-turbo commits which will be included in the next libjpeg-turbo release. The patches may therefore be removed from the portfile when an update is available for the next version of libjpeg-turbo.
I've included comments in the portfile referencing the upstream commits used for the patch files.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not true in general. If we see something bogus we can fix bogus and submit the fix for bogus upstream. I agree with Kai Pastor (@dg0yt) and think this is incorrect. Zlib has conventions for how it is found in CMake, and libspng publishes CMake configs: https://github.com/randy408/libspng/blob/adc94393dbeddf9e027d1b2dfff7c1bab975224e/CMakeLists.txt#L65-L81

We should stay entirely in the CMake configs namespace if at all possible and it appears possible here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see, this is confusing because it's patches on patches. Kai Pastor (@dg0yt) I think your comment is resolved by 0002+0003 in this series.

Comment thread ports/libjpeg-turbo/0001-Build-Fix-CMake-pkg-config-file-if-WITH_SYSTEM_.patch Outdated
Comment on lines +19 to +21
+ include(FindPkgConfig)
+ pkg_check_modules(spng REQUIRED spng IMPORTED_TARGET)
+ set(SPNG_TARGET_DEFAULT PkgConfig::spng)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this still goes against my "do not use imported targets from pkg-config" advise.
Again, the problem is that it works poorly for top-level projects in Windows because typically there is no pkg-config in the PATH. (It is resolved when building vcpkg ports, but not for top-level projects.)

+ if(SPNG_LIBRARY MATCHES "PkgConfig::")
+ find_dependency(PkgConfig)
+ if(PkgConfig_FOUND)
+ pkg_check_modules(spng REQUIRED spng IMPORTED_TARGET)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REQUIRED here breaks optional find_package. This another quirk with pkg-config for transitive dependencies for imported targets.

Comment thread ports/libjpeg-turbo/usage Outdated
Comment on lines +1 to +9
libjpeg-turbo is compatible with built-in implementation-agnostic CMake targets:

find_package(JPEG REQUIRED)
target_link_libraries(main PRIVATE JPEG::JPEG)

libjpeg-turbo provides CMake targets for the TurboJPEG C API:

find_package(libjpeg-turbo CONFIG REQUIRED)
target_link_libraries(main PRIVATE $<IF:$<TARGET_EXISTS:libjpeg-turbo::turbojpeg>,libjpeg-turbo::turbojpeg,libjpeg-turbo::turbojpeg-static>)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this file is touched, it should re-formatted to align with heuristical output.

Suggested change
libjpeg-turbo is compatible with built-in implementation-agnostic CMake targets:
find_package(JPEG REQUIRED)
target_link_libraries(main PRIVATE JPEG::JPEG)
libjpeg-turbo provides CMake targets for the TurboJPEG C API:
find_package(libjpeg-turbo CONFIG REQUIRED)
target_link_libraries(main PRIVATE $<IF:$<TARGET_EXISTS:libjpeg-turbo::turbojpeg>,libjpeg-turbo::turbojpeg,libjpeg-turbo::turbojpeg-static>)
libjpeg-turbo is compatible with built-in implementation-agnostic CMake targets:
find_package(JPEG REQUIRED)
target_link_libraries(main PRIVATE JPEG::JPEG)
libjpeg-turbo provides CMake targets for the TurboJPEG C API:
find_package(libjpeg-turbo CONFIG REQUIRED)
target_link_libraries(main PRIVATE $<IF:$<TARGET_EXISTS:libjpeg-turbo::turbojpeg>,libjpeg-turbo::turbojpeg,libjpeg-turbo::turbojpeg-static>)

Comment on lines +7 to +9
if(CMAKE_VERSION VERSION_LESS 3.12 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
set(JPEG_LIBRARY "${JPEG_LIBRARY_DEBUG}" CACHE FILEPATH "")
endif()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the wrapper is touched: CMake 3.12 is no longer supported when using vcpkg. This (and its usage further down) is obsolete.

@BillyONeal Billy O'Neal (BillyONeal) removed the depends:different-pr This PR or Issue depends on a PR which has been filed label Aug 28, 2026
@BillyONeal

Copy link
Copy Markdown
Member

OK 53510 just landed so you should be able to make both CMake and pkgconfig paths work now

@BillyONeal
Billy O'Neal (BillyONeal) marked this pull request as draft August 28, 2026 18:09
@tartanpaint

Copy link
Copy Markdown
Contributor Author

Billy O'Neal (@BillyONeal) Kai Pastor (@dg0yt) I've attempted to address the review comments above. Please let me know if there is more work required to make this mergable.
Regarding the system-dependency-fixes-pr-901.patch, I have included additional changes in this to try to satisfy the review comments. If these are acceptable I can then generate an upstream PR with the extra changes. Thank you.

@tartanpaint
tartanpaint marked this pull request as ready for review September 10, 2026 15:18
Copilot AI added 2 commits September 10, 2026 17:43
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 75ecd986-b9c4-474e-91e9-36e614aa0c3c
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 75ecd986-b9c4-474e-91e9-36e614aa0c3c

@vicroms Victor Romero (vicroms) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please merge tartanpaint#4 to fix usage issues.

@vicroms
Victor Romero (vicroms) marked this pull request as draft September 11, 2026 00:48
Fix static pkg-config dependencies
@tartanpaint

Copy link
Copy Markdown
Contributor Author

Please merge tartanpaint#4 to fix usage issues.

Victor Romero (@vicroms) Thank you!

@vicroms
Victor Romero (vicroms) merged commit d53f25d into microsoft:master Sep 18, 2026
16 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.

5 participants