From 5084db331ce2ba94a10766e03c8f383d0d57cdd1 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Mon, 2 Sep 2013 10:12:08 +0200 Subject: [PATCH] Added support for standard 64-bit integer type. --- CMakeLists.txt | 20 ++++++++++++++++---- cmake/config.hpp.cmake | 5 +++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b1ec771..5cfe7db8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.6 FATAL_ERROR) INCLUDE(cmake/Utils.cmake) INCLUDE(CheckIncludeFiles) +INCLUDE(CheckIncludeFileCxx) INCLUDE(CheckFunctionExists) INCLUDE(CheckSymbolExists) INCLUDE(CheckTypeSize) @@ -448,6 +449,8 @@ ELSE(BIGENDIAN EQUAL 0) ENDIF(BIGENDIAN EQUAL 0) +CHECK_INCLUDE_FILE_CXX(cstdint VMIME_HAVE_CSTDINT) + CHECK_TYPE_SIZE("char" SIZEOF_CHAR) CHECK_TYPE_SIZE("short" SIZEOF_SHORT) CHECK_TYPE_SIZE("int" SIZEOF_INT) @@ -455,6 +458,11 @@ CHECK_TYPE_SIZE("long" SIZEOF_LONG) CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG) CHECK_TYPE_SIZE("__int64" SIZEOF___INT64) +SET(CMAKE_EXTRA_INCLUDE_FILES cstdint) +CHECK_TYPE_SIZE("int64_t" SIZEOF_INT64_T) +SET(CMAKE_EXTRA_INCLUDE_FILES) + + IF(SIZEOF_CHAR EQUAL 1) SET(VMIME_8BIT_TYPE "char") ELSE() @@ -494,10 +502,14 @@ ELSE() IF(SIZEOF_LONG_LONG EQUAL 8) SET(VMIME_64BIT_TYPE "long long") ELSE() - IF(SIZEOF___INT64 EQUAL 8) - SET(VMIME_64BIT_TYPE "__int64") + IF(SIZEOF_INT64_T EQUAL 8) + SET(VMIME_64BIT_TYPE "int64_t") ELSE() - MESSAGE(FATAL_ERROR "Cannot determine 64-bit type") + IF(SIZEOF___INT64 EQUAL 8) + SET(VMIME_64BIT_TYPE "__int64") + ELSE() + MESSAGE(FATAL_ERROR "Cannot determine 64-bit type") + ENDIF() ENDIF() ENDIF() ENDIF() @@ -895,7 +907,7 @@ ELSE() SET( CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -D_REENTRANT=1 -W -Wall -ansi -pedantic -Wpointer-arith -Wold-style-cast -Wconversion -Wcast-align" + "${CMAKE_CXX_FLAGS} -D_REENTRANT=1 -W -Wall -ansi -pedantic -Wpointer-arith -Wold-style-cast -Wconversion -Wcast-align -Wno-long-long" CACHE STRING "g++ Compiler Flags" FORCE diff --git a/cmake/config.hpp.cmake b/cmake/config.hpp.cmake index d1b235cf..afae3d16 100644 --- a/cmake/config.hpp.cmake +++ b/cmake/config.hpp.cmake @@ -28,6 +28,11 @@ #define VMIME_BYTE_ORDER_LITTLE_ENDIAN @VMIME_BYTE_ORDER_LITTLE_ENDIAN@ // Generic types +#cmakedefine01 VMIME_HAVE_CSTDINT +#if VMIME_HAVE_CSTDINT +# include +#endif + // -- 8-bit typedef signed @VMIME_8BIT_TYPE@ vmime_int8; typedef unsigned @VMIME_8BIT_TYPE@ vmime_uint8;