summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tiff/cmake')
-rw-r--r--tiff/cmake/AutotoolsCompat.cmake32
-rw-r--r--tiff/cmake/AutotoolsVersion.cmake50
-rw-r--r--tiff/cmake/CXXLibrary.cmake32
-rw-r--r--tiff/cmake/CompilerChecks.cmake124
-rw-r--r--tiff/cmake/DeflateCodec.cmake45
-rw-r--r--tiff/cmake/FindCMath.cmake72
-rw-r--r--tiff/cmake/FindDeflate.cmake116
-rw-r--r--tiff/cmake/FindJBIG.cmake116
-rw-r--r--tiff/cmake/FindJPEG.cmake142
-rw-r--r--tiff/cmake/FindLERC.cmake86
-rw-r--r--tiff/cmake/FindLibLZMA.cmake126
-rw-r--r--tiff/cmake/FindWebP.cmake91
-rw-r--r--tiff/cmake/FindZSTD.cmake107
-rw-r--r--tiff/cmake/IncludeChecks.cmake36
-rw-r--r--tiff/cmake/InternalCodecs.cmake46
-rw-r--r--tiff/cmake/JBIGCodec.cmake47
-rw-r--r--tiff/cmake/JPEGCodec.cmake56
-rw-r--r--tiff/cmake/LERCCodec.cmake32
-rw-r--r--tiff/cmake/LZMACodec.cmake33
-rw-r--r--tiff/cmake/LargeFileSupport.cmake32
-rw-r--r--tiff/cmake/LibraryFeatures.cmake60
-rw-r--r--tiff/cmake/LinkerChecks.cmake50
-rw-r--r--tiff/cmake/OpenGLChecks.cmake43
-rw-r--r--tiff/cmake/PixarLogCodec.cmake33
-rw-r--r--tiff/cmake/PkgConfig.cmake36
-rw-r--r--tiff/cmake/ProcessorChecks.cmake47
-rw-r--r--tiff/cmake/Release.cmake31
-rw-r--r--tiff/cmake/ReleaseScript.cmake32
-rw-r--r--tiff/cmake/SymbolChecks.cmake43
-rw-r--r--tiff/cmake/TypeSizeChecks.cmake52
-rw-r--r--tiff/cmake/WebPCodec.cmake35
-rw-r--r--tiff/cmake/WindowsSupport.cmake39
-rw-r--r--tiff/cmake/ZSTDCodec.cmake53
33 files changed, 1975 insertions, 0 deletions
diff --git a/tiff/cmake/AutotoolsCompat.cmake b/tiff/cmake/AutotoolsCompat.cmake
new file mode 100644
index 00000000..f491a8a1
--- /dev/null
+++ b/tiff/cmake/AutotoolsCompat.cmake
@@ -0,0 +1,32 @@
+# Autotools compatibility
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+
+# For autotools header compatibility
+set(PACKAGE_NAME "LibTIFF Software")
+set(PACKAGE_TARNAME "${PROJECT_NAME}")
+set(PACKAGE_VERSION "${PROJECT_VERSION}${LIBTIFF_ALPHA_VERSION}")
+set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
+set(PACKAGE_BUGREPORT "tiff@lists.maptools.org")
diff --git a/tiff/cmake/AutotoolsVersion.cmake b/tiff/cmake/AutotoolsVersion.cmake
new file mode 100644
index 00000000..0f660878
--- /dev/null
+++ b/tiff/cmake/AutotoolsVersion.cmake
@@ -0,0 +1,50 @@
+# Read version information from configure.ac.
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+
+# Get version from configure.ac
+FILE(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/configure.ac" configure REGEX "^LIBTIFF_.*=")
+foreach(line ${configure})
+ foreach(var LIBTIFF_MAJOR_VERSION LIBTIFF_MINOR_VERSION LIBTIFF_MICRO_VERSION LIBTIFF_ALPHA_VERSION
+ LIBTIFF_CURRENT LIBTIFF_REVISION LIBTIFF_AGE)
+ if(NOT ${var} AND line MATCHES "^${var}=(.*)")
+ set(${var} "${CMAKE_MATCH_1}")
+ break()
+ endif()
+ endforeach()
+endforeach()
+
+# Package version
+set(LIBTIFF_VERSION "${LIBTIFF_MAJOR_VERSION}.${LIBTIFF_MINOR_VERSION}.${LIBTIFF_MICRO_VERSION}")
+set(LIBTIFF_VERSION_FULL "${LIBTIFF_VERSION}${LIBTIFF_ALPHA_VERSION}")
+
+# Convert the libtool version variables to proper major and minor versions
+math(EXPR SO_MAJOR "${LIBTIFF_CURRENT} - ${LIBTIFF_AGE}")
+set(SO_MINOR "${LIBTIFF_AGE}")
+set(SO_REVISION "${LIBTIFF_REVISION}")
+
+# Library version (unlike libtool's baroque scheme, WYSIWYG here)
+set(SO_COMPATVERSION "${SO_MAJOR}")
+set(SO_VERSION "${SO_MAJOR}.${SO_MINOR}.${SO_REVISION}")
diff --git a/tiff/cmake/CXXLibrary.cmake b/tiff/cmake/CXXLibrary.cmake
new file mode 100644
index 00000000..3fc15a98
--- /dev/null
+++ b/tiff/cmake/CXXLibrary.cmake
@@ -0,0 +1,32 @@
+# C++ library option
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+# C++ support
+option(cxx "Enable C++ stream API building (requires C++ compiler)" ON)
+set(CXX_SUPPORT FALSE)
+if (cxx)
+ enable_language(CXX)
+ set(CXX_SUPPORT TRUE)
+endif()
diff --git a/tiff/cmake/CompilerChecks.cmake b/tiff/cmake/CompilerChecks.cmake
new file mode 100644
index 00000000..8ac5564b
--- /dev/null
+++ b/tiff/cmake/CompilerChecks.cmake
@@ -0,0 +1,124 @@
+# Compiler feature checks
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+
+include(CheckCCompilerFlag)
+
+
+# These are annoyingly verbose, produce false positives or don't work
+# nicely with all supported compiler versions, so are disabled unless
+# explicitly enabled.
+option(extra-warnings "Enable extra compiler warnings" OFF)
+
+# This will cause the compiler to fail when an error occurs.
+option(fatal-warnings "Compiler warnings are errors" OFF)
+
+# Check if the compiler supports each of the following additional
+# flags, and enable them if supported. This greatly improves the
+# quality of the build by checking for a number of common problems,
+# some of which are quite serious.
+if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
+ CMAKE_C_COMPILER_ID MATCHES "Clang")
+ set(test_flags
+ -Wall
+ -Winline
+ -Wformat-security
+ -Wpointer-arith
+ -Wdisabled-optimization
+ -Wno-unknown-pragmas
+ -fstrict-aliasing)
+ if(extra-warnings)
+ list(APPEND test_flags
+ -pedantic
+ -Wextra
+ -Wformat
+ -Wformat-overflow
+ -Wformat-nonliteral
+ -Wformat-signedness
+ -Wformat-truncation
+ -Wdeclaration-after-statement
+ -Wconversion
+ -Wsign-conversion
+ -Wnull-dereference
+ -Wdouble-promotion
+ -Wmisleading-indentation
+ -Wmissing-include-dirs
+ -Wswitch-default
+ -Wswitch-enum
+ -Wunused-local-typedefs
+ -Wunused-parameter
+ -Wuninitialized
+ -Warith-conversion
+ -Wbool-operation
+ -Wduplicated-branches
+ -Wduplicated-cond
+ -Wshadow
+ -Wunused-macros
+ -Wc99-c11-compat
+ -Wcast-qual
+ -Wcast-align
+ -Wwrite-strings
+ -Wdangling-else
+ -Wsizeof-array-div
+ -Wsizeof-pointer-div
+ -Wsizeof-pointer-memaccess
+ -Wlogical-op
+ -Wlogical-not-parentheses
+ -Wstrict-prototypes
+ -Wmissing-declarations
+ -Wredundant-decls
+ -Wno-int-to-pointer-cast
+ -Wfloat-equal
+ -Wfloat-conversion
+ -Wmissing-prototypes
+ -Wunreachable-code)
+ endif()
+ if(fatal-warnings)
+ list(APPEND test_flags
+ -Werror)
+ endif()
+elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+ set(test_flags)
+ if(extra-warnings)
+ list(APPEND test_flags
+ /W4)
+ else()
+ list(APPEND test_flags
+ /W3)
+ endif()
+ if (fatal-warnings)
+ list(APPEND test_flags
+ /WX)
+ endif()
+endif()
+
+foreach(flag ${test_flags})
+ string(REGEX REPLACE "[^A-Za-z0-9]" "_" flag_var "${flag}")
+ set(test_c_flag "C_FLAG${flag_var}")
+ CHECK_C_COMPILER_FLAG(${flag} "${test_c_flag}")
+ if (${test_c_flag})
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
+ endif (${test_c_flag})
+endforeach(flag ${test_flags})
diff --git a/tiff/cmake/DeflateCodec.cmake b/tiff/cmake/DeflateCodec.cmake
new file mode 100644
index 00000000..76e5673e
--- /dev/null
+++ b/tiff/cmake/DeflateCodec.cmake
@@ -0,0 +1,45 @@
+# Checks for deflate codec support
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+
+# ZLIB
+set(ZLIB_SUPPORT FALSE)
+find_package(ZLIB)
+option(zlib "use zlib (required for Deflate compression)" ${ZLIB_FOUND})
+if(zlib AND ZLIB_FOUND)
+ set(ZLIB_SUPPORT TRUE)
+endif()
+set(ZIP_SUPPORT ${ZLIB_SUPPORT})
+
+# libdeflate
+set(LIBDEFLATE_SUPPORT FALSE)
+find_package(Deflate)
+option(libdeflate "use libdeflate (optional for faster Deflate support, still requires zlib)" ${Deflate_FOUND})
+if (libdeflate AND Deflate_FOUND AND ZIP_SUPPORT)
+ set(LIBDEFLATE_SUPPORT TRUE)
+endif()
+if(Deflate_FOUND AND NOT ZIP_SUPPORT)
+ message(WARNING "libdeflate available but zlib is not. libdeflate cannot be used")
+endif()
diff --git a/tiff/cmake/FindCMath.cmake b/tiff/cmake/FindCMath.cmake
new file mode 100644
index 00000000..2da3b7f1
--- /dev/null
+++ b/tiff/cmake/FindCMath.cmake
@@ -0,0 +1,72 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindCMath
+--------
+
+Find the native CMath includes and library.
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``CMath::CMath``, if
+CMath has been found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module defines the following variables:
+
+::
+
+ CMath_INCLUDE_DIRS - Where to find math.h
+ CMath_LIBRARIES - List of libraries when using CMath.
+ CMath_FOUND - True if CMath found.
+
+#]=======================================================================]
+
+
+include(CheckSymbolExists)
+include(CheckLibraryExists)
+
+check_symbol_exists(pow "math.h" CMath_HAVE_LIBC_POW)
+if(NOT CMath_HAVE_LIBC_POW)
+ find_library(CMath_LIBRARY NAMES m)
+
+ set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
+ set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${CMath_LIBRARY})
+ check_symbol_exists(pow "math.h" CMath_HAVE_LIBM_POW)
+ set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
+endif()
+
+set(CMath_pow FALSE)
+if(CMath_HAVE_LIBC_POW OR CMath_HAVE_LIBM_POW)
+ set(CMath_pow TRUE)
+endif()
+
+set(CMath_INCLUDE_DIRS)
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(CMath REQUIRED_VARS CMath_pow)
+
+if(CMath_FOUND)
+ if(NOT CMath_INCLUDE_DIRS)
+ set(CMath_INCLUDE_DIRS)
+ endif()
+ if(NOT CMath_LIBRARIES)
+ if (CMath_LIBRARY)
+ set(CMath_LIBRARIES ${CMath_LIBRARY})
+ endif()
+ endif()
+
+ if(NOT TARGET CMath::CMath)
+ if(CMath_LIBRARIES)
+ add_library(CMath::CMath UNKNOWN IMPORTED)
+ set_target_properties(CMath::CMath PROPERTIES
+ IMPORTED_LOCATION "${CMath_LIBRARY}")
+ else()
+ add_library(CMath::CMath INTERFACE IMPORTED)
+ endif()
+ endif()
+endif()
diff --git a/tiff/cmake/FindDeflate.cmake b/tiff/cmake/FindDeflate.cmake
new file mode 100644
index 00000000..ef6a5765
--- /dev/null
+++ b/tiff/cmake/FindDeflate.cmake
@@ -0,0 +1,116 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindDeflate
+--------
+
+Find the native Deflate includes and library.
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``Deflate::Deflate``, if
+Deflate has been found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module defines the following variables:
+
+::
+
+ Deflate_INCLUDE_DIRS - where to find deflate.h, etc.
+ Deflate_LIBRARIES - List of libraries when using deflate.
+ Deflate_FOUND - True if deflate found.
+
+::
+
+ Deflate_VERSION_STRING - The version of deflate found (x.y.z)
+ Deflate_VERSION_MAJOR - The major version of deflate
+ Deflate_VERSION_MINOR - The minor version of deflate
+
+ Debug and Release variants are found separately.
+#]=======================================================================]
+
+# Standard names to search for
+set(Deflate_NAMES deflate deflatestatic)
+set(Deflate_NAMES_DEBUG deflated deflatestaticd)
+
+find_path(Deflate_INCLUDE_DIR
+ NAMES libdeflate.h
+ PATH_SUFFIXES include)
+
+set(Deflate_OLD_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
+# Library has a "lib" prefix even on Windows.
+set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "")
+
+# Allow Deflate_LIBRARY to be set manually, as the location of the deflate library
+if(NOT Deflate_LIBRARY)
+ find_library(Deflate_LIBRARY_RELEASE
+ NAMES ${Deflate_NAMES}
+ PATH_SUFFIXES lib)
+ find_library(Deflate_LIBRARY_DEBUG
+ NAMES ${Deflate_NAMES_DEBUG}
+ PATH_SUFFIXES lib)
+
+ include(SelectLibraryConfigurations)
+ select_library_configurations(Deflate)
+endif()
+
+set(CMAKE_FIND_LIBRARY_PREFIXES "${Deflate_OLD_FIND_LIBRARY_PREFIXES}")
+
+unset(Deflate_NAMES)
+unset(Deflate_NAMES_DEBUG)
+unset(Deflate_OLD_FIND_LIBRARY_PREFIXES)
+
+mark_as_advanced(Deflate_INCLUDE_DIR)
+
+if(Deflate_INCLUDE_DIR AND EXISTS "${Deflate_INCLUDE_DIR}/deflate.h")
+ file(STRINGS "${Deflate_INCLUDE_DIR}/libdeflate.h" Deflate_H REGEX "^#define LIBDEFLATE_VERSION_STRING\s+\"[^\"]*\"$")
+
+ string(REGEX REPLACE "^.*Deflate_VERSION \"([0-9]+).*$" "\\1" Deflate_MAJOR_VERSION "${Deflate_H}")
+ string(REGEX REPLACE "^.*Deflate_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" Deflate_MINOR_VERSION "${Deflate_H}")
+ set(Deflate_VERSION_STRING "${Deflate_MAJOR_VERSION}.${Deflate_MINOR_VERSION}")
+
+ set(Deflate_MAJOR_VERSION "${Deflate_VERSION_MAJOR}")
+ set(Deflate_MINOR_VERSION "${Deflate_VERSION_MINOR}")
+endif()
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Deflate
+ REQUIRED_VARS Deflate_LIBRARY Deflate_INCLUDE_DIR
+ VERSION_VAR Deflate_VERSION_STRING)
+
+if(Deflate_FOUND)
+ set(Deflate_INCLUDE_DIRS ${Deflate_INCLUDE_DIR})
+
+ if(NOT Deflate_LIBRARIES)
+ set(Deflate_LIBRARIES ${Deflate_LIBRARY})
+ endif()
+
+ if(NOT TARGET Deflate::Deflate)
+ add_library(Deflate::Deflate UNKNOWN IMPORTED)
+ set_target_properties(Deflate::Deflate PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${Deflate_INCLUDE_DIRS}")
+
+ if(Deflate_LIBRARY_RELEASE)
+ set_property(TARGET Deflate::Deflate APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(Deflate::Deflate PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${Deflate_LIBRARY_RELEASE}")
+ endif()
+
+ if(Deflate_LIBRARY_DEBUG)
+ set_property(TARGET Deflate::Deflate APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(Deflate::Deflate PROPERTIES
+ IMPORTED_LOCATION_DEBUG "${Deflate_LIBRARY_DEBUG}")
+ endif()
+
+ if(NOT Deflate_LIBRARY_RELEASE AND NOT Deflate_LIBRARY_DEBUG)
+ set_target_properties(Deflate::Deflate PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${Deflate_LIBRARY}")
+ endif()
+ endif()
+endif()
diff --git a/tiff/cmake/FindJBIG.cmake b/tiff/cmake/FindJBIG.cmake
new file mode 100644
index 00000000..f0c232c3
--- /dev/null
+++ b/tiff/cmake/FindJBIG.cmake
@@ -0,0 +1,116 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindJBIG
+--------
+
+Find the native JBIG includes and library.
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``JBIG::JBIG``, if
+JBIG has been found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module defines the following variables:
+
+::
+
+ JBIG_INCLUDE_DIRS - where to find jbig.h, etc.
+ JBIG_LIBRARIES - List of libraries when using jbig.
+ JBIG_FOUND - True if jbig found.
+
+::
+
+ JBIG_VERSION_STRING - The version of jbig found (x.y.z)
+ JBIG_VERSION_MAJOR - The major version of jbig
+ JBIG_VERSION_MINOR - The minor version of jbig
+
+ Debug and Release variants are found separately.
+#]=======================================================================]
+
+# Standard names to search for
+set(JBIG_NAMES jbig)
+set(JBIG_NAMES_DEBUG jbigd)
+
+find_path(JBIG_INCLUDE_DIR
+ NAMES jbig.h
+ PATH_SUFFIXES include)
+
+set(JBIG_OLD_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
+# Library has a "lib" prefix even on Windows.
+set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "")
+
+# Allow JBIG_LIBRARY to be set manually, as the location of the jbig library
+if(NOT JBIG_LIBRARY)
+ find_library(JBIG_LIBRARY_RELEASE
+ NAMES ${JBIG_NAMES}
+ PATH_SUFFIXES lib)
+ find_library(JBIG_LIBRARY_DEBUG
+ NAMES ${JBIG_NAMES_DEBUG}
+ PATH_SUFFIXES lib)
+
+ include(SelectLibraryConfigurations)
+ select_library_configurations(JBIG)
+endif()
+
+set(CMAKE_FIND_LIBRARY_PREFIXES "${JBIG_OLD_FIND_LIBRARY_PREFIXES}")
+
+unset(JBIG_NAMES)
+unset(JBIG_NAMES_DEBUG)
+unset(JBIG_OLD_FIND_LIBRARY_PREFIXES)
+
+mark_as_advanced(JBIG_INCLUDE_DIR)
+
+if(JBIG_INCLUDE_DIR AND EXISTS "${JBIG_INCLUDE_DIR}/jbig.h")
+ file(STRINGS "${JBIG_INCLUDE_DIR}/jbig.h" JBIG_H REGEX "^#define JBG_VERSION *\"[^\"]*\"$")
+
+ string(REGEX REPLACE "^.*JBG_VERSION *\"([0-9]+).*$" "\\1" JBIG_MAJOR_VERSION "${JBIG_H}")
+ string(REGEX REPLACE "^.*JBG_VERSION *\"[0-9]+\\.([0-9]+).*$" "\\1" JBIG_MINOR_VERSION "${JBIG_H}")
+ set(JBIG_VERSION_STRING "${JBIG_MAJOR_VERSION}.${JBIG_MINOR_VERSION}")
+
+ set(JBIG_MAJOR_VERSION "${JBIG_VERSION_MAJOR}")
+ set(JBIG_MINOR_VERSION "${JBIG_VERSION_MINOR}")
+endif()
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(JBIG
+ REQUIRED_VARS JBIG_LIBRARY JBIG_INCLUDE_DIR
+ VERSION_VAR JBIG_VERSION_STRING)
+
+if(JBIG_FOUND)
+ set(JBIG_INCLUDE_DIRS ${JBIG_INCLUDE_DIR})
+
+ if(NOT JBIG_LIBRARIES)
+ set(JBIG_LIBRARIES ${JBIG_LIBRARY})
+ endif()
+
+ if(NOT TARGET JBIG::JBIG)
+ add_library(JBIG::JBIG UNKNOWN IMPORTED)
+ set_target_properties(JBIG::JBIG PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${JBIG_INCLUDE_DIRS}")
+
+ if(JBIG_LIBRARY_RELEASE)
+ set_property(TARGET JBIG::JBIG APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(JBIG::JBIG PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${JBIG_LIBRARY_RELEASE}")
+ endif()
+
+ if(JBIG_LIBRARY_DEBUG)
+ set_property(TARGET JBIG::JBIG APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(JBIG::JBIG PROPERTIES
+ IMPORTED_LOCATION_DEBUG "${JBIG_LIBRARY_DEBUG}")
+ endif()
+
+ if(NOT JBIG_LIBRARY_RELEASE AND NOT JBIG_LIBRARY_DEBUG)
+ set_target_properties(JBIG::JBIG PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${JBIG_LIBRARY}")
+ endif()
+ endif()
+endif()
diff --git a/tiff/cmake/FindJPEG.cmake b/tiff/cmake/FindJPEG.cmake
new file mode 100644
index 00000000..12d0844b
--- /dev/null
+++ b/tiff/cmake/FindJPEG.cmake
@@ -0,0 +1,142 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindJPEG
+--------
+
+Find the Joint Photographic Experts Group (JPEG) library (``libjpeg``)
+
+Imported targets
+^^^^^^^^^^^^^^^^
+
+.. versionadded:: 3.12
+
+This module defines the following :prop_tgt:`IMPORTED` targets:
+
+``JPEG::JPEG``
+ The JPEG library, if found.
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``JPEG_FOUND``
+ If false, do not try to use JPEG.
+``JPEG_INCLUDE_DIRS``
+ where to find jpeglib.h, etc.
+``JPEG_LIBRARIES``
+ the libraries needed to use JPEG.
+``JPEG_VERSION``
+ .. versionadded:: 3.12
+ the version of the JPEG library found
+
+Cache variables
+^^^^^^^^^^^^^^^
+
+The following cache variables may also be set:
+
+``JPEG_INCLUDE_DIRS``
+ where to find jpeglib.h, etc.
+``JPEG_LIBRARY_RELEASE``
+ where to find the JPEG library (optimized).
+``JPEG_LIBRARY_DEBUG``
+ where to find the JPEG library (debug).
+
+.. versionadded:: 3.12
+ Debug and Release variand are found separately.
+
+Obsolete variables
+^^^^^^^^^^^^^^^^^^
+
+``JPEG_INCLUDE_DIR``
+ where to find jpeglib.h, etc. (same as JPEG_INCLUDE_DIRS)
+``JPEG_LIBRARY``
+ where to find the JPEG library.
+#]=======================================================================]
+
+find_path(JPEG_INCLUDE_DIR jpeglib.h)
+
+set(jpeg_names ${JPEG_NAMES} jpeg jpeg-static libjpeg libjpeg-static turbojpeg turbojpeg-static)
+foreach(name ${jpeg_names})
+ list(APPEND jpeg_names_debug "${name}d")
+endforeach()
+
+if(NOT JPEG_LIBRARY)
+ find_library(JPEG_LIBRARY_RELEASE NAMES ${jpeg_names} NAMES_PER_DIR)
+ find_library(JPEG_LIBRARY_DEBUG NAMES ${jpeg_names_debug} NAMES_PER_DIR)
+ include(SelectLibraryConfigurations)
+ select_library_configurations(JPEG)
+ mark_as_advanced(JPEG_LIBRARY_RELEASE JPEG_LIBRARY_DEBUG)
+endif()
+unset(jpeg_names)
+unset(jpeg_names_debug)
+
+if(JPEG_INCLUDE_DIR)
+ file(GLOB _JPEG_CONFIG_HEADERS_FEDORA "${JPEG_INCLUDE_DIR}/jconfig*.h")
+ file(GLOB _JPEG_CONFIG_HEADERS_DEBIAN "${JPEG_INCLUDE_DIR}/*/jconfig.h")
+ set(_JPEG_CONFIG_HEADERS
+ "${JPEG_INCLUDE_DIR}/jpeglib.h"
+ ${_JPEG_CONFIG_HEADERS_FEDORA}
+ ${_JPEG_CONFIG_HEADERS_DEBIAN})
+ foreach (_JPEG_CONFIG_HEADER IN LISTS _JPEG_CONFIG_HEADERS)
+ if (NOT EXISTS "${_JPEG_CONFIG_HEADER}")
+ continue ()
+ endif ()
+ file(STRINGS "${_JPEG_CONFIG_HEADER}"
+ jpeg_lib_version REGEX "^#define[\t ]+JPEG_LIB_VERSION[\t ]+.*")
+
+ if (NOT jpeg_lib_version)
+ continue ()
+ endif ()
+
+ string(REGEX REPLACE "^#define[\t ]+JPEG_LIB_VERSION[\t ]+([0-9]+).*"
+ "\\1" JPEG_VERSION "${jpeg_lib_version}")
+ break ()
+ endforeach ()
+ unset(jpeg_lib_version)
+ unset(_JPEG_CONFIG_HEADER)
+ unset(_JPEG_CONFIG_HEADERS)
+ unset(_JPEG_CONFIG_HEADERS_FEDORA)
+ unset(_JPEG_CONFIG_HEADERS_DEBIAN)
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(JPEG
+ REQUIRED_VARS JPEG_LIBRARY JPEG_INCLUDE_DIR
+ VERSION_VAR JPEG_VERSION)
+
+if(JPEG_FOUND)
+ set(JPEG_LIBRARIES ${JPEG_LIBRARY})
+ set(JPEG_INCLUDE_DIRS "${JPEG_INCLUDE_DIR}")
+
+ if(NOT TARGET JPEG::JPEG)
+ add_library(JPEG::JPEG UNKNOWN IMPORTED)
+ if(JPEG_INCLUDE_DIRS)
+ set_target_properties(JPEG::JPEG PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${JPEG_INCLUDE_DIRS}")
+ endif()
+ if(EXISTS "${JPEG_LIBRARY}")
+ set_target_properties(JPEG::JPEG PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${JPEG_LIBRARY}")
+ endif()
+ if(EXISTS "${JPEG_LIBRARY_RELEASE}")
+ set_property(TARGET JPEG::JPEG APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(JPEG::JPEG PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
+ IMPORTED_LOCATION_RELEASE "${JPEG_LIBRARY_RELEASE}")
+ endif()
+ if(EXISTS "${JPEG_LIBRARY_DEBUG}")
+ set_property(TARGET JPEG::JPEG APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(JPEG::JPEG PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
+ IMPORTED_LOCATION_DEBUG "${JPEG_LIBRARY_DEBUG}")
+ endif()
+ endif()
+endif()
+
+mark_as_advanced(JPEG_LIBRARY JPEG_INCLUDE_DIR)
diff --git a/tiff/cmake/FindLERC.cmake b/tiff/cmake/FindLERC.cmake
new file mode 100644
index 00000000..ade742a1
--- /dev/null
+++ b/tiff/cmake/FindLERC.cmake
@@ -0,0 +1,86 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindLerc
+--------
+
+Find the native Lerc includes and library.
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``LERC::LERC``, if
+CMath has been found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module defines the following variables:
+
+::
+
+ LERC_INCLUDE_DIRS - where to find Lerc_c_api.h, etc.
+ LERC_LIBRARIES - List of libraries when using LERC.
+ LERC_FOUND - True if LERC found.
+
+#]=======================================================================]
+
+# Standard names to search for
+set(LERC_NAMES LercLib Lerc)
+
+find_path(LERC_INCLUDE_DIR
+ NAMES Lerc_c_api.h
+ PATH_SUFFIXES include)
+
+# Allow LERC_LIBRARY to be set manually, as the location of the deflate library
+if(NOT LERC_LIBRARY)
+ find_library(LERC_LIBRARY_RELEASE
+ NAMES ${LERC_NAMES}
+ PATH_SUFFIXES lib)
+
+ include(SelectLibraryConfigurations)
+ select_library_configurations(LERC)
+endif()
+
+unset(LERC_NAMES)
+
+mark_as_advanced(LERC_INCLUDE_DIR)
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LERC
+ REQUIRED_VARS LERC_LIBRARY LERC_INCLUDE_DIR
+ VERSION_VAR LERC_VERSION_STRING)
+
+if(LERC_FOUND)
+ set(LERC_INCLUDE_DIRS ${LERC_INCLUDE_DIR})
+
+ if(NOT LERC_LIBRARIES)
+ set(LERC_LIBRARIES ${LERC_LIBRARY})
+ endif()
+
+ if(NOT TARGET LERC::LERC)
+ add_library(LERC::LERC UNKNOWN IMPORTED)
+ set_target_properties(LERC::LERC PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${LERC_INCLUDE_DIRS}")
+
+ if(LERC_LIBRARY_RELEASE)
+ set_property(TARGET LERC::LERC APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(LERC::LERC PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${LERC_LIBRARY_RELEASE}")
+ endif()
+
+ if(LERC_LIBRARY_DEBUG)
+ set_property(TARGET LERC::LERC APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(LERC::LERC PROPERTIES
+ IMPORTED_LOCATION_DEBUG "${LERC_LIBRARY_DEBUG}")
+ endif()
+
+ if(NOT LERC_LIBRARY_RELEASE AND NOT LERC_LIBRARY_DEBUG)
+ set_target_properties(LERC::LERC PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${LERC_LIBRARY}")
+ endif()
+ endif()
+endif()
diff --git a/tiff/cmake/FindLibLZMA.cmake b/tiff/cmake/FindLibLZMA.cmake
new file mode 100644
index 00000000..3042bac9
--- /dev/null
+++ b/tiff/cmake/FindLibLZMA.cmake
@@ -0,0 +1,126 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindLibLZMA
+-----------
+
+Find LZMA compression algorithm headers and library.
+
+
+Imported Targets
+^^^^^^^^^^^^^^^^
+
+.. versionadded:: 3.14
+
+This module defines :prop_tgt:`IMPORTED` target ``LibLZMA::LibLZMA``, if
+liblzma has been found.
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+This module will set the following variables in your project:
+
+``LIBLZMA_FOUND``
+ True if liblzma headers and library were found.
+``LIBLZMA_INCLUDE_DIRS``
+ Directory where liblzma headers are located.
+``LIBLZMA_LIBRARIES``
+ Lzma libraries to link against.
+``LIBLZMA_HAS_AUTO_DECODER``
+ True if lzma_auto_decoder() is found (required).
+``LIBLZMA_HAS_EASY_ENCODER``
+ True if lzma_easy_encoder() is found (required).
+``LIBLZMA_HAS_LZMA_PRESET``
+ True if lzma_lzma_preset() is found (required).
+``LIBLZMA_VERSION_MAJOR``
+ The major version of lzma
+``LIBLZMA_VERSION_MINOR``
+ The minor version of lzma
+``LIBLZMA_VERSION_PATCH``
+ The patch version of lzma
+``LIBLZMA_VERSION_STRING``
+ version number as a string (ex: "5.0.3")
+#]=======================================================================]
+
+find_path(LIBLZMA_INCLUDE_DIR lzma.h )
+if(NOT LIBLZMA_LIBRARY)
+ find_library(LIBLZMA_LIBRARY_RELEASE NAMES lzma liblzma NAMES_PER_DIR PATH_SUFFIXES lib)
+ find_library(LIBLZMA_LIBRARY_DEBUG NAMES lzmad liblzmad NAMES_PER_DIR PATH_SUFFIXES lib)
+ include(SelectLibraryConfigurations)
+ select_library_configurations(LIBLZMA)
+else()
+ file(TO_CMAKE_PATH "${LIBLZMA_LIBRARY}" LIBLZMA_LIBRARY)
+endif()
+
+if(LIBLZMA_INCLUDE_DIR AND EXISTS "${LIBLZMA_INCLUDE_DIR}/lzma/version.h")
+ file(STRINGS "${LIBLZMA_INCLUDE_DIR}/lzma/version.h" LIBLZMA_HEADER_CONTENTS REGEX "#define LZMA_VERSION_[A-Z]+ [0-9]+")
+
+ string(REGEX REPLACE ".*#define LZMA_VERSION_MAJOR ([0-9]+).*" "\\1" LIBLZMA_VERSION_MAJOR "${LIBLZMA_HEADER_CONTENTS}")
+ string(REGEX REPLACE ".*#define LZMA_VERSION_MINOR ([0-9]+).*" "\\1" LIBLZMA_VERSION_MINOR "${LIBLZMA_HEADER_CONTENTS}")
+ string(REGEX REPLACE ".*#define LZMA_VERSION_PATCH ([0-9]+).*" "\\1" LIBLZMA_VERSION_PATCH "${LIBLZMA_HEADER_CONTENTS}")
+
+ set(LIBLZMA_VERSION_STRING "${LIBLZMA_VERSION_MAJOR}.${LIBLZMA_VERSION_MINOR}.${LIBLZMA_VERSION_PATCH}")
+ unset(LIBLZMA_HEADER_CONTENTS)
+endif()
+
+# We're using new code known now as XZ, even library still been called LZMA
+# it can be found in http://tukaani.org/xz/
+# Avoid using old codebase
+if (LIBLZMA_LIBRARY)
+ include(CheckLibraryExists)
+ set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
+ set(CMAKE_REQUIRED_QUIET ${LibLZMA_FIND_QUIETLY})
+ if(NOT LIBLZMA_LIBRARY_RELEASE AND NOT LIBLZMA_LIBRARY_DEBUG)
+ set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY})
+ elseif(LIBLZMA_LIBRARY_RELEASE)
+ set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY_RELEASE})
+ elseif(LIBLZMA_LIBRARY_DEBUG)
+ set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY_DEBUG})
+ endif()
+ CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY_check} lzma_auto_decoder "" LIBLZMA_HAS_AUTO_DECODER)
+ CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY_check} lzma_easy_encoder "" LIBLZMA_HAS_EASY_ENCODER)
+ CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY_check} lzma_lzma_preset "" LIBLZMA_HAS_LZMA_PRESET)
+ unset(LIBLZMA_LIBRARY_check)
+ set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
+endif ()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(LibLZMA REQUIRED_VARS LIBLZMA_LIBRARY
+ LIBLZMA_INCLUDE_DIR
+ LIBLZMA_HAS_AUTO_DECODER
+ LIBLZMA_HAS_EASY_ENCODER
+ LIBLZMA_HAS_LZMA_PRESET
+ VERSION_VAR LIBLZMA_VERSION_STRING
+ )
+mark_as_advanced( LIBLZMA_INCLUDE_DIR LIBLZMA_LIBRARY )
+
+if (LIBLZMA_FOUND)
+ set(LIBLZMA_LIBRARIES ${LIBLZMA_LIBRARY})
+ set(LIBLZMA_INCLUDE_DIRS ${LIBLZMA_INCLUDE_DIR})
+ if(NOT TARGET LibLZMA::LibLZMA)
+ add_library(LibLZMA::LibLZMA UNKNOWN IMPORTED)
+ set_target_properties(LibLZMA::LibLZMA PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES ${LIBLZMA_INCLUDE_DIR}
+ IMPORTED_LINK_INTERFACE_LANGUAGES C)
+
+ if(LIBLZMA_LIBRARY_RELEASE)
+ set_property(TARGET LibLZMA::LibLZMA APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(LibLZMA::LibLZMA PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${LIBLZMA_LIBRARY_RELEASE}")
+ endif()
+
+ if(LIBLZMA_LIBRARY_DEBUG)
+ set_property(TARGET LibLZMA::LibLZMA APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(LibLZMA::LibLZMA PROPERTIES
+ IMPORTED_LOCATION_DEBUG "${LIBLZMA_LIBRARY_DEBUG}")
+ endif()
+
+ if(NOT LIBLZMA_LIBRARY_RELEASE AND NOT LIBLZMA_LIBRARY_DEBUG)
+ set_target_properties(LibLZMA::LibLZMA PROPERTIES
+ IMPORTED_LOCATION "${LIBLZMA_LIBRARY}")
+ endif()
+ endif()
+endif ()
diff --git a/tiff/cmake/FindWebP.cmake b/tiff/cmake/FindWebP.cmake
new file mode 100644
index 00000000..770fd979
--- /dev/null
+++ b/tiff/cmake/FindWebP.cmake
@@ -0,0 +1,91 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindWebP
+--------
+
+Find the native WebP includes and library.
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``WebP::WebP``, if
+WebP has been found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module defines the following variables:
+
+::
+
+ WebP_INCLUDE_DIRS - where to find webp/*.h, etc.
+ WebP_LIBRARIES - List of libraries when using webp.
+ WebP_FOUND - True if webp found.
+
+ Debug and Release variants are found separately.
+#]=======================================================================]
+
+# Standard names to search for
+set(WebP_NAMES webp)
+set(WebP_NAMES_DEBUG webpd)
+
+find_path(WebP_INCLUDE_DIR
+ NAMES webp/decode.h
+ PATH_SUFFIXES include)
+
+# Allow WebP_LIBRARY to be set manually, as the location of the webp library
+if(NOT WebP_LIBRARY)
+ find_library(WebP_LIBRARY_RELEASE
+ NAMES ${WebP_NAMES}
+ PATH_SUFFIXES lib)
+ find_library(WebP_LIBRARY_DEBUG
+ NAMES ${WebP_NAMES_DEBUG}
+ PATH_SUFFIXES lib)
+
+ include(SelectLibraryConfigurations)
+ select_library_configurations(WebP)
+endif()
+
+unset(WebP_NAMES)
+unset(WebP_NAMES_DEBUG)
+
+mark_as_advanced(WebP_INCLUDE_DIR)
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(WebP
+ REQUIRED_VARS WebP_LIBRARY WebP_INCLUDE_DIR)
+
+if(WebP_FOUND)
+ set(WebP_INCLUDE_DIRS ${WebP_INCLUDE_DIR})
+
+ if(NOT WebP_LIBRARIES)
+ set(WebP_LIBRARIES ${WebP_LIBRARY})
+ endif()
+
+ if(NOT TARGET WebP::WebP)
+ add_library(WebP::WebP UNKNOWN IMPORTED)
+ set_target_properties(WebP::WebP PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIRS}")
+
+ if(WebP_LIBRARY_RELEASE)
+ set_property(TARGET WebP::WebP APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(WebP::WebP PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${WebP_LIBRARY_RELEASE}")
+ endif()
+
+ if(WebP_LIBRARY_DEBUG)
+ set_property(TARGET WebP::WebP APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(WebP::WebP PROPERTIES
+ IMPORTED_LOCATION_DEBUG "${WebP_LIBRARY_DEBUG}")
+ endif()
+
+ if(NOT WebP_LIBRARY_RELEASE AND NOT WebP_LIBRARY_DEBUG)
+ set_target_properties(WebP::WebP PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${WebP_LIBRARY}")
+ endif()
+ endif()
+endif()
diff --git a/tiff/cmake/FindZSTD.cmake b/tiff/cmake/FindZSTD.cmake
new file mode 100644
index 00000000..a4066300
--- /dev/null
+++ b/tiff/cmake/FindZSTD.cmake
@@ -0,0 +1,107 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindZSTD
+--------
+
+Find the native ZSTD includes and library.
+
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``ZSTD::ZSTD``, if
+ZSTD has been found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+This module defines the following variables:
+
+::
+
+ ZSTD_INCLUDE_DIRS - where to find zstd.h, etc.
+ ZSTD_LIBRARIES - List of libraries when using zstd.
+ ZSTD_FOUND - True if zstd found.
+
+::
+
+ ZSTD_VERSION_STRING - The version of zstd found (x.y.z)
+ ZSTD_VERSION_MAJOR - The major version of zstd
+ ZSTD_VERSION_MINOR - The minor version of zstd
+
+ Debug and Release variants are found separately.
+#]=======================================================================]
+
+# Standard names to search for
+set(ZSTD_NAMES zstd zstd_static)
+set(ZSTD_NAMES_DEBUG zstdd zstd_staticd)
+
+find_path(ZSTD_INCLUDE_DIR
+ NAMES zstd.h
+ PATH_SUFFIXES include)
+
+# Allow ZSTD_LIBRARY to be set manually, as the location of the zstd library
+if(NOT ZSTD_LIBRARY)
+ find_library(ZSTD_LIBRARY_RELEASE
+ NAMES ${ZSTD_NAMES}
+ PATH_SUFFIXES lib)
+ find_library(ZSTD_LIBRARY_DEBUG
+ NAMES ${ZSTD_NAMES_DEBUG}
+ PATH_SUFFIXES lib)
+
+ include(SelectLibraryConfigurations)
+ select_library_configurations(ZSTD)
+endif()
+
+unset(ZSTD_NAMES)
+unset(ZSTD_NAMES_DEBUG)
+
+mark_as_advanced(ZSTD_INCLUDE_DIR)
+
+if(ZSTD_INCLUDE_DIR AND EXISTS "${ZSTD_INCLUDE_DIR}/zstd.h")
+ file(STRINGS "${ZSTD_INCLUDE_DIR}/zstd.h" ZSTD_H REGEX "^#define ZSTD_VERSION_.*$")
+
+ string(REGEX REPLACE "^.*ZSTD_VERSION_MAJOR *([0-9]+).*$" "\\1" ZSTD_MAJOR_VERSION "${ZSTD_H}")
+ string(REGEX REPLACE "^.*ZSTD_VERSION_MINOR *([0-9]+).*$" "\\1" ZSTD_MINOR_VERSION "${ZSTD_H}")
+ string(REGEX REPLACE "^.*ZSTD_VERSION_RELEASE *([0-9]+).*$" "\\1" ZSTD_PATCH_VERSION "${ZSTD_H}")
+ set(ZSTD_VERSION_STRING "${ZSTD_MAJOR_VERSION}.${ZSTD_MINOR_VERSION}.${ZSTD_PATCH_VERSION}")
+endif()
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZSTD
+ REQUIRED_VARS ZSTD_LIBRARY ZSTD_INCLUDE_DIR
+ VERSION_VAR ZSTD_VERSION_STRING)
+
+if(ZSTD_FOUND)
+ set(ZSTD_INCLUDE_DIRS ${ZSTD_INCLUDE_DIR})
+
+ if(NOT ZSTD_LIBRARIES)
+ set(ZSTD_LIBRARIES ${ZSTD_LIBRARY})
+ endif()
+
+ if(NOT TARGET ZSTD::ZSTD)
+ add_library(ZSTD::ZSTD UNKNOWN IMPORTED)
+ set_target_properties(ZSTD::ZSTD PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${ZSTD_INCLUDE_DIRS}")
+
+ if(ZSTD_LIBRARY_RELEASE)
+ set_property(TARGET ZSTD::ZSTD APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(ZSTD::ZSTD PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${ZSTD_LIBRARY_RELEASE}")
+ endif()
+
+ if(ZSTD_LIBRARY_DEBUG)
+ set_property(TARGET ZSTD::ZSTD APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(ZSTD::ZSTD PROPERTIES
+ IMPORTED_LOCATION_DEBUG "${ZSTD_LIBRARY_DEBUG}")
+ endif()
+
+ if(NOT ZSTD_LIBRARY_RELEASE AND NOT ZSTD_LIBRARY_DEBUG)
+ set_target_properties(ZSTD::ZSTD PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${ZSTD_LIBRARY}")
+ endif()
+ endif()
+endif()
diff --git a/tiff/cmake/IncludeChecks.cmake b/tiff/cmake/IncludeChecks.cmake
new file mode 100644
index 00000000..08873598
--- /dev/null
+++ b/tiff/cmake/IncludeChecks.cmake
@@ -0,0 +1,36 @@
+# Checks for headers
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+
+include(CheckIncludeFile)
+
+
+check_include_file(assert.h HAVE_ASSERT_H)
+check_include_file(fcntl.h HAVE_FCNTL_H)
+check_include_file(io.h HAVE_IO_H)
+check_include_file(strings.h HAVE_STRINGS_H)
+check_include_file(sys/time.h HAVE_SYS_TIME_H)
+check_include_file(sys/types.h HAVE_SYS_TYPES_H)
+check_include_file(unistd.h HAVE_UNISTD_H)
diff --git a/tiff/cmake/InternalCodecs.cmake b/tiff/cmake/InternalCodecs.cmake
new file mode 100644
index 00000000..97526e1e
--- /dev/null
+++ b/tiff/cmake/InternalCodecs.cmake
@@ -0,0 +1,46 @@
+# Options to enable and disable internal codecs
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+
+option(ccitt "support for CCITT Group 3 & 4 algorithms" ON)
+set(CCITT_SUPPORT ${ccitt})
+
+option(packbits "support for Macintosh PackBits algorithm" ON)
+set(PACKBITS_SUPPORT ${packbits})
+
+option(lzw "support for LZW algorithm" ON)
+set(LZW_SUPPORT ${lzw})
+
+option(thunder "support for ThunderScan 4-bit RLE algorithm" ON)
+set(THUNDER_SUPPORT ${thunder})
+
+option(next "support for NeXT 2-bit RLE algorithm" ON)
+set(NEXT_SUPPORT ${next})
+
+option(logluv "support for LogLuv high dynamic range algorithm" ON)
+set(LOGLUV_SUPPORT ${logluv})
+
+option(mdi "support for Microsoft Document Imaging" ON)
+set(MDI_SUPPORT ${mdi})
diff --git a/tiff/cmake/JBIGCodec.cmake b/tiff/cmake/JBIGCodec.cmake
new file mode 100644
index 00000000..a4350028
--- /dev/null
+++ b/tiff/cmake/JBIGCodec.cmake
@@ -0,0 +1,47 @@
+# Checks for JBIG codec support
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+
+# JBIG-KIT
+set(JBIG_SUPPORT FALSE)
+
+find_package(JBIG)
+
+if(JBIG_FOUND)
+ set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
+ set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${JBIG_INCLUDE_DIRS})
+ set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
+ set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${JBIG_LIBRARIES})
+ check_symbol_exists(jbg_newlen "jbig.h" HAVE_JBG_NEWLEN)
+ set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
+ set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
+endif()
+
+option(jbig "use ISO JBIG compression (requires JBIT-KIT library)" ${JBIG_FOUND})
+
+if (jbig AND JBIG_FOUND)
+ set(JBIG_SUPPORT TRUE)
+endif()
+
diff --git a/tiff/cmake/JPEGCodec.cmake b/tiff/cmake/JPEGCodec.cmake
new file mode 100644
index 00000000..5b295851
--- /dev/null
+++ b/tiff/cmake/JPEGCodec.cmake
@@ -0,0 +1,56 @@
+# Checks for JPEG codec support
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+
+# JPEG
+set(JPEG_SUPPORT FALSE)
+find_package(JPEG)
+option(jpeg "use libjpeg (required for JPEG compression)" ${JPEG_FOUND})
+if (jpeg AND JPEG_FOUND)
+ set(JPEG_SUPPORT TRUE)
+endif()
+
+# Old-jpeg
+set(OJPEG_SUPPORT FALSE)
+option(old-jpeg "support for Old JPEG compression (read-only)" ${JPEG_SUPPORT})
+if (old-jpeg AND JPEG_SUPPORT)
+ set(OJPEG_SUPPORT TRUE)
+endif()
+
+# 8/12-bit jpeg mode
+set(JPEG12_INCLUDE_DIR JPEG12_INCLUDE_DIR-NOTFOUND CACHE PATH "Include directory for 12-bit libjpeg")
+set(JPEG12_LIBRARY JPEG12_LIBRARY-NOTFOUND CACHE FILEPATH "12-bit libjpeg library")
+set(JPEG_DUAL_MODE_8_12 FALSE)
+if (JPEG12_INCLUDE_DIR AND JPEG12_LIBRARY)
+ set(JPEG12_LIBRARIES ${JPEG12_LIBRARY})
+ set(JPEG12_FOUND TRUE)
+else()
+ set(JPEG12_FOUND FALSE)
+endif()
+option(jpeg12 "enable libjpeg 8/12-bit dual mode (requires separate 12-bit libjpeg build)" ${JPEG12_FOUND})
+if (jpeg12 AND JPEG12_FOUND)
+ set(JPEG_DUAL_MODE_8_12 TRUE)
+ set(LIBJPEG_12_PATH "${JPEG12_INCLUDE_DIR}/jpeglib.h")
+endif()
diff --git a/tiff/cmake/LERCCodec.cmake b/tiff/cmake/LERCCodec.cmake
new file mode 100644
index 00000000..7344bfa5
--- /dev/null
+++ b/tiff/cmake/LERCCodec.cmake
@@ -0,0 +1,32 @@
+# Checks for LERC codec support
+#
+# Copyright © 2021 Antonio Valentino <antonio.valentino@tiscali.it>
+# Written by Antonio Valentino <antonio.valentino@tiscali.it>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+
+# libLerc
+set(LERC_SUPPORT FALSE)
+find_package(LERC)
+option(lerc "use libLerc (required for LERC compression)" ${LERC_FOUND})
+if (lerc AND LERC_FOUND)
+ set(LERC_SUPPORT TRUE)
+endif()
diff --git a/tiff/cmake/LZMACodec.cmake b/tiff/cmake/LZMACodec.cmake
new file mode 100644
index 00000000..06b14c1e
--- /dev/null
+++ b/tiff/cmake/LZMACodec.cmake
@@ -0,0 +1,33 @@
+# Checks for LZMA codec support
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+
+# liblzma2
+set(LZMA_SUPPORT FALSE)
+find_package(LibLZMA)
+option(lzma "use liblzma (required for LZMA2 compression)" ${LZMA_FOUND})
+if (lzma AND LIBLZMA_FOUND)
+ set(LZMA_SUPPORT TRUE)
+endif()
diff --git a/tiff/cmake/LargeFileSupport.cmake b/tiff/cmake/LargeFileSupport.cmake
new file mode 100644
index 00000000..f1819b97
--- /dev/null
+++ b/tiff/cmake/LargeFileSupport.cmake
@@ -0,0 +1,32 @@
+# Large file support
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+
+if (UNIX OR MINGW)
+ # This might not catch every possibility catered for by
+ # Autoconf AC_SYS_LARGEFILE.
+ add_definitions(-D_FILE_OFFSET_BITS=64)
+ set(FILE_OFFSET_BITS 64)
+endif()
diff --git a/tiff/cmake/LibraryFeatures.cmake b/tiff/cmake/LibraryFeatures.cmake
new file mode 100644
index 00000000..929ed241
--- /dev/null
+++ b/tiff/cmake/LibraryFeatures.cmake
@@ -0,0 +1,60 @@
+# C library features
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+# Strip chopping
+option(strip-chopping "strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of specified size to reduce memory usage)" ON)
+set(TIFF_DEFAULT_STRIP_SIZE 8192 CACHE STRING "default size of the strip in bytes (when strip chopping is enabled)")
+
+set(STRIPCHOP_DEFAULT)
+if(strip-chopping)
+ set(STRIPCHOP_DEFAULT TRUE)
+ if(TIFF_DEFAULT_STRIP_SIZE)
+ set(STRIP_SIZE_DEFAULT "${TIFF_DEFAULT_STRIP_SIZE}")
+ endif()
+endif()
+
+# Defer loading of strip/tile offsets
+option(defer-strile-load "enable deferred strip/tile offset/size loading (also available at runtime with the 'D' flag of TIFFOpen())" OFF)
+set(DEFER_STRILE_LOAD ${defer-strile-load})
+
+# CHUNKY_STRIP_READ_SUPPORT
+option(chunky-strip-read "enable reading large strips in chunks for TIFFReadScanline() (experimental)" OFF)
+set(CHUNKY_STRIP_READ_SUPPORT ${chunky-strip-read})
+
+# SUBIFD support
+set(SUBIFD_SUPPORT 1)
+
+# Default handling of ASSOCALPHA support.
+option(extrasample-as-alpha "the RGBA interface will treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many packages produce RGBA files but don't mark the alpha properly" ON)
+if(extrasample-as-alpha)
+ set(DEFAULT_EXTRASAMPLE_AS_ALPHA 1)
+endif()
+
+# Default handling of YCbCr subsampling support.
+# See Bug 168 in Bugzilla, and JPEGFixupTestSubsampling() for details.
+option(check-ycbcr-subsampling "enable picking up YCbCr subsampling info from the JPEG data stream to support files lacking the tag" ON)
+if (check-ycbcr-subsampling)
+ set(CHECK_JPEG_YCBCR_SUBSAMPLING 1)
+endif()
diff --git a/tiff/cmake/LinkerChecks.cmake b/tiff/cmake/LinkerChecks.cmake
new file mode 100644
index 00000000..ad1f0f9f
--- /dev/null
+++ b/tiff/cmake/LinkerChecks.cmake
@@ -0,0 +1,50 @@
+# Check linker capabilities
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+
+include(CheckCSourceCompiles)
+
+
+option(ld-version-script "Enable linker version script" ON)
+
+# Check if LD supports linker scripts.
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 {
+ global: sym;
+};
+
+VERS_2 {
+ global: sym;
+} VERS_1;
+")
+set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
+set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
+check_c_source_compiles("int main(void){return 0;}" HAVE_LD_VERSION_SCRIPT)
+set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
+file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
+if (ld-version-script AND HAVE_LD_VERSION_SCRIPT)
+ set(HAVE_LD_VERSION_SCRIPT TRUE)
+else()
+ set(HAVE_LD_VERSION_SCRIPT FALSE)
+endif()
diff --git a/tiff/cmake/OpenGLChecks.cmake b/tiff/cmake/OpenGLChecks.cmake
new file mode 100644
index 00000000..8d4142aa
--- /dev/null
+++ b/tiff/cmake/OpenGLChecks.cmake
@@ -0,0 +1,43 @@
+# Checks for OpenGL and GLUT support
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+# OpenGL and GLUT
+set(OpenGL_GL_PREFERENCE LEGACY)
+
+find_package(OpenGL COMPONENTS OpenGL)
+find_package(GLUT)
+
+set(HAVE_OPENGL FALSE)
+if(OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND)
+ set(HAVE_OPENGL TRUE)
+endif()
+
+# Purely to satisfy the generated headers:
+check_include_file(GL/gl.h HAVE_GL_GL_H)
+check_include_file(GL/glu.h HAVE_GL_GLU_H)
+check_include_file(GL/glut.h HAVE_GL_GLUT_H)
+check_include_file(GLUT/glut.h HAVE_GLUT_GLUT_H)
+check_include_file(OpenGL/gl.h HAVE_OPENGL_GL_H)
+check_include_file(OpenGL/glu.h HAVE_OPENGL_GLU_H)
diff --git a/tiff/cmake/PixarLogCodec.cmake b/tiff/cmake/PixarLogCodec.cmake
new file mode 100644
index 00000000..db363050
--- /dev/null
+++ b/tiff/cmake/PixarLogCodec.cmake
@@ -0,0 +1,33 @@
+# Checks for PixarLog codec support
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+
+# Option for Pixar log-format algorithm
+# Pixar log format
+set(PIXARLOG_SUPPORT FALSE)
+option(pixarlog "support for Pixar log-format algorithm (requires Zlib)" ${ZLIB_SUPPORT})
+if(pixarlog AND ZLIB_SUPPORT)
+ set(PIXARLOG_SUPPORT TRUE)
+endif()
diff --git a/tiff/cmake/PkgConfig.cmake b/tiff/cmake/PkgConfig.cmake
new file mode 100644
index 00000000..92674bd7
--- /dev/null
+++ b/tiff/cmake/PkgConfig.cmake
@@ -0,0 +1,36 @@
+# pkg-config support
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+# Generate pkg-config file
+set(prefix "${CMAKE_INSTALL_PREFIX}")
+set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
+set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
+set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libtiff-4.pc.in
+ ${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc)
+
+# Install pkg-config file
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc
+ DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig")
diff --git a/tiff/cmake/ProcessorChecks.cmake b/tiff/cmake/ProcessorChecks.cmake
new file mode 100644
index 00000000..8d8c568a
--- /dev/null
+++ b/tiff/cmake/ProcessorChecks.cmake
@@ -0,0 +1,47 @@
+# Processor capability checks
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+
+include(TestBigEndian)
+
+
+# CPU bit order
+set(HOST_FILLORDER FILLORDER_MSB2LSB)
+if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i.*86.*" OR
+ CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64.*" OR
+ # AMD64 on Windows
+ CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "AMD64" OR
+ CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64.*")
+ set(HOST_FILLORDER FILLORDER_LSB2MSB)
+endif()
+
+# CPU endianness
+test_big_endian(HOST_BIG_ENDIAN)
+if(HOST_BIG_ENDIAN)
+ add_definitions(-DWORDS_BIGENDIAN)
+endif()
+
+# IEEE floating point
+set(HAVE_IEEEFP 1)
diff --git a/tiff/cmake/Release.cmake b/tiff/cmake/Release.cmake
new file mode 100644
index 00000000..fbf34cc6
--- /dev/null
+++ b/tiff/cmake/Release.cmake
@@ -0,0 +1,31 @@
+# Release support
+#
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+
+add_custom_target(release
+ COMMAND ${CMAKE_COMMAND}
+ "-DSOURCE_DIR:PATH=${PROJECT_SOURCE_DIR}"
+ "-DLIBTIFF_VERSION=${PROJECT_VERSION}"
+ -P "${CMAKE_CURRENT_LIST_DIR}/ReleaseScript.cmake"
+ COMMENT "Releasing ${PROJECT_NAME} ${PROJECT_VERSION}")
diff --git a/tiff/cmake/ReleaseScript.cmake b/tiff/cmake/ReleaseScript.cmake
new file mode 100644
index 00000000..31cdbfe3
--- /dev/null
+++ b/tiff/cmake/ReleaseScript.cmake
@@ -0,0 +1,32 @@
+# Release support
+#
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+string(TIMESTAMP LIBTIFF_RELEASE_DATE "%Y%m%d")
+
+message(STATUS "Setting release version to ${LIBTIFF_VERSION}")
+message(STATUS "Setting release date to ${LIBTIFF_RELEASE_DATE}")
+
+configure_file("${SOURCE_DIR}/libtiff/tiffvers.h.cmake.in"
+ "${SOURCE_DIR}/libtiff/tiffvers.h"
+ @ONLY)
diff --git a/tiff/cmake/SymbolChecks.cmake b/tiff/cmake/SymbolChecks.cmake
new file mode 100644
index 00000000..210748ed
--- /dev/null
+++ b/tiff/cmake/SymbolChecks.cmake
@@ -0,0 +1,43 @@
+# Checks for symbols
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+
+include(CheckSymbolExists)
+
+
+# Check for getopt
+check_symbol_exists(getopt "unistd.h;stdio.h" HAVE_GETOPT)
+check_symbol_exists(optarg "getopt.h" HAVE_DECL_OPTARG)
+if (HAVE_DECL_OPTARG)
+ set(HAVE_DECL_OPTARG 1)
+else()
+ set(HAVE_DECL_OPTARG 0)
+endif()
+
+# Check for mmap
+check_symbol_exists(mmap "sys/mman.h" HAVE_MMAP)
+
+# Check for setmode
+check_symbol_exists(setmode "unistd.h" HAVE_SETMODE)
diff --git a/tiff/cmake/TypeSizeChecks.cmake b/tiff/cmake/TypeSizeChecks.cmake
new file mode 100644
index 00000000..29f23b41
--- /dev/null
+++ b/tiff/cmake/TypeSizeChecks.cmake
@@ -0,0 +1,52 @@
+# Check type sizes
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+
+set(CMAKE_EXTRA_INCLUDE_FILES_SAVE ${CMAKE_EXTRA_INCLUDE_FILES})
+set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} "stddef.h")
+check_type_size("size_t" SIZEOF_SIZE_T)
+set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES_SAVE})
+
+# C99 fixed-size integer types
+set(TIFF_INT8_T "int8_t")
+set(TIFF_UINT8_T "uint8_t")
+
+set(TIFF_INT16_T "int16_t")
+set(TIFF_UINT16_T "uint16_t")
+
+set(TIFF_INT32_T "int32_t")
+set(TIFF_UINT32_T "uint32_t")
+
+set(TIFF_INT64_T "int64_t")
+set(TIFF_UINT64_T "uint64_t")
+
+# size_t and TIFF signed size-type
+if(SIZEOF_SIZE_T EQUAL 4)
+ set(TIFF_SSIZE_T "int32_t")
+elseif(SIZEOF_SIZE_T EQUAL 8)
+ set(TIFF_SSIZE_T "int64_t")
+else()
+ message(FATAL_ERROR "Unsupported size_t size ${SIZEOF_SIZE_T}; please add support")
+endif()
diff --git a/tiff/cmake/WebPCodec.cmake b/tiff/cmake/WebPCodec.cmake
new file mode 100644
index 00000000..1d676a78
--- /dev/null
+++ b/tiff/cmake/WebPCodec.cmake
@@ -0,0 +1,35 @@
+# Checks for WebP codec support
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+# libwebp
+set(WEBP_SUPPORT FALSE)
+
+find_package(WebP)
+
+option(webp "use libwebp (required for WEBP compression)" ${WebP_FOUND})
+
+if (webp AND WebP_FOUND)
+ set(WEBP_SUPPORT TRUE)
+endif()
diff --git a/tiff/cmake/WindowsSupport.cmake b/tiff/cmake/WindowsSupport.cmake
new file mode 100644
index 00000000..93c13094
--- /dev/null
+++ b/tiff/cmake/WindowsSupport.cmake
@@ -0,0 +1,39 @@
+# Windows support
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+# Debug postfix
+if(MSVC)
+ set(CMAKE_DEBUG_POSTFIX "d")
+endif()
+
+# Win32 file I/O
+set(win32_io_default OFF)
+if(WIN32)
+ set(win32_io_default ON)
+endif()
+
+option(win32-io "Use Win32 I/O" ${win32_io_default})
+
+set(USE_WIN32_FILEIO ${win32-io})
diff --git a/tiff/cmake/ZSTDCodec.cmake b/tiff/cmake/ZSTDCodec.cmake
new file mode 100644
index 00000000..d3d2de80
--- /dev/null
+++ b/tiff/cmake/ZSTDCodec.cmake
@@ -0,0 +1,53 @@
+# Checks for LZMA codec support
+#
+# Copyright © 2015 Open Microscopy Environment / University of Dundee
+# Copyright © 2021 Roger Leigh <rleigh@codelibre.net>
+# Written by Roger Leigh <rleigh@codelibre.net>
+#
+# Permission to use, copy, modify, distribute, and sell this software and
+# its documentation for any purpose is hereby granted without fee, provided
+# that (i) the above copyright notices and this permission notice appear in
+# all copies of the software and related documentation, and (ii) the names of
+# Sam Leffler and Silicon Graphics may not be used in any advertising or
+# publicity relating to the software without the specific, prior written
+# permission of Sam Leffler and Silicon Graphics.
+#
+# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+#
+# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+# OF THIS SOFTWARE.
+
+
+# libzstd
+set(ZSTD_SUPPORT FALSE)
+set(ZSTD_USABLE FALSE)
+
+find_package(ZSTD)
+
+if(ZSTD_FOUND)
+ set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
+ set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ZSTD_INCLUDE_DIRS})
+ set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
+ set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ZSTD_LIBRARIES})
+ check_symbol_exists(ZSTD_decompressStream "zstd.h" ZSTD_RECENT_ENOUGH)
+ set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
+ set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
+
+ if (ZSTD_RECENT_ENOUGH)
+ set(ZSTD_USABLE TRUE)
+ else()
+ message(WARNING "Found ZSTD library, but not recent enough. Use zstd >= 1.0")
+ endif()
+endif()
+
+option(zstd "use libzstd (required for ZSTD compression)" ${ZSTD_USABLE})
+
+if (zstd AND ZSTD_USABLE)
+ set(ZSTD_SUPPORT TRUE)
+endif()