From f56c8174ebe73a620af362b3d4656c2c2f279bf1 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Fri, 9 Feb 2024 07:41:50 +0100 Subject: [PATCH] [tiff] Add lerc support (#35471) * [lerc] Burn C++ linkage into pc file * [tiff] Add lerc support * [cmake-user] Test tiff with lerc * [wxwidgets] Handle tiff/lerc C++ linkage trick --- ports/lerc/cxx-linkage-pkgconfig.patch | 31 +++++++++++++++++++++++ ports/lerc/portfile.cmake | 5 ++-- ports/lerc/vcpkg.json | 2 +- ports/tiff/portfile.cmake | 4 ++- ports/tiff/requires-lerc.patch | 13 ++++++++++ ports/tiff/vcpkg-cmake-wrapper.cmake.in | 19 ++++++++++++++ ports/tiff/vcpkg.json | 15 ++++++++++- ports/wxwidgets/gtk3-link-libraries.patch | 7 ++++- ports/wxwidgets/vcpkg.json | 1 + scripts/test_ports/cmake-user/vcpkg.json | 1 + versions/baseline.json | 6 ++--- versions/l-/lerc.json | 5 ++++ versions/t-/tiff.json | 5 ++++ versions/w-/wxwidgets.json | 5 ++++ 14 files changed, 110 insertions(+), 9 deletions(-) create mode 100644 ports/lerc/cxx-linkage-pkgconfig.patch create mode 100644 ports/tiff/requires-lerc.patch diff --git a/ports/lerc/cxx-linkage-pkgconfig.patch b/ports/lerc/cxx-linkage-pkgconfig.patch new file mode 100644 index 0000000000..1b1f09b0e4 --- /dev/null +++ b/ports/lerc/cxx-linkage-pkgconfig.patch @@ -0,0 +1,31 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index ec42013..8ac570a 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -52,6 +52,16 @@ install(EXPORT LercTargets + ) + + # Configure and install pkgconfig file ++set(FAKE_CXX_LINKAGE "") ++foreach(lib IN LISTS CMAKE_CXX_IMPLICIT_LINK_LIBRARIES) ++ if(lib IN_LIST CMAKE_C_IMPLICIT_LINK_LIBRARIES) ++ continue() ++ elseif(EXISTS "${lib}") ++ string(APPEND FAKE_CXX_LINKAGE " ${CMAKE_LINK_LIBRARY_FILE_FLAG}${lib}") ++ else() ++ string(APPEND FAKE_CXX_LINKAGE " ${CMAKE_LINK_LIBRARY_FLAG}${lib}") ++ endif() ++endforeach() + configure_file(Lerc.pc.in ${CMAKE_CURRENT_BINARY_DIR}/Lerc.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Lerc.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +diff --git a/Lerc.pc.in b/Lerc.pc.in +index 96cf6eb..8856171 100644 +--- a/Lerc.pc.in ++++ b/Lerc.pc.in +@@ -9,4 +9,4 @@ URL: @PROJECT_HOMEPAGE_URL@ + Version: @PROJECT_VERSION@ + Cflags: -I${includedir} + Cflags.private: -DLERC_STATIC +-Libs: -L${libdir} -lLerc ++Libs: -L${libdir} -lLerc @FAKE_CXX_LINKAGE@ diff --git a/ports/lerc/portfile.cmake b/ports/lerc/portfile.cmake index f980b545ee..41949548d5 100644 --- a/ports/lerc/portfile.cmake +++ b/ports/lerc/portfile.cmake @@ -5,8 +5,9 @@ vcpkg_from_github( SHA512 36fe453b6e732f6bed554d1c1c5cd4668aec63593d6de11f12b659c7b9cbc059ac9aaacc6cea483b3257d522f1b07e13c299914d08b1f8aeb0bb2cde42ba47cf HEAD_REF master PATCHES - "create_package.patch" - "include_algorithm_for_std_min.patch" + create_package.patch + include_algorithm_for_std_min.patch + cxx-linkage-pkgconfig.patch ) vcpkg_cmake_configure( diff --git a/ports/lerc/vcpkg.json b/ports/lerc/vcpkg.json index 45dc3ee0c5..38d2fefefd 100644 --- a/ports/lerc/vcpkg.json +++ b/ports/lerc/vcpkg.json @@ -1,7 +1,7 @@ { "name": "lerc", "version": "4.0", - "port-version": 1, + "port-version": 2, "description": "An open-source image or raster format which supports rapid encoding and decoding for any pixel type", "homepage": "https://github.com/Esri/lerc", "license": "Apache-2.0", diff --git a/ports/tiff/portfile.cmake b/ports/tiff/portfile.cmake index 426d8af72a..1e5366fb05 100644 --- a/ports/tiff/portfile.cmake +++ b/ports/tiff/portfile.cmake @@ -7,6 +7,7 @@ vcpkg_from_gitlab( HEAD_REF master PATCHES FindCMath.patch + requires-lerc.patch ) vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS @@ -16,6 +17,8 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS jpeg CMAKE_REQUIRE_FIND_PACKAGE_JPEG libdeflate libdeflate libdeflate CMAKE_REQUIRE_FIND_PACKAGE_Deflate + lerc lerc + lerc CMAKE_REQUIRE_FIND_PACKAGE_LERC lzma lzma lzma CMAKE_REQUIRE_FIND_PACKAGE_liblzma tools tiff-tools @@ -37,7 +40,6 @@ vcpkg_cmake_configure( -Dtiff-tests=OFF -Djbig=OFF # This is disabled by default due to GPL/Proprietary licensing. -Djpeg12=OFF - -Dlerc=OFF -DCMAKE_DISABLE_FIND_PACKAGE_OpenGL=ON -DCMAKE_DISABLE_FIND_PACKAGE_GLUT=ON -DZSTD_HAVE_DECOMPRESS_STREAM=ON diff --git a/ports/tiff/requires-lerc.patch b/ports/tiff/requires-lerc.patch new file mode 100644 index 0000000000..5f3a3d13c4 --- /dev/null +++ b/ports/tiff/requires-lerc.patch @@ -0,0 +1,13 @@ +diff --git a/libtiff/CMakeLists.txt b/libtiff/CMakeLists.txt +index 9c8024e..baee592 100755 +--- a/libtiff/CMakeLists.txt ++++ b/libtiff/CMakeLists.txt +@@ -148,7 +148,7 @@ if(JBIG_SUPPORT) + endif() + if(LERC_SUPPORT) + target_link_libraries(tiff PRIVATE LERC::LERC) +- list(APPEND tiff_libs_private_list "${LERC_LIBRARY}") ++ string(APPEND tiff_requires_private " Lerc") + if(NOT BUILD_SHARED_LIBS) + set_target_properties(tiff PROPERTIES COMPILE_DEFINITIONS LERC_STATIC) + endif() diff --git a/ports/tiff/vcpkg-cmake-wrapper.cmake.in b/ports/tiff/vcpkg-cmake-wrapper.cmake.in index 1d04ec7a0a..84c37e1cdd 100644 --- a/ports/tiff/vcpkg-cmake-wrapper.cmake.in +++ b/ports/tiff/vcpkg-cmake-wrapper.cmake.in @@ -59,6 +59,25 @@ if(TIFF_FOUND AND "@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static") unset(z_vcpkg_config) unset(z_vcpkg_tiff_zstd_target) endif() + if("@lerc@") + find_package(unofficial-lerc ${z_vcpkg_tiff_find_options}) + get_target_property(z_vcpkg_lerc_configs unofficial::Lerc::Lerc IMPORTED_CONFIGURATIONS) + foreach(z_vcpkg_property IN ITEMS IMPORTED_IMPLIB_ IMPORTED_LOCATION_) + foreach(z_vcpkg_config IN LISTS z_vcpkg_lerc_configs) + get_target_property(Z_VCPKG_LERC_LIBRARY_${z_vcpkg_config} unofficial::Lerc::Lerc "${z_vcpkg_property}${z_vcpkg_config}") + endforeach() + select_library_configurations(Z_VCPKG_LERC) + if(Z_VCPKG_LERC_LIBRARIES) + break() + endif() + endforeach() + list(APPEND z_vcpkg_tiff_link_libraries "\$") + list(APPEND z_vcpkg_tiff_libraries ${Z_VCPKG_LERC_LIBRARIES}) + unset(z_vcpkg_config) + unset(z_vcpkg_lerc_configs) + unset(z_vcpkg_property) + unset(Z_VCPKG_LERC_FOUND) + endif() if("@libdeflate@") find_package(libdeflate ${z_vcpkg_tiff_find_options}) set(z_vcpkg_property "IMPORTED_LOCATION_") diff --git a/ports/tiff/vcpkg.json b/ports/tiff/vcpkg.json index eea6684aa7..8e59bd6384 100644 --- a/ports/tiff/vcpkg.json +++ b/ports/tiff/vcpkg.json @@ -1,7 +1,7 @@ { "name": "tiff", "version": "4.6.0", - "port-version": 2, + "port-version": 3, "description": "A library that supports the manipulation of TIFF image files", "homepage": "https://libtiff.gitlab.io/libtiff/", "license": "libtiff", @@ -30,6 +30,19 @@ "libjpeg-turbo" ] }, + "lerc": { + "description": "Support LERC compression", + "dependencies": [ + "lerc", + { + "name": "tiff", + "default-features": false, + "features": [ + "zip" + ] + } + ] + }, "libdeflate": { "description": "Use libdeflate for faster ZIP support", "dependencies": [ diff --git a/ports/wxwidgets/gtk3-link-libraries.patch b/ports/wxwidgets/gtk3-link-libraries.patch index fe2736b2da..4e4c4819ab 100644 --- a/ports/wxwidgets/gtk3-link-libraries.patch +++ b/ports/wxwidgets/gtk3-link-libraries.patch @@ -2,10 +2,15 @@ diff --git a/build/cmake/modules/FindGTK3.cmake b/build/cmake/modules/FindGTK3.c index d2939a1..daf33fe 100644 --- a/build/cmake/modules/FindGTK3.cmake +++ b/build/cmake/modules/FindGTK3.cmake -@@ -47,6 +47,7 @@ include(CheckSymbolExists) +@@ -47,6 +47,12 @@ include(CheckSymbolExists) set(CMAKE_REQUIRED_INCLUDES ${GTK3_INCLUDE_DIRS}) check_symbol_exists(GDK_WINDOWING_WAYLAND "gdk/gdk.h" wxHAVE_GDK_WAYLAND) check_symbol_exists(GDK_WINDOWING_X11 "gdk/gdk.h" wxHAVE_GDK_X11) ++# With Lerc support in TIFF, Gtk3 may carry C++ compiler libs which break FindWxWidgets.cmake. ++# WxWidgets is C++, so we can remove them here using the inverse pattern. ++set(cxx_libs "${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES}") ++list(REMOVE_ITEM cxx_libs ${CMAKE_C_IMPLICIT_LINK_LIBRARIES}) ++list(REMOVE_ITEM GTK3_LINK_LIBRARIES ${cxx_libs}) +set(GTK3_LIBRARIES "${GTK3_LINK_LIBRARIES}" CACHE INTERNAL "") include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK3 DEFAULT_MSG GTK3_INCLUDE_DIRS GTK3_LIBRARIES VERSION_OK) diff --git a/ports/wxwidgets/vcpkg.json b/ports/wxwidgets/vcpkg.json index a160545909..666cb62c45 100644 --- a/ports/wxwidgets/vcpkg.json +++ b/ports/wxwidgets/vcpkg.json @@ -1,6 +1,7 @@ { "name": "wxwidgets", "version": "3.2.4", + "port-version": 1, "description": [ "Widget toolkit and tools library for creating graphical user interfaces (GUIs) for cross-platform applications. ", "Set WXWIDGETS_USE_STL in a custom triplet to build with the wxUSE_STL build option.", diff --git a/scripts/test_ports/cmake-user/vcpkg.json b/scripts/test_ports/cmake-user/vcpkg.json index 1e727be0e5..e79ee97d8b 100644 --- a/scripts/test_ports/cmake-user/vcpkg.json +++ b/scripts/test_ports/cmake-user/vcpkg.json @@ -158,6 +158,7 @@ "name": "tiff", "default-features": false, "features": [ + "lerc", "libdeflate", "zstd" ] diff --git a/versions/baseline.json b/versions/baseline.json index a2aadf0011..22edd1b59b 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -4074,7 +4074,7 @@ }, "lerc": { "baseline": "4.0", - "port-version": 1 + "port-version": 2 }, "lest": { "baseline": "1.35.1", @@ -8510,7 +8510,7 @@ }, "tiff": { "baseline": "4.6.0", - "port-version": 2 + "port-version": 3 }, "tinkerforge": { "baseline": "2.1.25", @@ -9250,7 +9250,7 @@ }, "wxwidgets": { "baseline": "3.2.4", - "port-version": 0 + "port-version": 1 }, "wyhash": { "baseline": "2023-01-25", diff --git a/versions/l-/lerc.json b/versions/l-/lerc.json index 95998d5ff4..5121727338 100644 --- a/versions/l-/lerc.json +++ b/versions/l-/lerc.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "dcd63e138165489f0c4c068cd98cd713c1174475", + "version": "4.0", + "port-version": 2 + }, { "git-tree": "b7391a7d4c1b31d4fcd7160f305c7b9de9621ff2", "version": "4.0", diff --git a/versions/t-/tiff.json b/versions/t-/tiff.json index 7596064aa9..d3a2203f95 100644 --- a/versions/t-/tiff.json +++ b/versions/t-/tiff.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "25e53ce930bd517f7824c9dd90c39a9d11931a20", + "version": "4.6.0", + "port-version": 3 + }, { "git-tree": "eee46c160d2fcf26a0013e7159adc2e6c03039d5", "version": "4.6.0", diff --git a/versions/w-/wxwidgets.json b/versions/w-/wxwidgets.json index 314acc4b7d..fe8b9531fa 100644 --- a/versions/w-/wxwidgets.json +++ b/versions/w-/wxwidgets.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "4d0a489a0a24e703960f526ed1c40e8b7ae2a221", + "version": "3.2.4", + "port-version": 1 + }, { "git-tree": "b76c48ce396ff7c6e49ec508b7c5bd749fb94fbb", "version": "3.2.4",