vcpkg/ports/tiff/fix-pkgconfig.patch
2022-01-14 16:12:41 -08:00

105 lines
3.0 KiB
Diff

From f337e19d0d0564b1b000ecd5dfbefed6c37f4d5b Mon Sep 17 00:00:00 2001
From: Matthias Kuhn <matthias@opengis.ch>
Date: Tue, 21 Dec 2021 07:57:09 +0000
Subject: [PATCH] Fix pkgconfig
---
CMakeLists.txt | 4 ++--
libtiff-4.pc.in | 3 ++-
libtiff/CMakeLists.txt | 19 +++++++++++++++++++
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2188f97..93e6a34 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -124,8 +124,6 @@ include(WindowsSupport)
# Orthogonal features
include(LibraryFeatures)
-# pkg-config support
-include(PkgConfig)
# math.h/libm portability
find_package(CMath REQUIRED)
@@ -156,6 +154,8 @@ add_subdirectory(man)
add_subdirectory(html)
endif()
+# pkg-config support
+include(PkgConfig)
message(STATUS "")
message(STATUS "Libtiff is now configured for ${CMAKE_SYSTEM}")
diff --git a/libtiff-4.pc.in b/libtiff-4.pc.in
index abe75a6..8899725 100644
--- a/libtiff-4.pc.in
+++ b/libtiff-4.pc.in
@@ -5,7 +5,8 @@ includedir=@includedir@
Name: libtiff
Description: Tag Image File Format (TIFF) library.
-Version: @VERSION@
+Version: @LIBTIFF_VERSION_FULL@
Libs: -L${libdir} -ltiff
Libs.private: @tiff_libs_private@
Cflags: -I${includedir}
+Requires.private: @tiff_requires_private@
diff --git a/libtiff/CMakeLists.txt b/libtiff/CMakeLists.txt
index db5f140..32721ec 100755
--- a/libtiff/CMakeLists.txt
+++ b/libtiff/CMakeLists.txt
@@ -106,14 +106,19 @@ target_include_directories(tiff
${TIFF_INCLUDES}
)
+set(tiff_libs_private "")
+set(tiff_requires_private "")
+
if(ZIP_SUPPORT)
target_link_libraries(tiff PRIVATE ZLIB::ZLIB)
+ string(APPEND tiff_requires_private " zlib")
endif()
if(ZIP_SUPPORT AND LIBDEFLATE_SUPPORT)
target_link_libraries(tiff PRIVATE Deflate::Deflate)
endif()
if(JPEG_SUPPORT)
target_link_libraries(tiff PRIVATE JPEG::JPEG)
+ string(APPEND tiff_requires_private " libjpeg")
if(JPEG_DUAL_MODE_8_12)
target_include_directories(tiff PRIVATE ${JPEG12_INCLUDE_DIR})
target_link_libraries(tiff PRIVATE ${JPEG12_LIBRARIES})
@@ -127,15 +132,29 @@ if(LERC_SUPPORT)
endif()
if(LZMA_SUPPORT)
target_link_libraries(tiff PRIVATE LibLZMA::LibLZMA)
+ string(APPEND tiff_requires_private " liblzma")
endif()
if(ZSTD_SUPPORT)
target_link_libraries(tiff PRIVATE ZSTD::ZSTD)
+ string(APPEND tiff_requires_private " libzstd")
endif()
if(WEBP_SUPPORT)
target_link_libraries(tiff PRIVATE WebP::WebP)
+ string(APPEND tiff_requires_private " libwebp")
endif()
target_link_libraries(tiff PRIVATE CMath::CMath)
+include(CheckLibraryExists)
+
+CHECK_LIBRARY_EXISTS(m sin "" HAVE_LIB_M)
+
+if (HAVE_LIB_M)
+ string(APPEND tiff_libs_private " -lm")
+endif()
+
+set(tiff_libs_private "${tiff_libs_private}" PARENT_SCOPE)
+set(tiff_requires_private "${tiff_requires_private}" PARENT_SCOPE)
+
set_target_properties(tiff PROPERTIES SOVERSION ${SO_COMPATVERSION})
if(NOT CYGWIN)
# This property causes shared libraries on Linux to have the full version
--
2.25.1