Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

thirdparty/libtiff: update to libtiff 4.6.0 #1540

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 16 additions & 112 deletions thirdparty/libtiff/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
cmake_minimum_required(VERSION 2.6)
set(CMAKE_C_STANDARD 99)
project(libtiff C)

string(REPLACE "-Wdeclaration-after-statement" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REPLACE "-Werror=declaration-after-statement" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REPLACE "-Wconversion" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string(REPLACE "-Wsign-conversion" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")

# This convenient copy of libtiff does not support encapsulated zlib or jpeg
# stream. see ZIP_SUPPORT and JPEG_SUPPORT values

Expand Down Expand Up @@ -27,6 +34,8 @@ set(TARGET_FILES
tif_fax3sm.c
tif_flush.c
tif_getimage.c
tif_hash_set.c
tif_hash_set.h
tif_jbig.c
tif_jpeg.c
tif_luv.c
Expand Down Expand Up @@ -66,8 +75,8 @@ endif()

include(${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
set(HOST_BIGENDIAN ${WORDS_BIGENDIAN})
if(HOST_BIGENDIAN)
set(HOST_BIG_ENDIAN ${WORDS_BIGENDIAN})
if(HOST_BIG_ENDIAN)
set(HOST_FILLORDER "FILLORDER_MSB2LSB")
else()
set(HOST_FILLORDER "FILLORDER_LSB2MSB")
Expand All @@ -76,6 +85,8 @@ include(CheckIncludeFiles)
include(CheckSymbolExists)
include(CheckFunctionExists)
include(CheckCSourceCompiles)
include(TypeSizeChecks.cmake)
include(LibraryFeatures.cmake)

CHECK_INCLUDE_FILES("zlib.h" HAVE_ZLIB_H)
CHECK_INCLUDE_FILES("jpeglib.h" HAVE_JPEGLIB_H)
Expand Down Expand Up @@ -115,18 +126,13 @@ CHECK_INCLUDE_FILES("ieeefp.h" HAVE_IEEEFP_H)
if( HAVE_TIME_H AND HAVE_SYS_TIME_H )
set(TIME_WITH_SYS_TIME 1)
endif()
set(LZW_SUPPORT 1)
set(LZMA_SUPPORT 0) # ?
set(MDI_SUPPORT 1) # ?
set(STDC_HEADERS 1) # why not ?
set(DEFAULT_EXTRASAMPLE_AS_ALPHA 1)
set(CHECK_JPEG_YCBCR_SUBSAMPLING 1)
set(CCITT_SUPPORT 1)
set(DEFER_STRILE_LOAD 0)
set(HAVE_JBG_NEWLEN 0) # FIXME: jbigkit stuff
set(STRIPCHOP_DEFAULT "TIFF_STRIPCHOP")
set(STRIP_SIZE_DEFAULT 8192)
set(SUBIFD_SUPPORT 1)
set(THUNDER_SUPPORT 1)
set(HAVE_IEEEFP 1)

CHECK_FUNCTION_EXISTS(getopt HAVE_GETOPT)
CHECK_FUNCTION_EXISTS(isascii HAVE_ISASCII)
Expand All @@ -141,97 +147,8 @@ CHECK_FUNCTION_EXISTS(strtol HAVE_STRTOL)
CHECK_FUNCTION_EXISTS(strtoul HAVE_STRTOUL)
CHECK_FUNCTION_EXISTS(strtoull HAVE_STRTOULL)

# May be inlined, so check it compiles:
check_c_source_compiles("
#include <stdio.h>
int main(void) {
char buf[10];
snprintf(buf, 10, \"Test %d\", 1);
return 0;
}" HAVE_SNPRINTF)

if(NOT HAVE_SNPRINTF)
set(TARGET_FILES ${TARGET_FILES} snprintf.c)
endif()

include(CheckTypeSize)

CHECK_TYPE_SIZE("signed int" SIZEOF_SIGNED_INT)
CHECK_TYPE_SIZE("signed long" SIZEOF_SIGNED_LONG)
CHECK_TYPE_SIZE("signed long long" SIZEOF_SIGNED_LONG_LONG)
CHECK_TYPE_SIZE("signed short" SIZEOF_SIGNED_SHORT)
CHECK_TYPE_SIZE("unsigned int" SIZEOF_UNSIGNED_INT)
CHECK_TYPE_SIZE("unsigned long" SIZEOF_UNSIGNED_LONG)
CHECK_TYPE_SIZE("unsigned long long" SIZEOF_UNSIGNED_LONG_LONG)
CHECK_TYPE_SIZE("unsigned short" SIZEOF_UNSIGNED_SHORT)
CHECK_TYPE_SIZE("unsigned char*" SIZEOF_UNSIGNED_CHAR_P)
# check platform has ssize_t:
CHECK_TYPE_SIZE(ssize_t SSIZE_T)

if(HAVE_STDINT_H)
set(TIFF_INT8_T int8_t)
set(TIFF_INT16_T int16_t)
set(TIFF_INT32_T int32_t)
set(TIFF_INT64_T int64_t)
set(TIFF_UINT8_T uint8_t)
set(TIFF_UINT16_T uint16_t)
set(TIFF_UINT32_T uint32_t)
set(TIFF_UINT64_T uint64_t)
set(TIFF_PTRDIFF_T ptrdiff_t)
if(NOT HAVE_SSIZE_T)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
set(TIFF_SSIZE_T int64_t)
set(TIFF_SSIZE_FORMAT "%lld")
set(TIFF_SIZE_FORMAT "%llu")
elseif("${CMAKE_SIZEOF_VOID_P}" EQUAL 4)
set(TIFF_SSIZE_T int32_t)
set(TIFF_SSIZE_FORMAT "%d")
set(TIFF_SIZE_FORMAT "%u")
else()
message(FATAL_ERROR "unknown ssize_t")
endif()
else()
set(TIFF_SSIZE_T ssize_t)
endif()
set(TIFF_INT32_FORMAT "%d")
set(TIFF_UINT32_FORMAT "%u")
set(TIFF_INT64_FORMAT "%lld")
set(TIFF_UINT64_FORMAT "%llu")
set(TIFF_PTRDIFF_FORMAT "%ld")
else()
set(TIFF_INT8_T "signed __int8")
set(TIFF_INT16_T "signed __int16")
set(TIFF_INT32_T "signed __int32")
set(TIFF_INT64_T "signed __int64")
set(TIFF_UINT8_T "unsigned __int8")
set(TIFF_UINT16_T "unsigned __int16")
set(TIFF_UINT32_T "unsigned __int32")
set(TIFF_UINT64_T "unsigned __int64")
set(TIFF_PTRDIFF_T ptrdiff_t)
if(NOT HAVE_SSIZE_T)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8)
set(TIFF_SSIZE_T "signed __int64")
set(TIFF_SSIZE_FORMAT "%lld")
set(TIFF_SIZE_FORMAT "%llu")
elseif("${CMAKE_SIZEOF_VOID_P}" EQUAL 4)
set(TIFF_SSIZE_T "signed __int32")
set(TIFF_SSIZE_FORMAT "%d")
set(TIFF_SIZE_FORMAT "%u")
else()
message(FATAL_ERROR "unknown ssize_t")
endif()
else()
set(TIFF_SSIZE_T ssize_t)
endif()
set(TIFF_INT32_FORMAT "%d")
set(TIFF_UINT32_FORMAT "%u")
set(TIFF_INT64_FORMAT "%lld")
set(TIFF_UINT64_FORMAT "%llu")
set(TIFF_PTRDIFF_FORMAT "%ld")
endif()

#
set(VERSION "\"4.0.6\"")
set(VERSION "\"4.6.0\"")
set(PACKAGE_VERSION ${VERSION})
set(PACKAGE "\"tiff\"")

Expand All @@ -249,19 +166,6 @@ CHECK_SYMBOL_EXISTS(pow "math.h" HAVE_POW)
CHECK_SYMBOL_EXISTS(lfind "search.h" HAVE_LFIND)
CHECK_SYMBOL_EXISTS(setmod "io.h" HAVE_SETMODE)

# http://www.cmake.org/pipermail/cmake/2007-September/016285.html
foreach(KEYWORD "inline" "__inline__" "__inline")
if(NOT DEFINED C_INLINE)
try_compile(C_HAS_${KEYWORD} "${CMAKE_CURRENT_BINARY_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/test_inline.c"
COMPILE_DEFINITIONS "-Dinline=${KEYWORD}")
if(C_HAS_${KEYWORD})
set(C_INLINE TRUE)
set(INLINE_KEYWORD "${KEYWORD}")
endif(C_HAS_${KEYWORD})
endif(NOT DEFINED C_INLINE)
endforeach(KEYWORD)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tiffconf.h.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/tiffconf.h @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tif_config.h.cmake.in
Expand Down
62 changes: 62 additions & 0 deletions thirdparty/libtiff/LibraryFeatures.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# C library features
#
# Copyright © 2015 Open Microscopy Environment / University of Dundee
# Copyright © 2021 Roger Leigh <[email protected]>
# Written by Roger Leigh <[email protected]>
#
# 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()

set(TIFF_MAX_DIR_COUNT 1048576 CACHE STRING "Maximum number of TIFF directories that libtiff can browse through")

# 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()
54 changes: 54 additions & 0 deletions thirdparty/libtiff/TypeSizeChecks.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Check type sizes
#
# Copyright © 2015 Open Microscopy Environment / University of Dundee
# Copyright © 2021 Roger Leigh <[email protected]>
# Written by Roger Leigh <[email protected]>
#
# 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("CheckTypeSize")

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()
38 changes: 0 additions & 38 deletions thirdparty/libtiff/snprintf.c

This file was deleted.

Loading