2015-06-24 22:27:58 -04:00
# CMake build for libtiff
# Run "cmake" to generate the build files for your platform
#
# Copyright © 2015 Open Microscopy Environment / University of Dundee
# 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.
2018-01-29 14:38:02 -05:00
cmake_minimum_required ( VERSION 2.8.11 ) # b/c of use of BUILD_INTERFACE generator expression
2015-06-24 22:27:58 -04:00
2015-09-01 11:38:01 -04:00
# Default policy is from 2.8.9
cmake_policy ( VERSION 2.8.9 )
2015-06-24 22:27:58 -04:00
# Set MacOSX @rpath usage globally.
if ( POLICY CMP0020 )
cmake_policy ( SET CMP0020 NEW )
endif ( POLICY CMP0020 )
if ( POLICY CMP0042 )
cmake_policy ( SET CMP0042 NEW )
endif ( POLICY CMP0042 )
# Use new variable expansion policy.
if ( POLICY CMP0053 )
cmake_policy ( SET CMP0053 NEW )
endif ( POLICY CMP0053 )
if ( POLICY CMP0054 )
cmake_policy ( SET CMP0054 NEW )
endif ( POLICY CMP0054 )
* CMakeLists.txt, libtiff/test/Makefile.am: Applied patches by
Roger Leigh (via tiff mailing list on 2015-08-31.
CMake reads all version information directly from configure.ac to
avoid duplication of values. This basically greps over the file
for the LIBTIFF_* variables, then translates them to the form
needed for cmake. This includes the release version and libtool
shared library version information.
Make shared/static library building configurable. Currently it
always builds shared libraries, with static libs having a _static
suffix (copying zlib, but it means it's got a non-standard name).
CMake has a -DBUILD_SHARED_LIBS=ON|OFF option to select one or the
other, which is now used instead. There's now a single "tiff"
target to build either shared or static as required, and all the
tests and tools are linked with this. Note: the Windows tests fail
when linked with a static libtiff (says: libtiff.dll not found).
Not really a regression since this was not tested up to this
point, and it's likely the unit tests haven't (ever?) been run on
Windows with a static libtiff, so there's some additional
portability issue here to address. Works fine on UNIX systems,
and fine on Windows with the default to build a DLL.
Add a missing file which wasn't being distributed, causing unit
tests to fail. Note that "find . -name '*.cmake'" lists all the
CMake files which need distributing in addition to all the
CMakeLists.txt files (which now are distributed).
2015-08-31 22:51:50 -04:00
# Read version information from configure.ac.
FILE ( READ "${CMAKE_CURRENT_SOURCE_DIR}/configure.ac" configure )
STRING ( REGEX REPLACE ";" "\\\\;" configure "${configure}" )
STRING ( REGEX REPLACE "\n" ";" configure "${configure}" )
foreach ( line ${ configure } )
foreach ( var LIBTIFF_MAJOR_VERSION LIBTIFF_MINOR_VERSION LIBTIFF_MICRO_VERSION LIBTIFF_ALPHA_VERSION
L I B T I F F _ C U R R E N T L I B T I F F _ R E V I S I O N L I B T I F F _ A G E )
if ( NOT ${ var } )
string ( REGEX MATCH "^${var}=(.*)" ${ var } _MATCH "${line}" )
if ( ${ var } _MATCH )
string ( REGEX REPLACE "^${var}=(.*)" "\\1" ${ var } "${line}" )
endif ( )
endif ( )
endforeach ( )
endforeach ( )
math ( EXPR SO_MAJOR "${LIBTIFF_CURRENT} - ${LIBTIFF_AGE}" )
set ( SO_MINOR "${LIBTIFF_AGE}" )
set ( SO_REVISION "${LIBTIFF_REVISION}" )
message ( STATUS "Building tiff version ${LIBTIFF_MAJOR_VERSION}.${LIBTIFF_MINOR_VERSION}.${LIBTIFF_MICRO_VERSION}${LIBTIFF_ALPHA_VERSION}" )
message ( STATUS "libtiff library version ${SO_MAJOR}.${SO_MINOR}.${SO_REVISION}" )
set ( BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries" )
2015-06-24 22:27:58 -04:00
# Project version
2015-09-01 11:38:01 -04:00
project ( tiff C )
set ( VERSION "${LIBTIFF_MAJOR_VERSION}.${LIBTIFF_MINOR_VERSION}.${LIBTIFF_MICRO_VERSION}" )
set ( tiff_VERSION "${VERSION}" )
set ( tiff_VERSION_MAJOR "${LIBTIFF_MAJOR_VERSION}" )
set ( tiff_VERSION_MINOR "${LIBTIFF_MINOR_VERSION}" )
set ( tiff_VERSION_PATCH "${LIBTIFF_MICRO_VERSION}" )
2015-06-24 22:27:58 -04:00
# the other tiff_VERSION_* variables are set automatically
* CMakeLists.txt, libtiff/test/Makefile.am: Applied patches by
Roger Leigh (via tiff mailing list on 2015-08-31.
CMake reads all version information directly from configure.ac to
avoid duplication of values. This basically greps over the file
for the LIBTIFF_* variables, then translates them to the form
needed for cmake. This includes the release version and libtool
shared library version information.
Make shared/static library building configurable. Currently it
always builds shared libraries, with static libs having a _static
suffix (copying zlib, but it means it's got a non-standard name).
CMake has a -DBUILD_SHARED_LIBS=ON|OFF option to select one or the
other, which is now used instead. There's now a single "tiff"
target to build either shared or static as required, and all the
tests and tools are linked with this. Note: the Windows tests fail
when linked with a static libtiff (says: libtiff.dll not found).
Not really a regression since this was not tested up to this
point, and it's likely the unit tests haven't (ever?) been run on
Windows with a static libtiff, so there's some additional
portability issue here to address. Works fine on UNIX systems,
and fine on Windows with the default to build a DLL.
Add a missing file which wasn't being distributed, causing unit
tests to fail. Note that "find . -name '*.cmake'" lists all the
CMake files which need distributing in addition to all the
CMakeLists.txt files (which now are distributed).
2015-08-31 22:51:50 -04:00
set ( tiff_VERSION_ALPHA "${LIBTIFF_ALPHA_VERSION}" )
2015-06-24 22:27:58 -04:00
# Library version (unlike libtool's baroque scheme, WYSIWYG here)
* CMakeLists.txt, libtiff/test/Makefile.am: Applied patches by
Roger Leigh (via tiff mailing list on 2015-08-31.
CMake reads all version information directly from configure.ac to
avoid duplication of values. This basically greps over the file
for the LIBTIFF_* variables, then translates them to the form
needed for cmake. This includes the release version and libtool
shared library version information.
Make shared/static library building configurable. Currently it
always builds shared libraries, with static libs having a _static
suffix (copying zlib, but it means it's got a non-standard name).
CMake has a -DBUILD_SHARED_LIBS=ON|OFF option to select one or the
other, which is now used instead. There's now a single "tiff"
target to build either shared or static as required, and all the
tests and tools are linked with this. Note: the Windows tests fail
when linked with a static libtiff (says: libtiff.dll not found).
Not really a regression since this was not tested up to this
point, and it's likely the unit tests haven't (ever?) been run on
Windows with a static libtiff, so there's some additional
portability issue here to address. Works fine on UNIX systems,
and fine on Windows with the default to build a DLL.
Add a missing file which wasn't being distributed, causing unit
tests to fail. Note that "find . -name '*.cmake'" lists all the
CMake files which need distributing in addition to all the
CMakeLists.txt files (which now are distributed).
2015-08-31 22:51:50 -04:00
set ( SO_COMPATVERSION "${SO_MAJOR}" )
set ( SO_VERSION "${SO_MAJOR}.${SO_MINOR}.${SO_REVISION}" )
2015-06-24 22:27:58 -04:00
# For autotools header compatibility
set ( PACKAGE_NAME "LibTIFF Software" )
set ( PACKAGE_TARNAME "${PROJECT_NAME}" )
set ( PACKAGE_VERSION "${PROJECT_VERSION}${tiff_VERSION_ALPHA}" )
set ( PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}" )
set ( PACKAGE_BUGREPORT "tiff@lists.maptools.org" )
include ( GNUInstallDirs )
2015-07-04 18:09:27 -04:00
include ( CheckCCompilerFlag )
2015-06-24 22:27:58 -04:00
include ( CheckCSourceCompiles )
include ( CheckIncludeFile )
include ( CheckTypeSize )
2017-12-28 17:23:45 -05:00
include ( CheckSymbolExists )
2015-06-24 22:27:58 -04:00
enable_testing ( )
macro ( current_date var )
if ( UNIX )
execute_process ( COMMAND "date" + "%Y%m%d" OUTPUT_VARIABLE ${ var } )
endif ( )
endmacro ( )
current_date ( RELEASE_DATE )
macro ( extra_dist )
foreach ( file ${ ARGV } )
file ( RELATIVE_PATH relfile "${PROJECT_SOURCE_DIR}"
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / $ { f i l e } " )
list ( APPEND EXTRA_DIST "${relfile}" )
endforeach ( )
set ( EXTRA_DIST "${EXTRA_DIST}" PARENT_SCOPE )
endmacro ( )
set ( EXTRA_DIST
H O W T O - R E L E A S E
M a k e f i l e . v c
S C o n s t r u c t
a u t o g e n . s h
c o n f i g u r e . c o m
n m a k e . o p t
l i b t i f f - 4 . p c . i n )
2015-07-04 18:09:27 -04:00
# 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
C M A K E _ C _ C O M P I L E R _ I D M A T C H E S " C l a n g " )
set ( test_flags
- W a l l
- W i n l i n e
- W
- W f o r m a t - s e c u r i t y
- W p o i n t e r - a r i t h
- W d i s a b l e d - o p t i m i z a t i o n
- W n o - u n k n o w n - p r a g m a s
- W d e c l a r a t i o n - a f t e r - s t a t e m e n t
- f s t r i c t - a l i a s i n g )
if ( extra-warnings )
list ( APPEND test_flags
- W f l o a t - e q u a l
- W m i s s i n g - p r o t o t y p e s
- W u n r e a c h a b l e - c o d e )
endif ( )
if ( fatal-warnings )
list ( APPEND test_flags
- W e r r o r )
endif ( )
elseif ( CMAKE_C_COMPILER_ID STREQUAL "MSVC" )
set ( test_flags )
if ( extra-warnings )
list ( APPEND test_flags
/ W 4 )
else ( )
list ( APPEND test_flags
/ W 3 )
endif ( )
if ( fatal-warnings )
list ( APPEND test_flags
/ W X )
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 } )
if ( MSVC )
set ( CMAKE_DEBUG_POSTFIX "d" )
endif ( )
2015-08-29 11:30:28 -04:00
option ( ld-version-script "Enable linker version script" ON )
2015-06-24 22:27:58 -04:00
# Check if LD supports linker scripts.
file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" " VERS_1 {
g l o b a l : s y m ;
} ;
V E R S _ 2 {
g l o b a l : s y m ;
} V E R S _ 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" )
2015-08-29 11:30:28 -04:00
if ( ld-version-script AND HAVE_LD_VERSION_SCRIPT )
2015-06-24 22:27:58 -04:00
set ( HAVE_LD_VERSION_SCRIPT TRUE )
else ( )
set ( HAVE_LD_VERSION_SCRIPT FALSE )
endif ( )
# Find libm, if available
find_library ( M_LIBRARY m )
check_include_file ( assert.h HAVE_ASSERT_H )
check_include_file ( dlfcn.h HAVE_DLFCN_H )
check_include_file ( fcntl.h HAVE_FCNTL_H )
check_include_file ( inttypes.h HAVE_INTTYPES_H )
check_include_file ( io.h HAVE_IO_H )
check_include_file ( search.h HAVE_SEARCH_H )
check_include_file ( stdint.h HAVE_STDINT_H )
check_include_file ( string.h HAVE_STRING_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 )
# Inspired from /usr/share/autoconf/autoconf/c.m4
foreach ( inline_keyword "inline" "__inline__" "__inline" )
if ( NOT DEFINED C_INLINE )
set ( CMAKE_REQUIRED_DEFINITIONS_SAVE ${ CMAKE_REQUIRED_DEFINITIONS } )
set ( CMAKE_REQUIRED_DEFINITIONS ${ CMAKE_REQUIRED_DEFINITIONS }
" - D i n l i n e = $ { i n l i n e _ k e y w o r d } " )
check_c_source_compiles ( "
t y p e d e f i n t f o o _ t ;
s t a t i c i n l i n e f o o _ t static_foo ( ) { r e t u r n 0 ; }
f o o _ t foo ( ) { r e t u r n 0 ; }
i n t main ( int argc, char *argv[] ) { r e t u r n 0 ; } "
C _ H A S _ $ { i n l i n e _ k e y w o r d } )
set ( CMAKE_REQUIRED_DEFINITIONS ${ CMAKE_REQUIRED_DEFINITIONS_SAVE } )
if ( C_HAS_ ${ inline_keyword } )
set ( C_INLINE TRUE )
set ( INLINE_KEYWORD "${inline_keyword}" )
endif ( )
endif ( )
endforeach ( )
if ( NOT DEFINED C_INLINE )
set ( INLINE_KEYWORD )
endif ( )
# off_t and size_t checks omitted; not clear they are used at all
# Are off_t and size_t checks strictly necessary?
# Check if sys/time.h and time.h allow use together
check_c_source_compiles ( "
#include <sys/time.h>
#include <time.h>
i n t main ( void ) { r e t u r n 0 ; } "
T I M E _ W I T H _ S Y S _ T I M E )
# Check if struct tm is in sys/time.h
check_c_source_compiles ( "
#include <sys/types.h>
#include <time.h>
i n t main ( void ) {
s t r u c t t m t m ;
i n t * p = & t m . t m _ s e c ;
r e t u r n ! p ;
} "
T M _ I N _ S Y S _ T I M E )
# Check type sizes
# NOTE: Could be replaced with C99 <stdint.h>
check_type_size ( "signed int" SIZEOF_SIGNED_INT )
check_type_size ( "unsigned int" SIZEOF_UNSIGNED_INT )
check_type_size ( "signed long" SIZEOF_SIGNED_LONG )
check_type_size ( "unsigned long" SIZEOF_UNSIGNED_LONG )
check_type_size ( "signed long long" SIZEOF_SIGNED_LONG_LONG )
check_type_size ( "unsigned long long" SIZEOF_UNSIGNED_LONG_LONG )
check_type_size ( "unsigned char *" SIZEOF_UNSIGNED_CHAR_P )
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 )
check_type_size ( "ptrdiff_t" SIZEOF_PTRDIFF_T )
set ( CMAKE_EXTRA_INCLUDE_FILES ${ CMAKE_EXTRA_INCLUDE_FILES_SAVE } )
macro ( report_values )
foreach ( val ${ ARGV } )
message ( STATUS "${val} set to ${${val}}" )
endforeach ( )
endmacro ( )
set ( TIFF_INT8_T "signed char" )
set ( TIFF_UINT8_T "unsigned char" )
set ( TIFF_INT16_T "signed short" )
set ( TIFF_UINT16_T "unsigned short" )
if ( SIZEOF_SIGNED_INT EQUAL 4 )
set ( TIFF_INT32_T "signed int" )
set ( TIFF_INT32_FORMAT "%d" )
elseif ( SIZEOF_SIGNED_LONG EQUAL 4 )
set ( TIFF_INT32_T "signed long" )
set ( TIFF_INT32_FORMAT "%ld" )
endif ( )
if ( SIZEOF_UNSIGNED_INT EQUAL 4 )
set ( TIFF_UINT32_T "unsigned int" )
set ( TIFF_UINT32_FORMAT "%u" )
elseif ( SIZEOF_UNSIGNED_LONG EQUAL 4 )
set ( TIFF_UINT32_T "unsigned long" )
set ( TIFF_UINT32_FORMAT "%lu" )
endif ( )
if ( SIZEOF_SIGNED_LONG EQUAL 8 )
set ( TIFF_INT64_T "signed long" )
set ( TIFF_INT64_FORMAT "%ld" )
elseif ( SIZEOF_SIGNED_LONG_LONG EQUAL 8 )
set ( TIFF_INT64_T "signed long long" )
if ( MINGW )
set ( TIFF_INT64_FORMAT "%I64d" )
else ( )
set ( TIFF_INT64_FORMAT "%lld" )
endif ( )
endif ( )
if ( SIZEOF_UNSIGNED_LONG EQUAL 8 )
set ( TIFF_UINT64_T "unsigned long" )
set ( TIFF_UINT64_FORMAT "%lu" )
elseif ( SIZEOF_UNSIGNED_LONG_LONG EQUAL 8 )
set ( TIFF_UINT64_T "unsigned long long" )
if ( MINGW )
set ( TIFF_UINT64_FORMAT "%I64u" )
else ( )
set ( TIFF_UINT64_FORMAT "%llu" )
endif ( )
endif ( )
if ( SIZEOF_UNSIGNED_INT EQUAL SIZEOF_SIZE_T )
set ( TIFF_SIZE_T "unsigned int" )
set ( TIFF_SIZE_FORMAT "%u" )
elseif ( SIZEOF_UNSIGNED_LONG EQUAL SIZEOF_SIZE_T )
set ( TIFF_SIZE_T "unsigned long" )
set ( TIFF_SIZE_FORMAT "%lu" )
elseif ( SIZEOF_UNSIGNED_LONG_LONG EQUAL SIZEOF_SIZE_T )
set ( TIFF_SIZE_T "unsigned long" )
if ( MINGW )
set ( TIFF_SIZE_FORMAT "%I64u" )
else ( )
set ( TIFF_SIZE_FORMAT "%llu" )
endif ( )
endif ( )
if ( SIZEOF_SIGNED_INT EQUAL SIZEOF_UNSIGNED_CHAR_P )
set ( TIFF_SSIZE_T "signed int" )
set ( TIFF_SSIZE_FORMAT "%d" )
elseif ( SIZEOF_SIGNED_LONG EQUAL SIZEOF_UNSIGNED_CHAR_P )
set ( TIFF_SSIZE_T "signed long" )
set ( TIFF_SSIZE_FORMAT "%ld" )
elseif ( SIZEOF_SIGNED_LONG_LONG EQUAL SIZEOF_UNSIGNED_CHAR_P )
set ( TIFF_SSIZE_T "signed long long" )
if ( MINGW )
set ( TIFF_SSIZE_FORMAT "%I64d" )
else ( )
set ( TIFF_SSIZE_FORMAT "%lld" )
endif ( )
endif ( )
if ( NOT SIZEOF_PTRDIFF_T )
set ( TIFF_PTRDIFF_T "${TIFF_SSIZE_T}" )
set ( TIFF_PTRDIFF_FORMAT "${SSIZE_FORMAT}" )
else ( )
set ( TIFF_PTRDIFF_T "ptrdiff_t" )
set ( TIFF_PTRDIFF_FORMAT "%ld" )
endif ( )
#report_values(TIFF_INT8_T TIFF_INT8_FORMAT
# TIFF_UINT8_T TIFF_UINT8_FORMAT
# TIFF_INT16_T TIFF_INT16_FORMAT
# TIFF_UINT16_T TIFF_UINT16_FORMAT
# TIFF_INT32_T TIFF_INT32_FORMAT
# TIFF_UINT32_T TIFF_UINT32_FORMAT
# TIFF_INT64_T TIFF_INT64_FORMAT
# TIFF_UINT64_T TIFF_UINT64_FORMAT
# TIFF_SSIZE_T TIFF_SSIZE_FORMAT
# TIFF_PTRDIFF_T TIFF_PTRDIFF_FORMAT)
2017-12-28 17:23:45 -05:00
check_symbol_exists ( mmap "sys/mman.h" HAVE_MMAP )
check_symbol_exists ( setmode "unistd.h" HAVE_SETMODE )
check_symbol_exists ( snprintf "stdio.h" HAVE_SNPRINTF )
check_symbol_exists ( strcasecmp "strings.h" HAVE_STRCASECMP )
check_symbol_exists ( strtol "stdlib.h" HAVE_STRTOUL )
check_symbol_exists ( getopt "unistd.h" HAVE_GETOPT )
check_symbol_exists ( lfind "search.h" HAVE_LFIND )
2015-06-24 22:27:58 -04:00
2015-08-20 21:59:33 -04:00
if ( NOT HAVE_SNPRINTF )
add_definitions ( -DNEED_LIBPORT )
endif ( )
2015-06-24 22:27:58 -04:00
# CPU bit order
2017-12-29 12:46:01 -05:00
set ( HOST_FILLORDER FILLORDER_MSB2LSB )
2015-06-24 22:27:58 -04:00
if ( CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i.*86.*" OR
C M A K E _ H O S T _ S Y S T E M _ P R O C E S S O R M A T C H E S " a m d 6 4 . * " O R
C M A K E _ H O S T _ S Y S T E M _ P R O C E S S O R M A T C H E S " x 8 6 _ 6 4 . * " )
2017-12-29 12:46:01 -05:00
set ( HOST_FILLORDER FILLORDER_LSB2MSB )
2015-06-24 22:27:58 -04:00
endif ( )
# CPU endianness
include ( TestBigEndian )
2017-12-29 12:46:16 -05:00
test_big_endian ( HOST_BIG_ENDIAN )
2015-06-24 22:27:58 -04:00
# IEEE floating point
2017-12-29 12:46:29 -05:00
set ( HAVE_IEEEFP 1 )
2015-06-24 22:27:58 -04:00
report_values ( CMAKE_HOST_SYSTEM_PROCESSOR HOST_FILLORDER
H O S T _ B I G _ E N D I A N H A V E _ I E E E F P )
# Large file support
2017-06-08 16:46:10 -04:00
if ( UNIX OR MINGW )
2015-06-24 22:27:58 -04:00
# This might not catch every possibility catered for by
# AC_SYS_LARGEFILE.
add_definitions ( -D_FILE_OFFSET_BITS=64 )
set ( FILE_OFFSET_BITS 64 )
endif ( )
# Documentation install directory (default to cmake project docdir)
set ( LIBTIFF_DOCDIR "${CMAKE_INSTALL_FULL_DOCDIR}" )
# Options to enable and disable internal codecs
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 for Microsoft Document Imaging
option ( mdi "support for Microsoft Document Imaging" ON )
set ( MDI_SUPPORT ${ mdi } )
# ZLIB
option ( zlib "use zlib (required for Deflate compression)" ON )
if ( zlib )
find_package ( ZLIB )
endif ( )
set ( ZLIB_SUPPORT 0 )
if ( ZLIB_FOUND )
set ( ZLIB_SUPPORT 1 )
endif ( )
set ( ZIP_SUPPORT ${ ZLIB_SUPPORT } )
# Option for Pixar log-format algorithm
# Pixar log format
option ( pixarlog "support for Pixar log-format algorithm (requires Zlib)" ON )
set ( PIXARLOG_SUPPORT FALSE )
if ( ZLIB_SUPPORT )
if ( pixarlog )
set ( PIXARLOG_SUPPORT TRUE )
endif ( )
endif ( )
# JPEG
option ( jpeg "use libjpeg (required for JPEG compression)" ON )
if ( jpeg )
find_package ( JPEG )
endif ( )
set ( JPEG_SUPPORT FALSE )
if ( JPEG_FOUND )
set ( JPEG_SUPPORT TRUE )
endif ( )
option ( old-jpeg "support for Old JPEG compression (read-only)" ON )
set ( OJPEG_SUPPORT FALSE )
if ( JPEG_SUPPORT )
if ( old-jpeg )
set ( OJPEG_SUPPORT TRUE )
endif ( )
endif ( )
# JBIG-KIT
option ( jbig "use ISO JBIG compression (requires JBIT-KIT library)" ON )
if ( jbig )
set ( JBIG_FOUND 0 )
find_path ( JBIG_INCLUDE_DIR jbig.h )
set ( JBIG_NAMES ${ JBIG_NAMES } jbig libjbig )
find_library ( JBIG_LIBRARY NAMES ${ JBIG_NAMES } )
if ( JBIG_INCLUDE_DIR AND JBIG_LIBRARY )
set ( JBIG_FOUND 1 )
set ( JBIG_LIBRARIES ${ JBIG_LIBRARY } )
endif ( )
endif ( )
set ( JBIG_SUPPORT 0 )
if ( JBIG_FOUND )
set ( JBIG_FOUND TRUE )
set ( JBIG_SUPPORT 1 )
else ( )
set ( JBIG_FOUND FALSE )
endif ( )
set ( CMAKE_REQUIRED_INCLUDES_SAVE ${ CMAKE_REQUIRED_INCLUDES } )
set ( CMAKE_REQUIRED_INCLUDES ${ CMAKE_REQUIRED_INCLUDES } ${ JBIG_INCLUDE_DIR } )
2017-12-28 17:23:45 -05:00
check_symbol_exists ( jbg_newlen "jbig.h" HAVE_JBG_NEWLEN )
2015-06-24 22:27:58 -04:00
set ( CMAKE_REQUIRED_INCLUDES ${ CMAKE_REQUIRED_INCLUDES_SAVE } )
# liblzma2
option ( lzma "use liblzma (required for LZMA2 compression)" ON )
if ( lzma )
find_package ( LibLZMA )
endif ( )
set ( LZMA_SUPPORT 0 )
if ( LIBLZMA_FOUND )
set ( LZMA_SUPPORT 1 )
endif ( )
Add ZSTD compression codec
From https://github.com/facebook/zstd
"Zstandard, or zstd as short version, is a fast lossless compression
algorithm, targeting real-time compression scenarios at zlib-level
and better compression ratios. It's backed by a very fast entropy stage,
provided by Huff0 and FSE library."
We require libzstd >= 1.0.0 so as to be able to use streaming compression
and decompression methods.
The default compression level we have selected is 9 (range goes from 1 to 22),
which experimentally offers equivalent or better compression ratio than
the default deflate/ZIP level of 6, and much faster compression.
For example on a 6600x4400 16bit image, tiffcp -c zip runs in 10.7 seconds,
while tiffcp -c zstd runs in 5.3 seconds. Decompression time for zip is
840 ms, and for zstd 650 ms. File size is 42735936 for zip, and
42586822 for zstd. Similar findings on other images.
On a 25894x16701 16bit image,
Compression time Decompression time File size
ZSTD 35 s 3.2 s 399 700 498
ZIP/Deflate 1m 20 s 4.9 s 419 622 336
2017-12-21 07:32:02 -05:00
# libzstd
option ( zstd "use libzstd (required for ZSTD compression)" ON )
if ( zstd )
find_path ( ZSTD_INCLUDE_DIR zstd.h )
find_library ( ZSTD_LIBRARY NAMES zstd )
if ( ZSTD_INCLUDE_DIR AND ZSTD_LIBRARY )
check_library_exists ( "${ZSTD_LIBRARY}" ZSTD_decompressStream "" ZSTD_RECENT_ENOUGH )
if ( ZSTD_RECENT_ENOUGH )
set ( ZSTD_FOUND TRUE )
set ( ZSTD_LIBRARIES ${ ZSTD_LIBRARY } )
message ( STATUS "Found ZSTD library: ${ZSTD_LIBRARY}" )
else ( )
message ( WARNING "Found ZSTD library, but not recent enough. Use zstd >= 1.0" )
endif ( )
endif ( )
endif ( )
set ( ZSTD_SUPPORT 0 )
if ( ZSTD_FOUND )
set ( ZSTD_SUPPORT 1 )
endif ( )
2015-06-24 22:27:58 -04:00
# 8/12-bit jpeg mode
option ( jpeg12 " enable libjpeg 8/12-bit dual mode ( requires separate
1 2 - b i t l i b j p e g b u i l d ) " O N )
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 ( JPEG12_FOUND FALSE )
if ( JPEG12_INCLUDE_DIR AND JPEG12_LIBRARY )
set ( JPEG12_LIBRARIES ${ JPEG12_LIBRARY } )
set ( JPEG12_FOUND TRUE )
endif ( )
if ( JPEG12_FOUND )
set ( JPEG_DUAL_MODE_8_12 1 )
set ( LIBJPEG_12_PATH "${JPEG12_INCLUDE_DIR}/jpeglib.h" )
endif ( )
# 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 ( )
# OpenGL and GLUT
find_package ( 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 )
# Win32 IO
set ( win32_io FALSE )
if ( WIN32 )
set ( win32_io TRUE )
endif ( )
2017-12-28 17:28:21 -05:00
set ( USE_WIN32_FILEIO ${ win32_io } )
2015-06-24 22:27:58 -04:00
# Orthogonal features
# 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 (experimental)" 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 ( )
# 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
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / l i b t i f f - 4 . p c )
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } /libtiff-4.pc
D E S T I N A T I O N " $ { C M A K E _ I N S T A L L _ F U L L _ L I B D I R } / p k g c o n f i g " )
# Includes used by libtiff (and tests)
if ( ZLIB_INCLUDE_DIRS )
list ( APPEND TIFF_INCLUDES ${ ZLIB_INCLUDE_DIRS } )
endif ( )
if ( JPEG_INCLUDE_DIR )
list ( APPEND TIFF_INCLUDES ${ JPEG_INCLUDE_DIR } )
endif ( )
if ( JPEG12_INCLUDE_DIR )
list ( APPEND TIFF_INCLUDES ${ JPEG12_INCLUDE_DIR } )
endif ( )
if ( JBIG_INCLUDE_DIR )
list ( APPEND TIFF_INCLUDES ${ JBIG_INCLUDE_DIR } )
endif ( )
if ( LIBLZMA_INCLUDE_DIRS )
list ( APPEND TIFF_INCLUDES ${ LIBLZMA_INCLUDE_DIRS } )
endif ( )
Add ZSTD compression codec
From https://github.com/facebook/zstd
"Zstandard, or zstd as short version, is a fast lossless compression
algorithm, targeting real-time compression scenarios at zlib-level
and better compression ratios. It's backed by a very fast entropy stage,
provided by Huff0 and FSE library."
We require libzstd >= 1.0.0 so as to be able to use streaming compression
and decompression methods.
The default compression level we have selected is 9 (range goes from 1 to 22),
which experimentally offers equivalent or better compression ratio than
the default deflate/ZIP level of 6, and much faster compression.
For example on a 6600x4400 16bit image, tiffcp -c zip runs in 10.7 seconds,
while tiffcp -c zstd runs in 5.3 seconds. Decompression time for zip is
840 ms, and for zstd 650 ms. File size is 42735936 for zip, and
42586822 for zstd. Similar findings on other images.
On a 25894x16701 16bit image,
Compression time Decompression time File size
ZSTD 35 s 3.2 s 399 700 498
ZIP/Deflate 1m 20 s 4.9 s 419 622 336
2017-12-21 07:32:02 -05:00
if ( ZSTD_INCLUDE_DIR )
list ( APPEND TIFF_INCLUDES ${ ZSTD_INCLUDE_DIR } )
endif ( )
2015-06-24 22:27:58 -04:00
# Libraries required by libtiff
set ( TIFF_LIBRARY_DEPS )
if ( M_LIBRARY )
list ( APPEND TIFF_LIBRARY_DEPS ${ M_LIBRARY } )
endif ( )
if ( ZLIB_LIBRARIES )
list ( APPEND TIFF_LIBRARY_DEPS ${ ZLIB_LIBRARIES } )
endif ( )
if ( JPEG_LIBRARIES )
list ( APPEND TIFF_LIBRARY_DEPS ${ JPEG_LIBRARIES } )
endif ( )
if ( JPEG12_LIBRARIES )
list ( APPEND TIFF_LIBRARY_DEPS ${ JPEG12_LIBRARIES } )
endif ( )
if ( JBIG_LIBRARIES )
list ( APPEND TIFF_LIBRARY_DEPS ${ JBIG_LIBRARIES } )
endif ( )
if ( LIBLZMA_LIBRARIES )
list ( APPEND TIFF_LIBRARY_DEPS ${ LIBLZMA_LIBRARIES } )
endif ( )
Add ZSTD compression codec
From https://github.com/facebook/zstd
"Zstandard, or zstd as short version, is a fast lossless compression
algorithm, targeting real-time compression scenarios at zlib-level
and better compression ratios. It's backed by a very fast entropy stage,
provided by Huff0 and FSE library."
We require libzstd >= 1.0.0 so as to be able to use streaming compression
and decompression methods.
The default compression level we have selected is 9 (range goes from 1 to 22),
which experimentally offers equivalent or better compression ratio than
the default deflate/ZIP level of 6, and much faster compression.
For example on a 6600x4400 16bit image, tiffcp -c zip runs in 10.7 seconds,
while tiffcp -c zstd runs in 5.3 seconds. Decompression time for zip is
840 ms, and for zstd 650 ms. File size is 42735936 for zip, and
42586822 for zstd. Similar findings on other images.
On a 25894x16701 16bit image,
Compression time Decompression time File size
ZSTD 35 s 3.2 s 399 700 498
ZIP/Deflate 1m 20 s 4.9 s 419 622 336
2017-12-21 07:32:02 -05:00
if ( ZSTD_LIBRARIES )
list ( APPEND TIFF_LIBRARY_DEPS ${ ZSTD_LIBRARIES } )
endif ( )
2015-06-24 22:27:58 -04:00
#report_values(TIFF_INCLUDES TIFF_LIBRARY_DEPS)
# Process subdirectories
add_subdirectory ( port )
add_subdirectory ( libtiff )
add_subdirectory ( tools )
add_subdirectory ( test )
add_subdirectory ( contrib )
add_subdirectory ( build )
add_subdirectory ( man )
add_subdirectory ( html )
#message(STATUS "EXTRA_DIST: ${EXTRA_DIST}")
message ( STATUS "" )
message ( STATUS "Libtiff is now configured for ${host}" )
message ( STATUS "" )
message ( STATUS " Installation directory: ${prefix}" )
message ( STATUS " Documentation directory: ${LIBTIFF_DOCDIR}" )
message ( STATUS " C compiler: ${CMAKE_C_COMPILER}" )
message ( STATUS " C++ compiler: ${CMAKE_CXX_COMPILER}" )
* CMakeLists.txt, libtiff/test/Makefile.am: Applied patches by
Roger Leigh (via tiff mailing list on 2015-08-31.
CMake reads all version information directly from configure.ac to
avoid duplication of values. This basically greps over the file
for the LIBTIFF_* variables, then translates them to the form
needed for cmake. This includes the release version and libtool
shared library version information.
Make shared/static library building configurable. Currently it
always builds shared libraries, with static libs having a _static
suffix (copying zlib, but it means it's got a non-standard name).
CMake has a -DBUILD_SHARED_LIBS=ON|OFF option to select one or the
other, which is now used instead. There's now a single "tiff"
target to build either shared or static as required, and all the
tests and tools are linked with this. Note: the Windows tests fail
when linked with a static libtiff (says: libtiff.dll not found).
Not really a regression since this was not tested up to this
point, and it's likely the unit tests haven't (ever?) been run on
Windows with a static libtiff, so there's some additional
portability issue here to address. Works fine on UNIX systems,
and fine on Windows with the default to build a DLL.
Add a missing file which wasn't being distributed, causing unit
tests to fail. Note that "find . -name '*.cmake'" lists all the
CMake files which need distributing in addition to all the
CMakeLists.txt files (which now are distributed).
2015-08-31 22:51:50 -04:00
message ( STATUS " Build shared libraries: ${BUILD_SHARED_LIBS}" )
2015-06-24 22:27:58 -04:00
message ( STATUS " Enable linker symbol versioning: ${HAVE_LD_VERSION_SCRIPT}" )
message ( STATUS " Support Microsoft Document Imaging: ${mdi}" )
message ( STATUS " Use win32 IO: ${USE_WIN32_FILEIO}" )
message ( STATUS "" )
message ( STATUS " Support for internal codecs:" )
message ( STATUS " CCITT Group 3 & 4 algorithms: ${ccitt}" )
message ( STATUS " Macintosh PackBits algorithm: ${packbits}" )
message ( STATUS " LZW algorithm: ${lzw}" )
message ( STATUS " ThunderScan 4-bit RLE algorithm: ${thunder}" )
message ( STATUS " NeXT 2-bit RLE algorithm: ${next}" )
message ( STATUS " LogLuv high dynamic range encoding: ${logluv}" )
message ( STATUS "" )
message ( STATUS " Support for external codecs:" )
message ( STATUS " ZLIB support: ${zlib} (requested) ${ZLIB_FOUND} (availability)" )
message ( STATUS " Pixar log-format algorithm: ${pixarlog} (requested) ${PIXARLOG_SUPPORT} (availability)" )
message ( STATUS " JPEG support: ${jpeg} (requested) ${JPEG_FOUND} (availability)" )
message ( STATUS " Old JPEG support: ${old-jpeg} (requested) ${JPEG_FOUND} (availability)" )
message ( STATUS " JPEG 8/12 bit dual mode: ${jpeg12} (requested) ${JPEG12_FOUND} (availability)" )
message ( STATUS " ISO JBIG support: ${jbig} (requested) ${JBIG_FOUND} (availability)" )
message ( STATUS " LZMA2 support: ${lzma} (requested) ${LIBLZMA_FOUND} (availability)" )
Add ZSTD compression codec
From https://github.com/facebook/zstd
"Zstandard, or zstd as short version, is a fast lossless compression
algorithm, targeting real-time compression scenarios at zlib-level
and better compression ratios. It's backed by a very fast entropy stage,
provided by Huff0 and FSE library."
We require libzstd >= 1.0.0 so as to be able to use streaming compression
and decompression methods.
The default compression level we have selected is 9 (range goes from 1 to 22),
which experimentally offers equivalent or better compression ratio than
the default deflate/ZIP level of 6, and much faster compression.
For example on a 6600x4400 16bit image, tiffcp -c zip runs in 10.7 seconds,
while tiffcp -c zstd runs in 5.3 seconds. Decompression time for zip is
840 ms, and for zstd 650 ms. File size is 42735936 for zip, and
42586822 for zstd. Similar findings on other images.
On a 25894x16701 16bit image,
Compression time Decompression time File size
ZSTD 35 s 3.2 s 399 700 498
ZIP/Deflate 1m 20 s 4.9 s 419 622 336
2017-12-21 07:32:02 -05:00
message ( STATUS " ZSTD support: ${zstd} (requested) ${ZSTD_FOUND} (availability)" )
2015-06-24 22:27:58 -04:00
message ( STATUS "" )
message ( STATUS " C++ support: ${cxx} (requested) ${CXX_SUPPORT} (availability)" )
message ( STATUS "" )
# message(STATUS " X Athena Widgets support: ${HAVE_XAW}")
message ( STATUS " OpenGL support: ${HAVE_OPENGL}" )
message ( STATUS "" )