1# CMake build for libtiff 2# Run "cmake" to generate the build files for your platform 3# 4# Copyright © 2015 Open Microscopy Environment / University of Dundee 5# Written by Roger Leigh <[email protected]> 6# 7# Permission to use, copy, modify, distribute, and sell this software and 8# its documentation for any purpose is hereby granted without fee, provided 9# that (i) the above copyright notices and this permission notice appear in 10# all copies of the software and related documentation, and (ii) the names of 11# Sam Leffler and Silicon Graphics may not be used in any advertising or 12# publicity relating to the software without the specific, prior written 13# permission of Sam Leffler and Silicon Graphics. 14# 15# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 16# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 17# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 18# 19# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR 20# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, 21# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 22# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 23# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 24# OF THIS SOFTWARE. 25 26cmake_minimum_required(VERSION 2.8.9) 27 28# Default policy is from 2.8.9 29cmake_policy(VERSION 2.8.9) 30# Set MacOSX @rpath usage globally. 31if (POLICY CMP0020) 32 cmake_policy(SET CMP0020 NEW) 33endif(POLICY CMP0020) 34if (POLICY CMP0042) 35 cmake_policy(SET CMP0042 NEW) 36endif(POLICY CMP0042) 37# Use new variable expansion policy. 38if (POLICY CMP0053) 39 cmake_policy(SET CMP0053 NEW) 40endif(POLICY CMP0053) 41if (POLICY CMP0054) 42 cmake_policy(SET CMP0054 NEW) 43endif(POLICY CMP0054) 44 45# Read version information from configure.ac. 46FILE(READ "${CMAKE_CURRENT_SOURCE_DIR}/configure.ac" configure) 47STRING(REGEX REPLACE ";" "\\\\;" configure "${configure}") 48STRING(REGEX REPLACE "\n" ";" configure "${configure}") 49foreach(line ${configure}) 50 foreach(var LIBTIFF_MAJOR_VERSION LIBTIFF_MINOR_VERSION LIBTIFF_MICRO_VERSION LIBTIFF_ALPHA_VERSION 51 LIBTIFF_CURRENT LIBTIFF_REVISION LIBTIFF_AGE) 52 if(NOT ${var}) 53 string(REGEX MATCH "^${var}=(.*)" ${var}_MATCH "${line}") 54 if(${var}_MATCH) 55 string(REGEX REPLACE "^${var}=(.*)" "\\1" ${var} "${line}") 56 endif() 57 endif() 58 endforeach() 59endforeach() 60 61math(EXPR SO_MAJOR "${LIBTIFF_CURRENT} - ${LIBTIFF_AGE}") 62set(SO_MINOR "${LIBTIFF_AGE}") 63set(SO_REVISION "${LIBTIFF_REVISION}") 64 65message(STATUS "Building tiff version ${LIBTIFF_MAJOR_VERSION}.${LIBTIFF_MINOR_VERSION}.${LIBTIFF_MICRO_VERSION}${LIBTIFF_ALPHA_VERSION}") 66message(STATUS "libtiff library version ${SO_MAJOR}.${SO_MINOR}.${SO_REVISION}") 67 68set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries") 69 70# Project version 71project(tiff C) 72set(VERSION "${LIBTIFF_MAJOR_VERSION}.${LIBTIFF_MINOR_VERSION}.${LIBTIFF_MICRO_VERSION}") 73set(tiff_VERSION "${VERSION}") 74set(tiff_VERSION_MAJOR "${LIBTIFF_MAJOR_VERSION}") 75set(tiff_VERSION_MINOR "${LIBTIFF_MINOR_VERSION}") 76set(tiff_VERSION_PATCH "${LIBTIFF_MICRO_VERSION}") 77 78# the other tiff_VERSION_* variables are set automatically 79set(tiff_VERSION_ALPHA "${LIBTIFF_ALPHA_VERSION}") 80# Library version (unlike libtool's baroque scheme, WYSIWYG here) 81set(SO_COMPATVERSION "${SO_MAJOR}") 82set(SO_VERSION "${SO_MAJOR}.${SO_MINOR}.${SO_REVISION}") 83 84# For autotools header compatibility 85set(PACKAGE_NAME "LibTIFF Software") 86set(PACKAGE_TARNAME "${PROJECT_NAME}") 87set(PACKAGE_VERSION "${PROJECT_VERSION}${tiff_VERSION_ALPHA}") 88set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") 89set(PACKAGE_BUGREPORT "[email protected]") 90 91include(GNUInstallDirs) 92include(CheckCCompilerFlag) 93include(CheckCSourceCompiles) 94include(CheckIncludeFile) 95include(CheckTypeSize) 96include(CheckFunctionExists) 97enable_testing() 98 99macro(current_date var) 100 if(UNIX) 101 execute_process(COMMAND "date" +"%Y%m%d" OUTPUT_VARIABLE ${var}) 102 endif() 103endmacro() 104 105current_date(RELEASE_DATE) 106 107macro(extra_dist) 108 foreach(file ${ARGV}) 109 file(RELATIVE_PATH relfile "${PROJECT_SOURCE_DIR}" 110 "${CMAKE_CURRENT_SOURCE_DIR}/${file}") 111 list(APPEND EXTRA_DIST "${relfile}") 112 endforeach() 113 set(EXTRA_DIST "${EXTRA_DIST}" PARENT_SCOPE) 114endmacro() 115 116set(EXTRA_DIST 117 HOWTO-RELEASE 118 Makefile.vc 119 SConstruct 120 autogen.sh 121 configure.com 122 nmake.opt 123 libtiff-4.pc.in) 124 125# These are annoyingly verbose, produce false positives or don't work 126# nicely with all supported compiler versions, so are disabled unless 127# explicitly enabled. 128option(extra-warnings "Enable extra compiler warnings" OFF) 129 130# This will cause the compiler to fail when an error occurs. 131option(fatal-warnings "Compiler warnings are errors" OFF) 132 133# Check if the compiler supports each of the following additional 134# flags, and enable them if supported. This greatly improves the 135# quality of the build by checking for a number of common problems, 136# some of which are quite serious. 137if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR 138 CMAKE_C_COMPILER_ID MATCHES "Clang") 139 set(test_flags 140 -Wall 141 -Winline 142 -W 143 -Wformat-security 144 -Wpointer-arith 145 -Wdisabled-optimization 146 -Wno-unknown-pragmas 147 -Wdeclaration-after-statement 148 -fstrict-aliasing) 149 if(extra-warnings) 150 list(APPEND test_flags 151 -Wfloat-equal 152 -Wmissing-prototypes 153 -Wunreachable-code) 154 endif() 155 if(fatal-warnings) 156 list(APPEND test_flags 157 -Werror) 158 endif() 159elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC") 160 set(test_flags) 161 if(extra-warnings) 162 list(APPEND test_flags 163 /W4) 164 else() 165 list(APPEND test_flags 166 /W3) 167 endif() 168 if (fatal-warnings) 169 list(APPEND test_flags 170 /WX) 171 endif() 172endif() 173 174foreach(flag ${test_flags}) 175 string(REGEX REPLACE "[^A-Za-z0-9]" "_" flag_var "${flag}") 176 set(test_c_flag "C_FLAG${flag_var}") 177 CHECK_C_COMPILER_FLAG(${flag} "${test_c_flag}") 178 if (${test_c_flag}) 179 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}") 180 endif (${test_c_flag}) 181endforeach(flag ${test_flags}) 182 183if(MSVC) 184 set(CMAKE_DEBUG_POSTFIX "d") 185endif() 186 187option(ld-version-script "Enable linker version script" ON) 188# Check if LD supports linker scripts. 189file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 { 190 global: sym; 191}; 192 193VERS_2 { 194 global: sym; 195} VERS_1; 196") 197set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) 198set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/conftest.map") 199check_c_source_compiles("int main(void){return 0;}" HAVE_LD_VERSION_SCRIPT) 200set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) 201file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map") 202if (ld-version-script AND HAVE_LD_VERSION_SCRIPT) 203 set(HAVE_LD_VERSION_SCRIPT TRUE) 204else() 205 set(HAVE_LD_VERSION_SCRIPT FALSE) 206endif() 207 208# Find libm, if available 209find_library(M_LIBRARY m) 210 211check_include_file(assert.h HAVE_ASSERT_H) 212check_include_file(dlfcn.h HAVE_DLFCN_H) 213check_include_file(fcntl.h HAVE_FCNTL_H) 214check_include_file(inttypes.h HAVE_INTTYPES_H) 215check_include_file(io.h HAVE_IO_H) 216check_include_file(limits.h HAVE_LIMITS_H) 217check_include_file(malloc.h HAVE_MALLOC_H) 218check_include_file(memory.h HAVE_MEMORY_H) 219check_include_file(search.h HAVE_SEARCH_H) 220check_include_file(stdint.h HAVE_STDINT_H) 221check_include_file(string.h HAVE_STRING_H) 222check_include_file(strings.h HAVE_STRINGS_H) 223check_include_file(sys/time.h HAVE_SYS_TIME_H) 224check_include_file(sys/types.h HAVE_SYS_TYPES_H) 225check_include_file(unistd.h HAVE_UNISTD_H) 226 227# Inspired from /usr/share/autoconf/autoconf/c.m4 228foreach(inline_keyword "inline" "__inline__" "__inline") 229 if(NOT DEFINED C_INLINE) 230 set(CMAKE_REQUIRED_DEFINITIONS_SAVE ${CMAKE_REQUIRED_DEFINITIONS}) 231 set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} 232 "-Dinline=${inline_keyword}") 233 check_c_source_compiles(" 234 typedef int foo_t; 235 static inline foo_t static_foo() {return 0;} 236 foo_t foo(){return 0;} 237 int main(int argc, char *argv[]) {return 0;}" 238 C_HAS_${inline_keyword}) 239 set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS_SAVE}) 240 if(C_HAS_${inline_keyword}) 241 set(C_INLINE TRUE) 242 set(INLINE_KEYWORD "${inline_keyword}") 243 endif() 244 endif() 245endforeach() 246if(NOT DEFINED C_INLINE) 247 set(INLINE_KEYWORD) 248endif() 249 250# off_t and size_t checks omitted; not clear they are used at all 251# Are off_t and size_t checks strictly necessary? 252 253# Check if sys/time.h and time.h allow use together 254check_c_source_compiles(" 255#include <sys/time.h> 256#include <time.h> 257int main(void){return 0;}" 258 TIME_WITH_SYS_TIME) 259 260# Check if struct tm is in sys/time.h 261check_c_source_compiles(" 262#include <sys/types.h> 263#include <time.h> 264 265int main(void){ 266 struct tm tm; 267 int *p = &tm.tm_sec; 268 return !p; 269}" 270 TM_IN_SYS_TIME) 271 272# Check type sizes 273# NOTE: Could be replaced with C99 <stdint.h> 274check_type_size("signed short" SIZEOF_SIGNED_SHORT) 275check_type_size("unsigned short" SIZEOF_UNSIGNED_SHORT) 276check_type_size("signed int" SIZEOF_SIGNED_INT) 277check_type_size("unsigned int" SIZEOF_UNSIGNED_INT) 278check_type_size("signed long" SIZEOF_SIGNED_LONG) 279check_type_size("unsigned long" SIZEOF_UNSIGNED_LONG) 280check_type_size("signed long long" SIZEOF_SIGNED_LONG_LONG) 281check_type_size("unsigned long long" SIZEOF_UNSIGNED_LONG_LONG) 282check_type_size("unsigned char *" SIZEOF_UNSIGNED_CHAR_P) 283 284set(CMAKE_EXTRA_INCLUDE_FILES_SAVE ${CMAKE_EXTRA_INCLUDE_FILES}) 285set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} "stddef.h") 286check_type_size("size_t" SIZEOF_SIZE_T) 287check_type_size("ptrdiff_t" SIZEOF_PTRDIFF_T) 288set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES_SAVE}) 289 290macro(report_values) 291 foreach(val ${ARGV}) 292 message(STATUS "${val} set to ${${val}}") 293 endforeach() 294endmacro() 295 296set(TIFF_INT8_T "signed char") 297set(TIFF_UINT8_T "unsigned char") 298 299set(TIFF_INT16_T "signed short") 300set(TIFF_UINT16_T "unsigned short") 301 302if(SIZEOF_SIGNED_INT EQUAL 4) 303 set(TIFF_INT32_T "signed int") 304 set(TIFF_INT32_FORMAT "%d") 305elseif(SIZEOF_SIGNED_LONG EQUAL 4) 306 set(TIFF_INT32_T "signed long") 307 set(TIFF_INT32_FORMAT "%ld") 308endif() 309 310if(SIZEOF_UNSIGNED_INT EQUAL 4) 311 set(TIFF_UINT32_T "unsigned int") 312 set(TIFF_UINT32_FORMAT "%u") 313elseif(SIZEOF_UNSIGNED_LONG EQUAL 4) 314 set(TIFF_UINT32_T "unsigned long") 315 set(TIFF_UINT32_FORMAT "%lu") 316endif() 317 318if(SIZEOF_SIGNED_LONG EQUAL 8) 319 set(TIFF_INT64_T "signed long") 320 set(TIFF_INT64_FORMAT "%ld") 321elseif(SIZEOF_SIGNED_LONG_LONG EQUAL 8) 322 set(TIFF_INT64_T "signed long long") 323 if (MINGW) 324 set(TIFF_INT64_FORMAT "%I64d") 325 else() 326 set(TIFF_INT64_FORMAT "%lld") 327 endif() 328endif() 329 330if(SIZEOF_UNSIGNED_LONG EQUAL 8) 331 set(TIFF_UINT64_T "unsigned long") 332 set(TIFF_UINT64_FORMAT "%lu") 333elseif(SIZEOF_UNSIGNED_LONG_LONG EQUAL 8) 334 set(TIFF_UINT64_T "unsigned long long") 335 if (MINGW) 336 set(TIFF_UINT64_FORMAT "%I64u") 337 else() 338 set(TIFF_UINT64_FORMAT "%llu") 339 endif() 340endif() 341 342if(SIZEOF_UNSIGNED_INT EQUAL SIZEOF_SIZE_T) 343 set(TIFF_SIZE_T "unsigned int") 344 set(TIFF_SIZE_FORMAT "%u") 345elseif(SIZEOF_UNSIGNED_LONG EQUAL SIZEOF_SIZE_T) 346 set(TIFF_SIZE_T "unsigned long") 347 set(TIFF_SIZE_FORMAT "%lu") 348elseif(SIZEOF_UNSIGNED_LONG_LONG EQUAL SIZEOF_SIZE_T) 349 set(TIFF_SIZE_T "unsigned long") 350 if (MINGW) 351 set(TIFF_SIZE_FORMAT "%I64u") 352 else() 353 set(TIFF_SIZE_FORMAT "%llu") 354 endif() 355endif() 356 357if(SIZEOF_SIGNED_INT EQUAL SIZEOF_UNSIGNED_CHAR_P) 358 set(TIFF_SSIZE_T "signed int") 359 set(TIFF_SSIZE_FORMAT "%d") 360elseif(SIZEOF_SIGNED_LONG EQUAL SIZEOF_UNSIGNED_CHAR_P) 361 set(TIFF_SSIZE_T "signed long") 362 set(TIFF_SSIZE_FORMAT "%ld") 363elseif(SIZEOF_SIGNED_LONG_LONG EQUAL SIZEOF_UNSIGNED_CHAR_P) 364 set(TIFF_SSIZE_T "signed long long") 365 if (MINGW) 366 set(TIFF_SSIZE_FORMAT "%I64d") 367 else() 368 set(TIFF_SSIZE_FORMAT "%lld") 369 endif() 370endif() 371 372if(NOT SIZEOF_PTRDIFF_T) 373 set(TIFF_PTRDIFF_T "${TIFF_SSIZE_T}") 374 set(TIFF_PTRDIFF_FORMAT "${SSIZE_FORMAT}") 375else() 376 set(TIFF_PTRDIFF_T "ptrdiff_t") 377 set(TIFF_PTRDIFF_FORMAT "%ld") 378endif() 379 380#report_values(TIFF_INT8_T TIFF_INT8_FORMAT 381# TIFF_UINT8_T TIFF_UINT8_FORMAT 382# TIFF_INT16_T TIFF_INT16_FORMAT 383# TIFF_UINT16_T TIFF_UINT16_FORMAT 384# TIFF_INT32_T TIFF_INT32_FORMAT 385# TIFF_UINT32_T TIFF_UINT32_FORMAT 386# TIFF_INT64_T TIFF_INT64_FORMAT 387# TIFF_UINT64_T TIFF_UINT64_FORMAT 388# TIFF_SSIZE_T TIFF_SSIZE_FORMAT 389# TIFF_PTRDIFF_T TIFF_PTRDIFF_FORMAT) 390 391# Nonstandard int types 392check_type_size(INT8 int8) 393set(HAVE_INT8 ${INT8}) 394check_type_size(INT16 int16) 395set(HAVE_INT16 ${INT16}) 396check_type_size(INT32 int32) 397set(HAVE_INT32 ${INT32}) 398 399# Check functions 400set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) 401set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${M_LIBRARY}) 402check_function_exists(floor HAVE_FLOOR) 403check_function_exists(pow HAVE_POW) 404check_function_exists(sqrt HAVE_SQRT) 405set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) 406 407check_function_exists(isascii HAVE_ISASCII) 408check_function_exists(memmove HAVE_MEMMOVE) 409check_function_exists(memset HAVE_MEMSET) 410check_function_exists(mmap HAVE_MMAP) 411check_function_exists(setmode HAVE_SETMODE) 412check_function_exists(strcasecmp HAVE_STRCASECMP) 413check_function_exists(strchr HAVE_STRCHR) 414check_function_exists(strrchr HAVE_STRRCHR) 415check_function_exists(strstr HAVE_STRSTR) 416check_function_exists(strtol HAVE_STRTOL) 417check_function_exists(strtol HAVE_STRTOUL) 418check_function_exists(strtoull HAVE_STRTOULL) 419check_function_exists(getopt HAVE_GETOPT) 420check_function_exists(lfind HAVE_LFIND) 421 422# May be inlined, so check it compiles: 423check_c_source_compiles(" 424#include <stdio.h> 425int main(void) { 426 char buf[10]; 427 snprintf(buf, 10, \"Test %d\", 1); 428 return 0; 429}" 430 HAVE_SNPRINTF) 431 432if(NOT HAVE_SNPRINTF) 433 add_definitions(-DNEED_LIBPORT) 434endif() 435 436# CPU bit order 437set(fillorder FILLORDER_MSB2LSB) 438if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "i.*86.*" OR 439 CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64.*" OR 440 CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64.*") 441 set(fillorder FILLORDER_LSB2MSB) 442endif() 443set(HOST_FILLORDER ${fillorder} CACHE STRING "Native CPU bit order") 444mark_as_advanced(HOST_FILLORDER) 445 446# CPU endianness 447include(TestBigEndian) 448test_big_endian(bigendian) 449if (bigendian) 450 set(bigendian ON) 451else() 452 set(bigendian OFF) 453endif() 454set(HOST_BIG_ENDIAN ${bigendian} CACHE STRING "Native CPU bit order") 455mark_as_advanced(HOST_BIG_ENDIAN) 456if (HOST_BIG_ENDIAN) 457 set(HOST_BIG_ENDIAN 1) 458else() 459 set(HOST_BIG_ENDIAN 0) 460endif() 461 462# IEEE floating point 463set(HAVE_IEEEFP 1 CACHE STRING "IEEE floating point is available") 464mark_as_advanced(HAVE_IEEEFP) 465 466report_values(CMAKE_HOST_SYSTEM_PROCESSOR HOST_FILLORDER 467 HOST_BIG_ENDIAN HAVE_IEEEFP) 468 469# Large file support 470if (UNIX) 471 # This might not catch every possibility catered for by 472 # AC_SYS_LARGEFILE. 473 add_definitions(-D_FILE_OFFSET_BITS=64) 474 set(FILE_OFFSET_BITS 64) 475endif() 476 477# Documentation install directory (default to cmake project docdir) 478set(LIBTIFF_DOCDIR "${CMAKE_INSTALL_FULL_DOCDIR}") 479 480# Options to enable and disable internal codecs 481 482option(ccitt "support for CCITT Group 3 & 4 algorithms" ON) 483set(CCITT_SUPPORT ${ccitt}) 484 485option(packbits "support for Macintosh PackBits algorithm" ON) 486set(PACKBITS_SUPPORT ${packbits}) 487 488option(lzw "support for LZW algorithm" ON) 489set(LZW_SUPPORT ${lzw}) 490 491option(thunder "support for ThunderScan 4-bit RLE algorithm" ON) 492set(THUNDER_SUPPORT ${thunder}) 493 494option(next "support for NeXT 2-bit RLE algorithm" ON) 495set(NEXT_SUPPORT ${next}) 496 497option(logluv "support for LogLuv high dynamic range algorithm" ON) 498set(LOGLUV_SUPPORT ${logluv}) 499 500# Option for Microsoft Document Imaging 501option(mdi "support for Microsoft Document Imaging" ON) 502set(MDI_SUPPORT ${mdi}) 503 504# ZLIB 505option(zlib "use zlib (required for Deflate compression)" ON) 506if (zlib) 507 find_package(ZLIB) 508endif() 509set(ZLIB_SUPPORT 0) 510if(ZLIB_FOUND) 511 set(ZLIB_SUPPORT 1) 512endif() 513set(ZIP_SUPPORT ${ZLIB_SUPPORT}) 514# Option for Pixar log-format algorithm 515 516# Pixar log format 517option(pixarlog "support for Pixar log-format algorithm (requires Zlib)" ON) 518set(PIXARLOG_SUPPORT FALSE) 519if (ZLIB_SUPPORT) 520 if(pixarlog) 521 set(PIXARLOG_SUPPORT TRUE) 522 endif() 523endif() 524 525# JPEG 526option(jpeg "use libjpeg (required for JPEG compression)" ON) 527if (jpeg) 528 find_package(JPEG) 529endif() 530set(JPEG_SUPPORT FALSE) 531if(JPEG_FOUND) 532 set(JPEG_SUPPORT TRUE) 533endif() 534 535option(old-jpeg "support for Old JPEG compression (read-only)" ON) 536set(OJPEG_SUPPORT FALSE) 537if (JPEG_SUPPORT) 538 if (old-jpeg) 539 set(OJPEG_SUPPORT TRUE) 540 endif() 541endif() 542 543# JBIG-KIT 544option(jbig "use ISO JBIG compression (requires JBIT-KIT library)" ON) 545if (jbig) 546 set(JBIG_FOUND 0) 547 find_path(JBIG_INCLUDE_DIR jbig.h) 548 set(JBIG_NAMES ${JBIG_NAMES} jbig libjbig) 549 find_library(JBIG_LIBRARY NAMES ${JBIG_NAMES}) 550 if (JBIG_INCLUDE_DIR AND JBIG_LIBRARY) 551 set(JBIG_FOUND 1) 552 set(JBIG_LIBRARIES ${JBIG_LIBRARY}) 553 endif() 554endif() 555set(JBIG_SUPPORT 0) 556if(JBIG_FOUND) 557 set(JBIG_FOUND TRUE) 558 set(JBIG_SUPPORT 1) 559else() 560 set(JBIG_FOUND FALSE) 561endif() 562 563set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES}) 564set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) 565set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${JBIG_INCLUDE_DIR}) 566set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${JBIG_LIBRARY}) 567check_function_exists(jbg_newlen HAVE_JBG_NEWLEN) 568set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE}) 569set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) 570 571# liblzma2 572option(lzma "use liblzma (required for LZMA2 compression)" ON) 573if (lzma) 574 find_package(LibLZMA) 575endif() 576set(LZMA_SUPPORT 0) 577if(LIBLZMA_FOUND) 578 set(LZMA_SUPPORT 1) 579endif() 580 581# 8/12-bit jpeg mode 582option(jpeg12 "enable libjpeg 8/12-bit dual mode (requires separate 58312-bit libjpeg build)" ON) 584set(JPEG12_INCLUDE_DIR JPEG12_INCLUDE_DIR-NOTFOUND CACHE PATH "Include directory for 12-bit libjpeg") 585set(JPEG12_LIBRARY JPEG12_LIBRARY-NOTFOUND CACHE FILEPATH "12-bit libjpeg library") 586set(JPEG12_FOUND FALSE) 587if (JPEG12_INCLUDE_DIR AND JPEG12_LIBRARY) 588 set(JPEG12_LIBRARIES ${JPEG12_LIBRARY}) 589 set(JPEG12_FOUND TRUE) 590endif() 591if (JPEG12_FOUND) 592 set(JPEG_DUAL_MODE_8_12 1) 593 set(LIBJPEG_12_PATH "${JPEG12_INCLUDE_DIR}/jpeglib.h") 594endif() 595 596# C++ support 597option(cxx "Enable C++ stream API building (requires C++ compiler)" ON) 598set(CXX_SUPPORT FALSE) 599if (cxx) 600 enable_language(CXX) 601 set(CXX_SUPPORT TRUE) 602endif() 603 604# OpenGL and GLUT 605find_package(OpenGL) 606find_package(GLUT) 607set(HAVE_OPENGL FALSE) 608if(OPENGL_FOUND AND OPENGL_GLU_FOUND AND GLUT_FOUND) 609 set(HAVE_OPENGL TRUE) 610endif() 611# Purely to satisfy the generated headers: 612check_include_file(GL/gl.h HAVE_GL_GL_H) 613check_include_file(GL/glu.h HAVE_GL_GLU_H) 614check_include_file(GL/glut.h HAVE_GL_GLUT_H) 615check_include_file(GLUT/glut.h HAVE_GLUT_GLUT_H) 616check_include_file(OpenGL/gl.h HAVE_OPENGL_GL_H) 617check_include_file(OpenGL/glu.h HAVE_OPENGL_GLU_H) 618 619# Win32 IO 620set(win32_io FALSE) 621if(WIN32) 622 set(win32_io TRUE) 623endif() 624set(USE_WIN32_FILEIO ${win32_io} CACHE BOOL "Use win32 IO system (Microsoft Windows only)") 625if (USE_WIN32_FILEIO) 626 set(USE_WIN32_FILEIO TRUE) 627else() 628 set(USE_WIN32_FILEIO FALSE) 629endif() 630 631# Orthogonal features 632 633# Strip chopping 634option(strip-chopping "strip chopping (whether or not to convert single-strip uncompressed images to mutiple strips of specified size to reduce memory usage)" ON) 635set(TIFF_DEFAULT_STRIP_SIZE 8192 CACHE STRING "default size of the strip in bytes (when strip chopping is enabled)") 636 637set(STRIPCHOP_DEFAULT) 638if(strip-chopping) 639 set(STRIPCHOP_DEFAULT TRUE) 640 if(TIFF_DEFAULT_STRIP_SIZE) 641 set(STRIP_SIZE_DEFAULT "${TIFF_DEFAULT_STRIP_SIZE}") 642 endif() 643endif() 644 645# Defer loading of strip/tile offsets 646option(defer-strile-load "enable deferred strip/tile offset/size loading (experimental)" OFF) 647set(DEFER_STRILE_LOAD ${defer-strile-load}) 648 649# CHUNKY_STRIP_READ_SUPPORT 650option(chunky-strip-read "enable reading large strips in chunks for TIFFReadScanline() (experimental)" OFF) 651set(CHUNKY_STRIP_READ_SUPPORT ${chunky-strip-read}) 652 653# SUBIFD support 654set(SUBIFD_SUPPORT 1) 655 656# Default handling of ASSOCALPHA support. 657option(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) 658if(extrasample-as-alpha) 659 set(DEFAULT_EXTRASAMPLE_AS_ALPHA 1) 660endif() 661 662# Default handling of YCbCr subsampling support. 663# See Bug 168 in Bugzilla, and JPEGFixupTestSubsampling() for details. 664option(check-ycbcr-subsampling "enable picking up YCbCr subsampling info from the JPEG data stream to support files lacking the tag" ON) 665if (check-ycbcr-subsampling) 666 set(CHECK_JPEG_YCBCR_SUBSAMPLING 1) 667endif() 668 669# Generate pkg-config file 670set(prefix "${CMAKE_INSTALL_PREFIX}") 671set(exec_prefix "${CMAKE_INSTALL_PREFIX}") 672set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}") 673set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") 674configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libtiff-4.pc.in 675 ${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc) 676install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtiff-4.pc 677 DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig") 678 679# Includes used by libtiff (and tests) 680if(ZLIB_INCLUDE_DIRS) 681 list(APPEND TIFF_INCLUDES ${ZLIB_INCLUDE_DIRS}) 682endif() 683if(JPEG_INCLUDE_DIR) 684 list(APPEND TIFF_INCLUDES ${JPEG_INCLUDE_DIR}) 685endif() 686if(JPEG12_INCLUDE_DIR) 687 list(APPEND TIFF_INCLUDES ${JPEG12_INCLUDE_DIR}) 688endif() 689if(JBIG_INCLUDE_DIR) 690 list(APPEND TIFF_INCLUDES ${JBIG_INCLUDE_DIR}) 691endif() 692if(LIBLZMA_INCLUDE_DIRS) 693 list(APPEND TIFF_INCLUDES ${LIBLZMA_INCLUDE_DIRS}) 694endif() 695 696# Libraries required by libtiff 697set(TIFF_LIBRARY_DEPS) 698if(M_LIBRARY) 699 list(APPEND TIFF_LIBRARY_DEPS ${M_LIBRARY}) 700endif() 701if(ZLIB_LIBRARIES) 702 list(APPEND TIFF_LIBRARY_DEPS ${ZLIB_LIBRARIES}) 703endif() 704if(JPEG_LIBRARIES) 705 list(APPEND TIFF_LIBRARY_DEPS ${JPEG_LIBRARIES}) 706endif() 707if(JPEG12_LIBRARIES) 708 list(APPEND TIFF_LIBRARY_DEPS ${JPEG12_LIBRARIES}) 709endif() 710if(JBIG_LIBRARIES) 711 list(APPEND TIFF_LIBRARY_DEPS ${JBIG_LIBRARIES}) 712endif() 713if(LIBLZMA_LIBRARIES) 714 list(APPEND TIFF_LIBRARY_DEPS ${LIBLZMA_LIBRARIES}) 715endif() 716 717#report_values(TIFF_INCLUDES TIFF_LIBRARY_DEPS) 718 719# Process subdirectories 720add_subdirectory(port) 721add_subdirectory(libtiff) 722add_subdirectory(tools) 723add_subdirectory(test) 724add_subdirectory(contrib) 725add_subdirectory(build) 726add_subdirectory(man) 727add_subdirectory(html) 728 729#message(STATUS "EXTRA_DIST: ${EXTRA_DIST}") 730 731message(STATUS "") 732message(STATUS "Libtiff is now configured for ${host}") 733message(STATUS "") 734message(STATUS " Installation directory: ${prefix}") 735message(STATUS " Documentation directory: ${LIBTIFF_DOCDIR}") 736message(STATUS " C compiler: ${CMAKE_C_COMPILER}") 737message(STATUS " C++ compiler: ${CMAKE_CXX_COMPILER}") 738message(STATUS " Build shared libraries: ${BUILD_SHARED_LIBS}") 739message(STATUS " Enable linker symbol versioning: ${HAVE_LD_VERSION_SCRIPT}") 740message(STATUS " Support Microsoft Document Imaging: ${mdi}") 741message(STATUS " Use win32 IO: ${USE_WIN32_FILEIO}") 742message(STATUS "") 743message(STATUS " Support for internal codecs:") 744message(STATUS " CCITT Group 3 & 4 algorithms: ${ccitt}") 745message(STATUS " Macintosh PackBits algorithm: ${packbits}") 746message(STATUS " LZW algorithm: ${lzw}") 747message(STATUS " ThunderScan 4-bit RLE algorithm: ${thunder}") 748message(STATUS " NeXT 2-bit RLE algorithm: ${next}") 749message(STATUS " LogLuv high dynamic range encoding: ${logluv}") 750message(STATUS "") 751message(STATUS " Support for external codecs:") 752message(STATUS " ZLIB support: ${zlib} (requested) ${ZLIB_FOUND} (availability)") 753message(STATUS " Pixar log-format algorithm: ${pixarlog} (requested) ${PIXARLOG_SUPPORT} (availability)") 754message(STATUS " JPEG support: ${jpeg} (requested) ${JPEG_FOUND} (availability)") 755message(STATUS " Old JPEG support: ${old-jpeg} (requested) ${JPEG_FOUND} (availability)") 756message(STATUS " JPEG 8/12 bit dual mode: ${jpeg12} (requested) ${JPEG12_FOUND} (availability)") 757message(STATUS " ISO JBIG support: ${jbig} (requested) ${JBIG_FOUND} (availability)") 758message(STATUS " LZMA2 support: ${lzma} (requested) ${LIBLZMA_FOUND} (availability)") 759message(STATUS "") 760message(STATUS " C++ support: ${cxx} (requested) ${CXX_SUPPORT} (availability)") 761message(STATUS "") 762# message(STATUS " X Athena Widgets support: ${HAVE_XAW}") 763message(STATUS " OpenGL support: ${HAVE_OPENGL}") 764message(STATUS "") 765