Added float conversion functions to ByteVector.

Added CMake checks about IEEE754 compliance.
This commit is contained in:
Tsuda Kageyu
2014-07-17 01:28:02 +09:00
parent b509106031
commit e29f1d39e7
10 changed files with 397 additions and 60 deletions

View File

@ -6,8 +6,9 @@ include(CheckLibraryExists)
include(CheckTypeSize)
include(CheckCXXSourceCompiles)
include(TestBigEndian)
include(TestFloatFormat)
# Check if the size of integral types are suitable.
# Check if the size of numeric types are suitable.
check_type_size("short" SIZEOF_SHORT)
if(NOT ${SIZEOF_SHORT} EQUAL 2)
@ -29,6 +30,16 @@ if(${SIZEOF_WCHAR_T} LESS 2)
MESSAGE(FATAL_ERROR "TagLib requires that wchar_t is sufficient to store a UTF-16 char.")
endif()
check_type_size("float" SIZEOF_FLOAT)
if(NOT ${SIZEOF_FLOAT} EQUAL 4)
MESSAGE(FATAL_ERROR "TagLib requires that float is 32-bit wide.")
endif()
check_type_size("double" SIZEOF_DOUBLE)
if(NOT ${SIZEOF_DOUBLE} EQUAL 8)
MESSAGE(FATAL_ERROR "TagLib requires that double is 64-bit wide.")
endif()
# Determine the CPU byte order.
test_big_endian(IS_BIG_ENDIAN)
@ -39,6 +50,18 @@ else()
set(SYSTEM_BYTEORDER 2)
endif()
# Check if the format of floating point types are suitable.
test_float_format(FP_IEEE754)
if(${FP_IEEE754} EQUAL 1)
set(FLOAT_BYTEORDER 1)
elseif(${FP_IEEE754} EQUAL 2)
set(FLOAT_BYTEORDER 2)
else()
MESSAGE(FATAL_ERROR "TagLib requires that floating point types are IEEE754 compliant.")
endif()
# Determine which kind of atomic operations your compiler supports.
check_cxx_source_compiles("