1# Check headers 2include(CheckIncludeFile) 3include(CheckIncludeFiles) 4check_include_files(dlfcn.h HAVE_DLFCN_H) 5check_include_files(inttypes.h HAVE_INTTYPES_H) 6check_include_files(limits.h HAVE_LIMITS_H) 7check_include_files(memory.h HAVE_MEMORY_H) 8check_include_files(net/errno.h HAVE_NET_ERRNO_H) 9check_include_files(stdint.h HAVE_STDINT_H) 10check_include_files(stdlib.h HAVE_STDLIB_H) 11check_include_files(strings.h HAVE_STRINGS_H) 12check_include_files(string.h HAVE_STRING_H) 13check_include_files(sys/param.h HAVE_SYS_PARAM_H) 14check_include_files(sys/stat.h HAVE_SYS_STAT_H ) 15check_include_files(sys/types.h HAVE_SYS_TYPES_H ) 16check_include_files(unistd.h HAVE_UNISTD_H ) 17check_include_files(dirent.h HAVE_DIRENT_H) 18check_include_files(limits.h HAVE_LIMITS_H) 19check_include_files(alloca.h HAVE_ALLOCA_H ) 20check_include_files(stdint.h HAVE_STDINT_H ) 21check_include_files(sys/mman.h HAVE_SYS_MMAN_H) 22check_include_files(errno.h HAVE_ERRNO_H) 23check_include_files(float.h HAVE_FLOAT_H) 24check_include_files(sys/wait.h HAVE_SYS_WAIT_H) 25check_include_files(values.h HAVE_VALUES_H) 26check_include_files(stdarg.h HAVE_STDARG_H) 27 28# Check functions 29include(CheckFunctionExists) 30check_function_exists(fseek64 HAVE_FSEEK64) 31check_function_exists(open64 HAVE_OPEN64) 32check_function_exists(memcpy HAVE_MEMCPY) 33check_function_exists(mmap HAVE_MMAP) 34check_function_exists(lseek64 HAVE_LSEEK64) 35set(CMAKE_EXTRA_INCLUDE_FILES math.h) 36if(NOT WIN32) 37set(CMAKE_REQUIRED_LIBRARIES m) 38endif() 39check_function_exists(round HAVE_ROUND) 40set(CMAKE_EXTRA_INCLUDE_FILES) 41set(CMAKE_REQUIRED_LIBRARIES) 42 43# Check types 44include ( CheckTypeSize ) 45check_type_size ( "long double" HAVE_LONG_DOUBLE ) 46check_type_size ( "double" SIZEOF_DOUBLE ) 47check_type_size ( "long double" SIZEOF_LONG_DOUBLE ) 48check_type_size ( "void*" SIZEOF_VOID_P ) 49# set(CMAKE_EXTRA_INCLUDE_FILES sys/stat.h) 50# check_type_size("struct stat64" _LARGEFILE64_SOURCE) 51# set(CMAKE_EXTRA_INCLUDE_FILES) 52 53# Check symbols 54include(CheckSymbolExists) 55 56# Custom checks... 57include (CheckCSourceCompiles) 58check_c_source_compiles("#include <sys/types.h> 59int main () { off64_t offset; return 0;}" HAVE_TYPE_OFF64_T) 60 61check_c_source_compiles("#include <sys/stat.h> 62int main () { struct stat64 p; return 0;}" HAVE_STRUCT_STAT64) 63check_c_source_compiles("#include <sys/types.h> 64#include <sys/dirent.h> 65int main () { struct dirent64 p; return 0;}" HAVE_STRUCT_DIRENT64) 66 67check_c_source_compiles("#include <sys/stat.h> 68int main () {struct stat64 buf; int i = stat64(\"/\", &buf); return 0;}" 69NO_LARGEFILE64_SOURCE) 70if(NOT NO_LARGEFILE64_SOURCE) 71check_c_source_compiles("#define _LARGEFILE64_SOURCE 1 72#include <sys/stat.h> 73int main () {struct stat64 buf; int i = stat64(\"/\", &buf); return 0;}" 74 _LARGEFILE64_SOURCE) 75endif(NOT NO_LARGEFILE64_SOURCE) 76 77check_c_source_compiles("#include <stdlib.h> 78int main () {char *p = (char *)strtoll; char *q = (char *)strtoull; return 0;}" 79NO_ISOC99_SOURCE) 80if(NOT NO_ISOC99_SOURCE) 81check_c_source_compiles("#define _ISOC99_SOURCE 1 82#include <stdlib.h> 83int main () {char *p = (char *)strtoll; char *q = (char *)strtoull; return 0;}" 84 _ISOC99_SOURCE) 85endif(NOT NO_ISOC99_SOURCE) 86 87check_c_source_compiles("#include <sys/stat.h> 88int main () {char *p = (char *)open64; return 0;}" 89NO_LARGEFILE_SOURCE64) 90if(NOT NO_LARGEFILE_SOURCE64) 91check_c_source_compiles("#define _LARGEFILE_SOURCE64 1 92#include <sys/stat.h> 93int main () {char *p = (char *)open64; return 0;}" 94 _LARGEFILE_SOURCE64) 95endif(NOT NO_LARGEFILE_SOURCE64) 96 97# See if the compiler knows natively about __int64 98set(tcl_cv_type_64bit "none") 99check_c_source_compiles("int main () {__int64 value = (__int64) 0; return 0;}" 100HAS___int64) 101if(HAS___int64) 102 set(tcl_type_64bit "__int64") 103else(HAS___int64) 104 set(tcl_type_64bit "long long") 105endif(HAS___int64) 106check_c_source_compiles("int main () {switch (0) {case 1: 107case (sizeof(${tcl_type_64bit})==sizeof(long)): ; }; return 0;}" 108HAS_WIDE_INT_NE_LONG) 109if(HAS_WIDE_INT_NE_LONG) 110 set(tcl_cv_type_64bit ${tcl_type_64bit}) 111endif(HAS_WIDE_INT_NE_LONG) 112 113if(${tcl_cv_type_64bit} STREQUAL "none") 114 set(TCL_WIDE_INT_IS_LONG 1) 115elseif((${tcl_cv_type_64bit} STREQUAL "__int64") AND WIN32) 116else(${tcl_cv_type_64bit} STREQUAL "none") 117 set(TCL_WIDE_INT_TYPE ${tcl_cv_type_64bit}) 118endif(${tcl_cv_type_64bit} STREQUAL "none") 119 120# Check for ANSI C header files... 121# ========================================================================== 122message(STATUS "Cheking for ANSI C header files...") 123if(HAVE_STDLIB_H AND HAVE_STDARG_H AND HAVE_STRING_H AND HAVE_FLOAT_H) 124 set(ac_cv_header_stdc ON) 125endif(HAVE_STDLIB_H AND HAVE_STDARG_H AND HAVE_STRING_H AND HAVE_FLOAT_H) 126 127if(ac_cv_header_stdc) 128 # SunOS 4.x string.h does not declare mem*, contrary to ANSI. 129 SET(CMAKE_EXTRA_INCLUDE_FILES string.h) 130 check_function_exists(memchr ac_cv_header_stdc) 131 SET(CMAKE_EXTRA_INCLUDE_FILES) 132endif(ac_cv_header_stdc) 133 134if(ac_cv_header_stdc) 135 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. 136 SET(CMAKE_EXTRA_INCLUDE_FILES stdlib.h) 137 check_function_exists(free ac_cv_header_stdc) 138 SET(CMAKE_EXTRA_INCLUDE_FILES) 139endif(ac_cv_header_stdc) 140 141if(ac_cv_header_stdc) 142 set(STDC_HEADERS 1) 143endif(ac_cv_header_stdc) 144 145if(NOT HAVE_DIRENT_H) 146 set(NO_DIRENT_H 1) 147endif() 148 149if(NOT HAVE_DLFCN_H) 150 set(NO_DLFCN_H 1) 151endif() 152 153if(NOT HAVE_ERRNO_H) 154 set(NO_ERRNO_H 1) 155endif() 156 157if(NOT HAVE_FLOAT_H) 158 set(NO_FLOAT_H 1) 159endif() 160 161if(NOT HAVE_LIMITS_H) 162 set(NO_LIMITS_H 1) 163endif() 164 165if(NOT HAVE_SYS_WAIT_H) 166 set(NO_SYS_WAIT_H 1) 167endif() 168 169if(NOT HAVE_VALUES_H) 170 set(NO_VALUES_H 1) 171endif() 172 173if(NOT HAVE_STDLIB_H) 174 set(NO_STDLIB_H 1) 175endif() 176 177if(NOT HAVE_STRING_H) 178 set(NO_STRING_H 1) 179endif() 180 181if(NOT HAVE_ROUND) 182 set(NO_HAVE_ROUND 1) 183endif() 184 185if(BUILD_STATIC_LIBS) 186 set(STATIC_BUILD 1) 187endif(BUILD_STATIC_LIBS) 188