cmake: check all available compiler features even if BUILD_STRICT_C90
This commit is contained in:
parent
43a296656d
commit
b6c9518e97
@ -75,7 +75,7 @@ include(TestBigEndian)
|
|||||||
test_big_endian(GMIO_HOST_IS_BIG_ENDIAN)
|
test_big_endian(GMIO_HOST_IS_BIG_ENDIAN)
|
||||||
|
|
||||||
# Adapt C compiler flags to satisfy the GMIO_BUILD_STRICT_C90 option
|
# Adapt C compiler flags to satisfy the GMIO_BUILD_STRICT_C90 option
|
||||||
# It must be done before checking of C99 and POSIX features
|
# It must be done before checking non ANSI features(C99, POSIX, ...)
|
||||||
if(GMIO_BUILD_STRICT_C90)
|
if(GMIO_BUILD_STRICT_C90)
|
||||||
if(CMAKE_C_COMPILER_IS_GCC_COMPATIBLE)
|
if(CMAKE_C_COMPILER_IS_GCC_COMPATIBLE)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ansi -pedantic-errors")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ansi -pedantic-errors")
|
||||||
@ -97,8 +97,6 @@ endif()
|
|||||||
check_type_size("int" GMIO_SIZEOF_INT)
|
check_type_size("int" GMIO_SIZEOF_INT)
|
||||||
check_type_size("long" GMIO_SIZEOF_LONG)
|
check_type_size("long" GMIO_SIZEOF_LONG)
|
||||||
|
|
||||||
# Check non-ANSI available features
|
|
||||||
if(NOT GMIO_BUILD_STRICT_C90)
|
|
||||||
# Check availability of a 64b integer type
|
# Check availability of a 64b integer type
|
||||||
if(GMIO_HAVE_STDINT_H)
|
if(GMIO_HAVE_STDINT_H)
|
||||||
set(CMAKE_REQUIRED_INCLUDES stdint.h)
|
set(CMAKE_REQUIRED_INCLUDES stdint.h)
|
||||||
@ -110,7 +108,7 @@ if(NOT GMIO_BUILD_STRICT_C90)
|
|||||||
check_type_size("long long" GMIO_SIZEOF_LONG_LONG)
|
check_type_size("long long" GMIO_SIZEOF_LONG_LONG)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_REQUIRED_INCLUDES)
|
set(CMAKE_REQUIRED_INCLUDES) # Pop changes
|
||||||
|
|
||||||
if(HAVE_GMIO_SIZEOF_INT64_T)
|
if(HAVE_GMIO_SIZEOF_INT64_T)
|
||||||
set(GMIO_HAVE_INT64_T ${HAVE_GMIO_SIZEOF_INT64_T})
|
set(GMIO_HAVE_INT64_T ${HAVE_GMIO_SIZEOF_INT64_T})
|
||||||
@ -121,15 +119,17 @@ if(NOT GMIO_BUILD_STRICT_C90)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Check C99 features
|
# Check C99 features
|
||||||
|
if(NOT GMIO_BUILD_STRICT_C90)
|
||||||
check_function_exists(strtof GMIO_HAVE_STRTOF_FUNC)
|
check_function_exists(strtof GMIO_HAVE_STRTOF_FUNC)
|
||||||
|
|
||||||
if(CMAKE_C_COMPILER_IS_GCC_COMPATIBLE)
|
if(CMAKE_C_COMPILER_IS_GCC_COMPATIBLE)
|
||||||
list(APPEND CMAKE_REQUIRED_LIBRARIES m) # -lm
|
list(APPEND CMAKE_REQUIRED_LIBRARIES m) # -lm
|
||||||
endif()
|
endif()
|
||||||
check_function_exists(powf GMIO_HAVE_POWF_FUNC)
|
check_function_exists(powf GMIO_HAVE_POWF_FUNC)
|
||||||
set(CMAKE_REQUIRED_LIBRARIES)
|
set(CMAKE_REQUIRED_LIBRARIES) # Pop changes
|
||||||
|
|
||||||
check_include_files(stdbool.h GMIO_HAVE_STDBOOL_H)
|
check_include_files(stdbool.h GMIO_HAVE_STDBOOL_H)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Check POSIX features
|
# Check POSIX features
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
@ -180,14 +180,14 @@ if(NOT GMIO_BUILD_STRICT_C90)
|
|||||||
set(CMAKE_EXTRA_INCLUDE_FILES)
|
set(CMAKE_EXTRA_INCLUDE_FILES)
|
||||||
set(CMAKE_REQUIRED_DEFINITIONS)
|
set(CMAKE_REQUIRED_DEFINITIONS)
|
||||||
|
|
||||||
# Verify large file support
|
# Verify large file support ?
|
||||||
if(GMIO_HAVE_SYS_STAT_H
|
if(GMIO_HAVE_SYS_STAT_H
|
||||||
AND NOT(GMIO_SIZEOF_STRUCT_STAT_ST_SIZE STREQUAL "0") # Not arch-dependent size
|
AND NOT(GMIO_SIZEOF_STRUCT_STAT_ST_SIZE STREQUAL "0") # Not arch-dependent size
|
||||||
AND NOT(GMIO_SIZEOF_STRUCT_STAT_ST_SIZE EQUAL 8))
|
AND NOT(GMIO_SIZEOF_STRUCT_STAT_ST_SIZE EQUAL 8))
|
||||||
message(WARNING "<sys/stat.h> does not provide 64b variant of fstat(), you may encounter problems with files > 2GB")
|
message(WARNING "<sys/stat.h> does not provide 64b variant of fstat(), you may encounter problems with files > 2GB")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Have builtin byte swap functions ?
|
# Have compiler-intrisics bytes wap functions ?
|
||||||
if(CMAKE_C_COMPILER_IS_GCC_COMPATIBLE)
|
if(CMAKE_C_COMPILER_IS_GCC_COMPATIBLE)
|
||||||
# __builtin_bswap16() is missing in x86 GCC version prior to v4.7
|
# __builtin_bswap16() is missing in x86 GCC version prior to v4.7
|
||||||
# See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52624
|
# See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52624
|
||||||
@ -203,7 +203,6 @@ if(NOT GMIO_BUILD_STRICT_C90)
|
|||||||
int main() { return (int)_byteswap_ulong(0x11223344); }"
|
int main() { return (int)_byteswap_ulong(0x11223344); }"
|
||||||
GMIO_HAVE_MSVC_BUILTIN_BSWAP_FUNC)
|
GMIO_HAVE_MSVC_BUILTIN_BSWAP_FUNC)
|
||||||
endif()
|
endif()
|
||||||
endif() # !GMIO_BUILD_STRICT_C90
|
|
||||||
|
|
||||||
# Specific flags for GCC-like compilers
|
# Specific flags for GCC-like compilers
|
||||||
if(CMAKE_C_COMPILER_IS_GCC_COMPATIBLE)
|
if(CMAKE_C_COMPILER_IS_GCC_COMPATIBLE)
|
||||||
@ -283,5 +282,5 @@ endif()
|
|||||||
|
|
||||||
# Examples:
|
# Examples:
|
||||||
# cmake -DCMAKE_INSTALL_PREFIX=gcc-linux64 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_DEBUG_POSTFIX=_d
|
# cmake -DCMAKE_INSTALL_PREFIX=gcc-linux64 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_DEBUG_POSTFIX=_d
|
||||||
# cmake -DCMAKE_INSTALL_PREFIX=gcc-linux64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_RELEASE_POSTFIX=_r
|
# cmake -DCMAKE_INSTALL_PREFIX=gcc-linux64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_RELEASE_POSTFIX=
|
||||||
# make VERBOSE=1 or cmake -DCMAKE_VERBOSE_MAKEFILE=TRUE
|
# make VERBOSE=1 or cmake -DCMAKE_VERBOSE_MAKEFILE=TRUE
|
||||||
|
Loading…
Reference in New Issue
Block a user