Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libjpeg-turbo] Update wrapper to correctly find debug/release variant #19319

Merged
merged 10 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions ports/azure-kinect-sensor-sdk/add-MATROSKA_VERSION-define.patch

This file was deleted.

106 changes: 59 additions & 47 deletions ports/azure-kinect-sensor-sdk/fix-builds.patch

Large diffs are not rendered by default.

36 changes: 0 additions & 36 deletions ports/azure-kinect-sensor-sdk/fix-uvc.patch

This file was deleted.

2 changes: 0 additions & 2 deletions ports/azure-kinect-sensor-sdk/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ vcpkg_from_github(
PATCHES
fix-builds.patch
fix-dependency-imgui.patch
add-MATROSKA_VERSION-define.patch
fix-linux.patch
fix-uvc.patch
fix-calibration-c.patch
)

Expand Down
2 changes: 1 addition & 1 deletion ports/azure-kinect-sensor-sdk/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "azure-kinect-sensor-sdk",
"version": "1.4.1",
"port-version": 1,
"port-version": 2,
"description": "Azure Kinect SDK is a cross platform (Linux and Windows) user mode SDK to read data from your Azure Kinect device.",
"homepage": "https://github.com/microsoft/Azure-Kinect-Sensor-SDK",
"supports": "!osx",
Expand Down
10 changes: 0 additions & 10 deletions ports/libjpeg-turbo/CONTROL

This file was deleted.

24 changes: 9 additions & 15 deletions ports/libjpeg-turbo/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" ENABLE_STATIC)
string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "dynamic" WITH_CRT_DLL)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
jpeg7 WITH_JPEG7
jpeg8 WITH_JPEG8
FEATURES
jpeg7 WITH_JPEG7
jpeg8 WITH_JPEG8
)

