|
| 1 | +# Flags |
| 2 | +include (CheckIncludeFile) |
| 3 | +check_include_file(math.h HAVE_MATH_H) |
| 4 | +check_include_file(ctype.h HAVE_CTYPE_H) |
| 5 | +check_include_file(inttypes.h HAVE_INTTYPES_H) |
| 6 | +check_include_file(float.h HAVE_FLOAT_H) |
| 7 | +check_include_file(ieeefp.h HAVE_IEEEFP_H) |
| 8 | +check_include_file(stdarg.h HAVE_STDARG_H) |
| 9 | +check_include_file(stddef.h HAVE_STDDEF_H) |
| 10 | +check_include_file(stdint.h HAVE_STDINT_H) |
| 11 | +check_include_file(stdio.h HAVE_STDIO_H) |
| 12 | +check_include_file(stdlib.h HAVE_STDLIB_H) |
| 13 | +check_include_file(assert.h HAVE_ASSERT_H) |
| 14 | +check_include_file(dlfcn.h HAVE_DLFCN_H) |
| 15 | +check_include_file(endian.h HAVE_ENDIAN_H) |
| 16 | +check_include_file(memory.h HAVE_MEMORY_H) |
| 17 | +check_include_file(strings.h HAVE_STRINGS_H) |
| 18 | +check_include_file(string.h HAVE_STRING_H) |
| 19 | +check_include_file(time.h HAVE_TIME_H) |
| 20 | +check_include_file(unistd.h HAVE_UNISTD_H) |
| 21 | +check_include_file(sys/stat.h HAVE_SYS_STAT_H) |
| 22 | +check_include_file(sys/types.h HAVE_SYS_TYPES_H) |
| 23 | + |
| 24 | +include (CheckIncludeFileCXX) |
| 25 | +check_include_file_cxx(cmath HAVE_CMATH) |
| 26 | +check_include_file_cxx(cctype HAVE_CCTYPE) |
| 27 | +check_include_file_cxx(cinttypes HAVE_CINTTYPES) |
| 28 | +check_include_file_cxx(cfloat HAVE_CFLOAT) |
| 29 | +check_include_file_cxx(cieeefp HAVE_CIEEEFP) |
| 30 | +check_include_file_cxx(cstdarg HAVE_CSTDARG) |
| 31 | +check_include_file_cxx(cstddef HAVE_CSTDDEF) |
| 32 | +check_include_file_cxx(cstdint HAVE_CSTDINT) |
| 33 | +check_include_file_cxx(cstdio HAVE_CSTDIO) |
| 34 | +check_include_file_cxx(cstdlib HAVE_CSTDLIB) |
| 35 | +check_include_file_cxx(cassert HAVE_CASSERT) |
| 36 | +check_include_file_cxx(cstring HAVE_CSTRING) |
| 37 | +check_include_file_cxx(ctime HAVE_CTIME) |
| 38 | + |
| 39 | +set(STDC_HEADERS 1 CACHE INTERNAL "System has ANSI C header files") |
| 40 | + |
| 41 | +set(TEST_INCLUDES "") |
| 42 | +if(HAVE_CMATH) |
| 43 | + list(APPEND TEST_INCLUDES "cmath") |
| 44 | +endif() |
| 45 | +if(HAVE_CFLOAT) |
| 46 | + list(APPEND TEST_INCLUDES "cfloat") |
| 47 | +endif() |
| 48 | +if(HAVE_CIEEEFP) |
| 49 | + list(APPEND TEST_INCLUDES "cieeefp") |
| 50 | +endif() |
| 51 | +if(HAVE_MATH_H) |
| 52 | + list(APPEND TEST_INCLUDES "math.h") |
| 53 | +endif() |
| 54 | +if(HAVE_FLOAT_H) |
| 55 | + list(APPEND TEST_INCLUDES "float.h") |
| 56 | +endif() |
| 57 | +if(HAVE_IEEEFP_H) |
| 58 | + list(APPEND TEST_INCLUDES "ieeefp.h") |
| 59 | +endif() |
| 60 | + |
| 61 | +# ISFINITE |
| 62 | +include(CheckCXXSourceCompiles) |
| 63 | +check_cxx_source_compiles( |
| 64 | + "#include <cmath>\nint main(){return std::isfinite(0);}" |
| 65 | + HAVE_STD_ISFINITE) |
| 66 | +include(CheckFunctionExists) |
| 67 | +include(CheckCXXSymbolExists) |
| 68 | +check_cxx_symbol_exists(isfinite "${TEST_INCLUDES}" HAVE_ISFINITE) |
| 69 | +check_cxx_symbol_exists(finite "${TEST_INCLUDES}" HAVE_FINITE) |
| 70 | +check_cxx_symbol_exists(_finite "${TEST_INCLUDES}" HAVE__FINITE) |
| 71 | +check_cxx_symbol_exists(__finite "${TEST_INCLUDES}" HAVE___FINITE) |
| 72 | +if(HAVE_STD_ISFINITE) |
| 73 | + set(COIN_C_FINITE "std::isfinite") |
| 74 | +elseif(HAVE_ISFINITE) |
| 75 | + set(COIN_C_FINITE "isfinite") |
| 76 | +elseif(HAVE_FINITE) |
| 77 | + set(COIN_C_FINITE "finite") |
| 78 | +elseif(HAVE__FINITE) |
| 79 | + set(COIN_C_FINITE "_finite") |
| 80 | +elseif(HAVE___FINITE) |
| 81 | + set(COIN_C_FINITE "__finite") |
| 82 | +else() |
| 83 | + message(FATAL_ERROR "Can't find isfinite()") |
| 84 | +endif() |
| 85 | +message(STATUS "Found isfinite: ${COIN_C_FINITE}") |
| 86 | + |
| 87 | +# ISNAN |
| 88 | +include(CheckCXXSourceCompiles) |
| 89 | +check_cxx_source_compiles( |
| 90 | + "#include <cmath>\nint main(){return std::isnan(0);}" |
| 91 | + HAVE_STD_ISNAN) |
| 92 | +include(CheckFunctionExists) |
| 93 | +include(CheckCXXSymbolExists) |
| 94 | +check_cxx_symbol_exists(isnan "${TEST_INCLUDES}" HAVE_ISNAN) |
| 95 | +check_cxx_symbol_exists(_isnan "${TEST_INCLUDES}" HAVE__ISNAN) |
| 96 | +check_cxx_symbol_exists(__isnan "${TEST_INCLUDES}" HAVE___ISNAN) |
| 97 | +if(HAVE_STD_ISNAN) |
| 98 | + set(COIN_C_ISNAN "std::isnan") |
| 99 | +elseif(HAVE_ISNAN) |
| 100 | + set(COIN_C_ISNAN "isnan") |
| 101 | +elseif(HAVE__ISNAN) |
| 102 | + set(COIN_C_ISNAN "_isnan") |
| 103 | +elseif(HAVE___ISNAN) |
| 104 | + set(COIN_C_ISNAN "__isnan") |
| 105 | +else() |
| 106 | + message(FATAL_ERROR "Can't find isnan()") |
| 107 | +endif() |
| 108 | +message(STATUS "Found isnan: ${COIN_C_ISNAN}") |
| 109 | + |
| 110 | +# Basic type |
| 111 | +include(CheckTypeSize) |
| 112 | +check_type_size("int64_t" SIZEOF_INT64_T) |
| 113 | +check_type_size("long long" SIZEOF_LONG_LONG) |
| 114 | +check_type_size("long" SIZEOF_LONG) |
| 115 | +check_type_size("uint64_t" SIZEOF_UINT64_T) |
| 116 | +check_type_size("unsigned long long" SIZEOF_ULONG_LONG) |
| 117 | +check_type_size("unsigned long" SIZEOF_ULONG) |
| 118 | +check_type_size("intptr_t" SIZEOF_INTPTR_T) |
| 119 | +check_type_size("int *" SIZEOF_INT_P) |
| 120 | + |
| 121 | +if(SIZEOF_INT64_T EQUAL "8") |
| 122 | + set(COIN_INT64_T "int64_t") |
| 123 | +elseif(SIZEOF_LONG EQUAL "8") |
| 124 | + set(COIN_INT64_T "long") |
| 125 | +elseif(SIZEOF_LONG_LONG EQUAL "8") |
| 126 | + set(COIN_INT64_T "long long") |
| 127 | +else() |
| 128 | + message(FATAL_ERROR "Can't find suitable int64_t") |
| 129 | +endif() |
| 130 | +message(STATUS "Found int64_t: ${COIN_INT64_T}") |
| 131 | + |
| 132 | +if(SIZEOF_UINT64_T EQUAL "8") |
| 133 | + set(COIN_UINT64_T "uint64_t") |
| 134 | +elseif(SIZEOF_ULONG EQUAL "8") |
| 135 | + set(COIN_INT64_T "unsigned long") |
| 136 | +elseif(SIZEOF_ULONG_LONG EQUAL "8") |
| 137 | + set(COIN_INT64_T "unsigned long long") |
| 138 | +else() |
| 139 | + message(FATAL_ERROR "Can't find suitable uint64_t") |
| 140 | +endif() |
| 141 | +message(STATUS "Found uint64_t: ${COIN_UINT64_T}") |
| 142 | + |
| 143 | +if(SIZEOF_INTPTR_T) |
| 144 | + set(COIN_INTPTR_T "intptr_t") |
| 145 | +elseif(SIZEOF_INT_P) |
| 146 | + set(COIN_INTPTR_T "int *") |
| 147 | +else() |
| 148 | + message(FATAL_ERROR "Can't find suitable intptr_t") |
| 149 | +endif() |
| 150 | +message(STATUS "Found intptr_t: ${COIN_INTPTR_T}") |
| 151 | + |
0 commit comments