libtiff: Merge branch 'fix_win_build' into 'master'

From 70f8d926cc9e984d2650f573e7cb8e519d367b4f Mon Sep 17 00:00:00 2001
From: Even Rouault <[EMAIL REDACTED]>
Date: Fri, 9 Jun 2023 15:39:38 +0200
Subject: [PATCH 1/2] Add tif_win32_versioninfo.rc and tif_tools_versioninfo.rc
 to EXTRA_DIST

---
 libtiff/Makefile.am | 3 ++-
 tools/Makefile.am   | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libtiff/Makefile.am b/libtiff/Makefile.am
index c688a3c4..1d1a35d7 100644
--- a/libtiff/Makefile.am
+++ b/libtiff/Makefile.am
@@ -33,7 +33,8 @@ EXTRA_DIST = \
 	libtiff.map \
 	libtiffxx.map \
 	tif_config.h.cmake.in \
-	tiffconf.h.cmake.in
+	tiffconf.h.cmake.in \
+	tif_win32_versioninfo.rc
 
 libtiffinclude_HEADERS = \
 	tiff.h \
diff --git a/tools/Makefile.am b/tools/Makefile.am
index c6c4c8af..877ffb26 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -27,7 +27,8 @@ LIBPORT = $(top_builddir)/port/libport.la
 LIBTIFF = $(top_builddir)/libtiff/libtiff.la
 
 EXTRA_DIST = \
-	CMakeLists.txt
+	CMakeLists.txt \
+	tif_tools_versioninfo.rc
 
 if TIFF_TOOLS
 bin_PROGRAMS = \

From 72187a0fb727e0760088ec4e5a3b8e681b313e75 Mon Sep 17 00:00:00 2001
From: Even Rouault <even.rouault@spatialys.com>
Date: Fri, 9 Jun 2023 15:40:17 +0200
Subject: [PATCH 2/2] cmake/PkgConfig.cmake: avoid CMake error when prefix or
 suffix is empty

---
 cmake/PkgConfig.cmake | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/cmake/PkgConfig.cmake b/cmake/PkgConfig.cmake
index 9a7842c4..75dc28e8 100644
--- a/cmake/PkgConfig.cmake
+++ b/cmake/PkgConfig.cmake
@@ -29,13 +29,13 @@ function(set_libs_private out_var)
     foreach(lib IN LISTS ARGN)
         get_filename_component(name "${lib}" NAME)
         foreach(prefix IN LISTS CMAKE_FIND_LIBRARY_PREFIXES)
-            if(name MATCHES "^${prefix}")
+            if(NOT("${prefix}" STREQUAL "") AND name MATCHES "^${prefix}")
                 string(REGEX REPLACE "^${prefix}" "" name "${name}")
                 break()
             endif()
         endforeach()
         foreach(suffix IN LISTS CMAKE_FIND_LIBRARY_SUFFIXES)
-            if(name MATCHES "${suffix}$")
+            if(NOT("${suffix}" STREQUAL "") AND name MATCHES "${suffix}$")
                 string(REGEX REPLACE "${suffix}$" "" name "${name}")
                 break()
             endif()
@@ -66,4 +66,4 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libtiff-4.pc.in
 if (tiff-install)
     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc
             DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
-endif()
\ No newline at end of file
+endif()