[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
This commit is contained in:
Kai Pastor 2024-02-09 07:41:50 +01:00 committed by GitHub
parent 2c7d2ae88f
commit f56c8174eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 110 additions and 9 deletions

View File

@ -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@

View File

@ -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(

View File

@ -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",

View File

@ -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

View File

@ -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()

View File

@ -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 "\$<LINK_ONLY:unofficial::Lerc::Lerc>")
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_")

View File

@ -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": [

View File

@ -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)

View File

@ -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.",

View File

@ -158,6 +158,7 @@
"name": "tiff",
"default-features": false,
"features": [
"lerc",
"libdeflate",
"zstd"
]

View File

@ -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",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "dcd63e138165489f0c4c068cd98cd713c1174475",
"version": "4.0",
"port-version": 2
},
{
"git-tree": "b7391a7d4c1b31d4fcd7160f305c7b9de9621ff2",
"version": "4.0",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "25e53ce930bd517f7824c9dd90c39a9d11931a20",
"version": "4.6.0",
"port-version": 3
},
{
"git-tree": "eee46c160d2fcf26a0013e7159adc2e6c03039d5",
"version": "4.6.0",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "4d0a489a0a24e703960f526ed1c40e8b7ae2a221",
"version": "3.2.4",
"port-version": 1
},
{
"git-tree": "b76c48ce396ff7c6e49ec508b7c5bd749fb94fbb",
"version": "3.2.4",