Don't look for CppUnit unless BUILD_TESTS, general cleanup.

This commit is contained in:
Festus Hagen 2015-05-20 01:16:54 -04:00
parent e4cf012522
commit e44cba56b5

View File

@ -9,39 +9,37 @@ include(TestBigEndian)
include(TestFloatFormat)
# Check if the size of numeric types are suitable.
check_type_size("short" SIZEOF_SHORT)
if(NOT ${SIZEOF_SHORT} EQUAL 2)
MESSAGE(FATAL_ERROR "TagLib requires that short is 16-bit wide.")
message(FATAL_ERROR "TagLib requires that short is 16-bit wide.")
endif()
check_type_size("int" SIZEOF_INT)
if(NOT ${SIZEOF_INT} EQUAL 4)
MESSAGE(FATAL_ERROR "TagLib requires that int is 32-bit wide.")
message(FATAL_ERROR "TagLib requires that int is 32-bit wide.")
endif()
check_type_size("long long" SIZEOF_LONGLONG)
if(NOT ${SIZEOF_LONGLONG} EQUAL 8)
MESSAGE(FATAL_ERROR "TagLib requires that long long is 64-bit wide.")
message(FATAL_ERROR "TagLib requires that long long is 64-bit wide.")
endif()
check_type_size("wchar_t" SIZEOF_WCHAR_T)
if(${SIZEOF_WCHAR_T} LESS 2)
MESSAGE(FATAL_ERROR "TagLib requires that wchar_t is sufficient to store a UTF-16 char.")
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.")
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.")
message(FATAL_ERROR "TagLib requires that double is 64-bit wide.")
endif()
# Determine the CPU byte order.
test_big_endian(IS_BIG_ENDIAN)
if(NOT IS_BIG_ENDIAN)
@ -51,19 +49,16 @@ else()
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.")
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("
#include <atomic>
int main() {
@ -207,21 +202,27 @@ if(NOT HAVE_GCC_BYTESWAP_16 OR NOT HAVE_GCC_BYTESWAP_32 OR NOT HAVE_GCC_BYTESWAP
endif()
# Determine whether your compiler supports some safer version of sprintf.
check_cxx_source_compiles("
#include <cstdio>
int main() { char buf[20]; snprintf(buf, 20, \"%d\", 1); return 0; }
int main() {
char buf[20];
snprintf(buf, 20, \"%d\", 1);
return 0;
}
" HAVE_SNPRINTF)
if(NOT HAVE_SNPRINTF)
check_cxx_source_compiles("
#include <cstdio>
int main() { char buf[20]; sprintf_s(buf, \"%d\", 1); return 0; }
int main() {
char buf[20];
sprintf_s(buf, \"%d\", 1);
return 0;
}
" HAVE_SPRINTF_S)
endif()
# Check for libz using the cmake supplied FindZLIB.cmake
if(NOT ZLIB_SOURCE)
find_package(ZLIB)
if(ZLIB_FOUND)
@ -231,8 +232,11 @@ if(NOT ZLIB_SOURCE)
endif()
endif()
find_package(CppUnit)
if(NOT CppUnit_FOUND AND BUILD_TESTS)
message(STATUS "CppUnit not found, disabling tests.")
set(BUILD_TESTS OFF)
if(BUILD_TESTS)
find_package(CppUnit)
if(NOT CppUnit_FOUND AND BUILD_TESTS)
message(STATUS "CppUnit not found, disabling tests.")
set(BUILD_TESTS OFF)
endif()
endif()