diff --git a/thirdparty/libtiff/CMakeLists.txt b/thirdparty/libtiff/CMakeLists.txt index 24332458..62963711 100644 --- a/thirdparty/libtiff/CMakeLists.txt +++ b/thirdparty/libtiff/CMakeLists.txt @@ -119,25 +119,6 @@ set(STRIP_SIZE_DEFAULT 8192) set(SUBIFD_SUPPORT 1) set(THUNDER_SUPPORT 1) -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) - set(TIFF_SSIZE_T ssize_t) - set(TIFF_INT32_FORMAT "\"%d\"") - set(TIFF_UINT32_FORMAT "\"%u\"") - set(TIFF_INT64_FORMAT "\"%ld\"") - set(TIFF_UINT64_FORMAT "\"%lu\"") - set(TIFF_PTRDIFF_FORMAT "\"%ld\"") - set(TIFF_SSIZE_FORMAT "\"%ld\"") -endif() - CHECK_FUNCTION_EXISTS(getopt HAVE_GETOPT) CHECK_FUNCTION_EXISTS(isascii HAVE_ISASCII) CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE) @@ -162,6 +143,37 @@ 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) + elseif("${CMAKE_SIZEOF_VOID_P}" EQUAL 4) + set(TIFF_SSIZE_T int32_t) + 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 "\"%ld\"") + set(TIFF_UINT64_FORMAT "\"%lu\"") + set(TIFF_PTRDIFF_FORMAT "\"%ld\"") + set(TIFF_SSIZE_FORMAT "\"%ld\"") +endif() # set(VERSION "\"4.0.1\"") @@ -178,6 +190,19 @@ 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}") + 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 diff --git a/thirdparty/libtiff/test_inline.c b/thirdparty/libtiff/test_inline.c new file mode 100644 index 00000000..ad25a9c6 --- /dev/null +++ b/thirdparty/libtiff/test_inline.c @@ -0,0 +1,10 @@ +/* Test source lifted from /usr/share/autoconf/autoconf/c.m4 */ +typedef int foo_t; +static inline foo_t static_foo(){return 0;} +foo_t foo(){return 0;} +int main(int argc, char *argv[]){return 0;} +/* Test source lifted from /usr/share/autoconf/autoconf/c.m4 */ +typedef int foo_t; +static inline foo_t static_foo(){return 0;} +foo_t foo(){return 0;} +int main(int argc, char *argv[]){return 0;} diff --git a/thirdparty/libtiff/tif_config.h.cmake.in b/thirdparty/libtiff/tif_config.h.cmake.in index d3711a76..23bdc46a 100644 --- a/thirdparty/libtiff/tif_config.h.cmake.in +++ b/thirdparty/libtiff/tif_config.h.cmake.in @@ -383,7 +383,7 @@ /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus -#cmakedefine inline +#define inline @INLINE@ #endif /* Define to `long int' if does not define. */