vcpkg_configure_cmake(
Expand All @@ -48,7 +49,10 @@ vcpkg_configure_cmake(
-DWITH_CRT_DLL=${WITH_CRT_DLL}
${FEATURE_OPTIONS}
${LIBJPEGTURBO_SIMD}
OPTIONS_DEBUG -DINSTALL_HEADERS=OFF
OPTIONS_DEBUG
-DINSTALL_HEADERS=OFF
MAYBE_UNUSED_VARIABLES
WITH_CRT_DLL
)

vcpkg_install_cmake()
Expand All @@ -60,23 +64,13 @@ if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(RENAME "${CURRENT_PACKAGES_DIR}/lib/turbojpeg-static.lib" "${CURRENT_PACKAGES_DIR}/lib/turbojpeg.lib")
endif()
if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/jpeg-static.lib")
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/jpeg-static.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/jpegd.lib")
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/turbojpeg-static.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/turbojpegd.lib")
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/jpeg-static.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/jpeg.lib")
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/turbojpeg-static.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/turbojpeg.lib")

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin)
endif()
else(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
if(EXISTS "${CURRENT_PACKAGES_DIR}/debug/lib/jpeg.lib")
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/jpeg.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/jpegd.lib")
file(RENAME "${CURRENT_PACKAGES_DIR}/debug/lib/turbojpeg.lib" "${CURRENT_PACKAGES_DIR}/debug/lib/turbojpegd.lib")
endif()
endif()

set(_file "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libjpeg.pc")
if(EXISTS "${_file}" AND VCPKG_TARGET_IS_WINDOWS)
vcpkg_replace_string("${_file}" "-ljpeg" "-ljpegd")
endif()

vcpkg_fixup_pkgconfig()

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
Expand Down
11 changes: 11 additions & 0 deletions ports/libjpeg-turbo/vcpkg-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
find_path(JPEG_INCLUDE_DIR NAMES jpeglib.h PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include" NO_DEFAULT_PATH)
find_library(JPEG_LIBRARY_RELEASE NAMES jpeg PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib" NO_DEFAULT_PATH)
find_library(JPEG_LIBRARY_DEBUG NAMES jpeg PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib" NO_DEFAULT_PATH)
Comment on lines +2 to +3
Copy link
Contributor

Choose a reason for hiding this comment

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

Just include all names you know of or the port will probably have in the future. There is no harm done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would prefer to see the wrapper being maintained to closely match the actual installation, not to list names the port "will probably have in the future".

if(NOT JPEG_INCLUDE_DIR OR NOT JPEG_LIBRARY_RELEASE OR (NOT JPEG_LIBRARY_DEBUG AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib"))
message(FATAL_ERROR "Broken installation of vcpkg port libjpeg-turbo")
endif()
Comment on lines +4 to +6
Copy link
Contributor

Choose a reason for hiding this comment

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

This check is broken (and it broke for me).
If "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/lib" exists it doesn't mean JPEG_LIBRARY_DEBUG has to exist.
It would be better to conditionally add checks for JPEG_LIBRARY_DEBUG and JPEG_LIBRARY_RELEASE if VCPKG_BUILD_TYPE in the portfile is set accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, but... My next PR for libjpeg-turbo is still waiting for #19034 to be merged. Cf. also #19034 (comment) from Sep 13.

if(CMAKE_VERSION VERSION_LESS 3.12)
include(SelectLibraryConfigurations)
select_library_configurations(JPEG)
unset(JPEG_FOUND)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you unsetting? select_library_configurations does not set _FOUND variables.
(probably thinking of https://cmake.org/cmake/help/latest/module/FindPackageHandleStandardArgs.html ?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm interesting does this influence https://cmake.org/cmake/help/latest/prop_gbl/PACKAGES_FOUND.html?
Maybe I need to check the find_package implementation in the cmake sources once to completely understand when it does the lookup and when not.

Copy link
Contributor Author

@dg0yt dg0yt Aug 4, 2021

Choose a reason for hiding this comment

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

Even if cmake fixes it now, it doesn't help for cmake wrappers because it will need a policy, and it won't be available for old cmake versions. It es easier to stay with an unconditional unset, or we might take this into the list of vcpkg wrapper helper functions proposed by @Neumann-A.

endif()
_find_package(${ARGS})
if(JPEG_FOUND AND NOT TARGET JPEG::JPEG)
# Backfill JPEG::JPEG to versions of cmake before 3.12
Expand Down
15 changes: 15 additions & 0 deletions ports/libjpeg-turbo/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "libjpeg-turbo",
"version": "2.0.6",
"port-version": 1,
"description": "libjpeg-turbo is a JPEG image codec that uses SIMD instructions (MMX, SSE2, NEON, AltiVec) to accelerate baseline JPEG compression and decompression on x86, x86-64, ARM, and PowerPC systems.",
"homepage": "https://github.com/libjpeg-turbo/libjpeg-turbo",
"features": {
"jpeg7": {
"description": "Emulate libjpeg v7 API/ABI (this makes libjpeg-turbo backward-incompatible with libjpeg v6b!)"
},
"jpeg8": {
"description": "Emulate libjpeg v8 API/ABI (this makes libjpeg-turbo backward-incompatible with libjpeg v6b!)"
}
}
}
5 changes: 5 additions & 0 deletions versions/a-/azure-kinect-sensor-sdk.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "012a033caf02486f3079b0c42036a807f3a7c4d7",
"version": "1.4.1",
"port-version": 2
},
{
"git-tree": "dc7fdf585419fadcd96b13a800c4323b098256cd",
"version": "1.4.1",
Expand Down
4 changes: 2 additions & 2 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
},
"azure-kinect-sensor-sdk": {
"baseline": "1.4.1",
"port-version": 1
"port-version": 2
},
"azure-macro-utils-c": {
"baseline": "2020-06-17",
Expand Down Expand Up @@ -3302,7 +3302,7 @@
},
"libjpeg-turbo": {
"baseline": "2.0.6",
"port-version": 0
"port-version": 1
},
"libjuice": {
"baseline": "0.7.1",
Expand Down
5 changes: 5 additions & 0 deletions versions/l-/libjpeg-turbo.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "88d4315ae4daa0619554d0465564beee0a688d71",
"version": "2.0.6",
"port-version": 1
},
{
"git-tree": "42aed1a37d04ecdc437a4f52c6dd71740339f478",
"version-string": "2.0.6",
Expand Down