From 72440acea2369d3903ef73c62f02d62bd6dcde0a Mon Sep 17 00:00:00 2001 From: Dieter Baron Date: Tue, 2 Jan 2018 15:15:48 +0100 Subject: [PATCH] Simplify generated zipconf.h by moving logic into CMakeLists.txt. --- CMakeLists.txt | 82 ++++++++++++++++++++++++++++++++++++++++++ cmake-zipconf.h.in | 103 ++++++----------------------------------------------- 2 files changed, 92 insertions(+), 93 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3366b25..dfa22d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,6 +169,88 @@ ENDIF(CMAKE_SYSTEM_NAME MATCHES BSD) CONFIGURE_FILE(libzip.pc.in libzip.pc @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libzip.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +# fixed size integral types + +IF(HAVE_STDINT_H_LIBZIP) + SET(LIBZIP_TYPES_INCLUDE "#include ") +ELSEIF(HAVE_INTTYPES_H_LIBZIP) + SET(LIBZIP_TYPES_INCLUDE "#include ") +ELSEIF(HAVE_SYS_TYPES_H_LIBZIP) + SET(LIBZIP_TYPES_INCLUDE "#include ") +ENDIF() + +IF(HAVE_INT8_T_LIBZIP) + SET(ZIP_INT8_T int8_t) +ELSEIF(HAVE___INT8_LIBZIP) + SET(ZIP_INT8_T __int8) +ELSE() + SET(ZIP_INT8_T "signed char") +ENDIF() + +IF(HAVE_UINT8_T_LIBZIP) + SET(ZIP_UINT8_T uint8_t) +ELSEIF(HAVE___INT8_LIBZIP) + SET(ZIP_UINT8_T "unsigned __int8") +ELSE() + SET(ZIP_UINT8_T "unsigned char") +ENDIF() + +IF(HAVE_INT16_T_LIBZIP) + SET(ZIP_INT16_T int16_t) +ELSEIF(HAVE___INT16_LIBZIP) + SET(INT16_T_LIBZIP __int16) +ELSEIF(SHORT_LIBZIP EQUAL 2) + SET(INT16_T_LIBZIP short) +ENDIF() + +IF(HAVE_UINT16_T_LIBZIP) + SET(ZIP_UINT16_T uint16_t) +ELSEIF(HAVE___INT16_LIBZIP) + SET(UINT16_T_LIBZIP "unsigned __int16") +ELSEIF(SHORT_LIBZIP EQUAL 2) + SET(UINT16_T_LIBZIP "unsigned short") +ENDIF() + +IF(HAVE_INT32_T_LIBZIP) + SET(ZIP_INT32_T int32_t) +ELSEIF(HAVE___INT32_LIBZIP) + SET(ZIP_INT32_T __int32) +ELSEIF(INT_LIBZIP EQUAL 4) + SET(ZIP_INT32_T int) +ELSEIF(LONG_LIBZIP EQUAL 4) + SET(ZIP_INT32_T long) +ENDIF() + +IF(HAVE_UINT32_T_LIBZIP) +SET(ZIP_UINT32_T uint32_t) +ELSEIF(HAVE___INT32_LIBZIP) +SET(ZIP_UINT32_T "unsigned __int32") +ELSEIF(INT_LIBZIP EQUAL 4) +SET(ZIP_UINT32_T "unsigned int") +ELSEIF(LONG_LIBZIP EQUAL 4) +SET(ZIP_UINT32_T "unsigned long") +ENDIF() + +IF(HAVE_INT64_T_LIBZIP) + SET(ZIP_INT64_T int64_t) +ELSEIF(HAVE___INT64_LIBZIP) + SET(ZIP_INT64_T __int64) +ELSEIF(LONG_LIBZIP EQUAL 8) + SET(ZIP_INT64_T long) +ELSEIF(LONG_LONG_LIBZIP EQUAL 8) + SET(ZIP_INT64_T "long long") +ENDIF() + +IF(HAVE_UINT64_T_LIBZIP) + SET(ZIP_UINT64_T uint64_t) +ELSEIF(HAVE___INT64_LIBZIP) + SET(ZIP_UINT64_T "unsigned __int64") +ELSEIF(LONG_LIBZIP EQUAL 8) + SET(ZIP_UINT64_T "unsigned long") +ELSEIF(LONG_LONG_LIBZIP EQUAL 8) + SET(ZIP_UINT64_T "unsigned long long") +ENDIF() + # write out config file CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake-config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake-zipconf.h.in ${CMAKE_CURRENT_BINARY_DIR}/zipconf.h) diff --git a/cmake-zipconf.h.in b/cmake-zipconf.h.in index f0e24e8..6ff4fe3 100644 --- a/cmake-zipconf.h.in +++ b/cmake-zipconf.h.in @@ -15,99 +15,16 @@ #cmakedefine ZIP_STATIC -#cmakedefine HAVE_INTTYPES_H_LIBZIP -#cmakedefine HAVE_STDINT_H_LIBZIP -#cmakedefine HAVE_SYS_TYPES_H_LIBZIP -#cmakedefine HAVE___INT8_LIBZIP -#cmakedefine HAVE_INT8_T_LIBZIP -#cmakedefine HAVE_UINT8_T_LIBZIP -#cmakedefine HAVE___INT16_LIBZIP -#cmakedefine HAVE_INT16_T_LIBZIP -#cmakedefine HAVE_UINT16_T_LIBZIP -#cmakedefine HAVE___INT32_LIBZIP -#cmakedefine HAVE_INT32_T_LIBZIP -#cmakedefine HAVE_UINT32_T_LIBZIP -#cmakedefine HAVE___INT64_LIBZIP -#cmakedefine HAVE_INT64_T_LIBZIP -#cmakedefine HAVE_UINT64_T_LIBZIP -#cmakedefine HAVE_SSIZE_T_LIBZIP -#cmakedefine SHORT_LIBZIP ${SHORT_LIBZIP} -#cmakedefine INT_LIBZIP ${INT_LIBZIP} -#cmakedefine LONG_LIBZIP ${LONG_LIBZIP} -#cmakedefine LONG_LONG_LIBZIP ${LONG_LONG_LIBZIP} - -#if defined(HAVE_STDINT_H_LIBZIP) -#include -#elif defined(HAVE_INTTYPES_H_LIBZIP) -#include -#elif defined(HAVE_SYS_TYPES_H_LIBZIP) -#include -#endif - -#if defined(HAVE_INT8_T_LIBZIP) -typedef int8_t zip_int8_t; -#elif defined(HAVE___INT8_LIBZIP) -typedef __int8 zip_int8_t; -#else -typedef signed char zip_int8_t; -#endif -#if defined(HAVE_UINT8_T_LIBZIP) -typedef uint8_t zip_uint8_t; -#elif defined(HAVE___INT8_LIBZIP) -typedef unsigned __int8 zip_uint8_t; -#else -typedef unsigned char zip_uint8_t; -#endif -#if defined(HAVE_INT16_T_LIBZIP) -typedef int16_t zip_int16_t; -#elif defined(HAVE___INT16_LIBZIP) -typedef __int16 zip_int16_t; -#elif defined(SHORT_LIBZIP) && SHORT_LIBZIP == 2 -typedef signed short zip_int16_t; -#endif -#if defined(HAVE_UINT16_T_LIBZIP) -typedef uint16_t zip_uint16_t; -#elif defined(HAVE___INT16_LIBZIP) -typedef unsigned __int16 zip_uint16_t; -#elif defined(SHORT_LIBZIP) && SHORT_LIBZIP == 2 -typedef unsigned short zip_uint16_t; -#endif -#if defined(HAVE_INT32_T_LIBZIP) -typedef int32_t zip_int32_t; -#elif defined(HAVE___INT32_LIBZIP) -typedef __int32 zip_int32_t; -#elif defined(INT_LIBZIP) && INT_LIBZIP == 4 -typedef signed int zip_int32_t; -#elif defined(LONG_LIBZIP) && LONG_LIBZIP == 4 -typedef signed long zip_int32_t; -#endif -#if defined(HAVE_UINT32_T_LIBZIP) -typedef uint32_t zip_uint32_t; -#elif defined(HAVE___INT32_LIBZIP) -typedef unsigned __int32 zip_uint32_t; -#elif defined(INT_LIBZIP) && INT_LIBZIP == 4 -typedef unsigned int zip_uint32_t; -#elif defined(LONG_LIBZIP) && LONG_LIBZIP == 4 -typedef unsigned long zip_uint32_t; -#endif -#if defined(HAVE_INT64_T_LIBZIP) -typedef int64_t zip_int64_t; -#elif defined(HAVE___INT64_LIBZIP) -typedef __int64 zip_int64_t; -#elif defined(LONG_LIBZIP) && LONG_LIBZIP == 8 -typedef signed long zip_int64_t; -#elif defined(LONG_LONG_LIBZIP) && LONG_LONG_LIBZIP == 8 -typedef signed long long zip_int64_t; -#endif -#if defined(HAVE_UINT64_T_LIBZIP) -typedef uint64_t zip_uint64_t; -#elif defined(HAVE___INT64_LIBZIP) -typedef unsigned __int64 zip_uint64_t; -#elif defined(LONG_LIBZIP) && LONG_LONG_LIBZIP == 8 -typedef unsigned long zip_uint64_t; -#elif defined(LONG_LONG_LIBZIP) && LONG_LONG_LIBZIP == 8 -typedef unsigned long long zip_uint64_t; -#endif +${LIBZIP_TYPES_INCLUDE} + +typedef ${ZIP_INT8_T} zip_int8_t; +typedef ${ZIP_UINT8_T} zip_uint8_t; +typedef ${ZIP_INT16_T} zip_int16_t; +typedef ${ZIP_UINT16_T} zip_uint16_t; +typedef ${ZIP_INT32_T} zip_int32_t; +typedef ${ZIP_UINT32_T} zip_uint32_t; +typedef ${ZIP_INT64_T} zip_int64_t; +typedef ${ZIP_UINT64_T} zip_uint64_t; #define ZIP_INT8_MIN (-ZIP_INT8_MAX-1) #define ZIP_INT8_MAX 0x7f