From 2f7a83304f1b04af7cceff13e22ea2b5428d2243 Mon Sep 17 00:00:00 2001 From: ayeteadoe Date: Thu, 26 Jun 2025 10:13:00 -0700 Subject: [PATCH] Meta: Patch libjxl port to not link with libm when building with msvc The libjxl port is required to add the `msvc-remove-libm` patch. Otherwise LibGfx attempts to link with 'm.lib' which is not valid for MSVC as the CRT bundles math functions implicitly unlike on Unix --- .../libjxl/msvc-remove-libm.patch | 24 +++++++++++++++++++ .../vcpkg/overlay-ports/libjxl/portfile.cmake | 1 + 2 files changed, 25 insertions(+) create mode 100644 Meta/CMake/vcpkg/overlay-ports/libjxl/msvc-remove-libm.patch diff --git a/Meta/CMake/vcpkg/overlay-ports/libjxl/msvc-remove-libm.patch b/Meta/CMake/vcpkg/overlay-ports/libjxl/msvc-remove-libm.patch new file mode 100644 index 00000000000..49b8ddd7f0b --- /dev/null +++ b/Meta/CMake/vcpkg/overlay-ports/libjxl/msvc-remove-libm.patch @@ -0,0 +1,24 @@ +--- a/lib/jxl.cmake 2024-11-26 05:02:35.000000000 -0800 ++++ b/lib/jxl.cmake 2025-06-26 08:37:25.999263200 -0700 +@@ -269,12 +269,15 @@ + set(JPEGXL_LIBRARY_REQUIRES + "libhwy libbrotlienc libbrotlidec libjxl_cms") + +-if (BUILD_SHARED_LIBS) +- set(JPEGXL_REQUIRES_TYPE "Requires.private") +- set(JPEGXL_PRIVATE_LIBS "-lm ${PKGCONFIG_CXX_LIB}") +-else() +- set(JPEGXL_REQUIRES_TYPE "Requires") +- set(JPEGXL_PUBLIC_LIBS "-lm ${PKGCONFIG_CXX_LIB}") ++# MSVCRT bundles math functions ++if(NOT MSVC) ++ if (BUILD_SHARED_LIBS) ++ set(JPEGXL_REQUIRES_TYPE "Requires.private") ++ set(JPEGXL_PRIVATE_LIBS "-lm ${PKGCONFIG_CXX_LIB}") ++ else() ++ set(JPEGXL_REQUIRES_TYPE "Requires") ++ set(JPEGXL_PUBLIC_LIBS "-lm ${PKGCONFIG_CXX_LIB}") ++ endif() + endif() + + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/jxl/libjxl.pc.in" diff --git a/Meta/CMake/vcpkg/overlay-ports/libjxl/portfile.cmake b/Meta/CMake/vcpkg/overlay-ports/libjxl/portfile.cmake index c8ce55e6132..507b9423c9b 100644 --- a/Meta/CMake/vcpkg/overlay-ports/libjxl/portfile.cmake +++ b/Meta/CMake/vcpkg/overlay-ports/libjxl/portfile.cmake @@ -6,6 +6,7 @@ vcpkg_from_github( HEAD_REF main PATCHES fix-dependencies.patch + msvc-remove-libm.patch # https://github.com/microsoft/vcpkg/pull/46177 ) vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS