1include(CheckCCompilerFlag) 2include(CheckCSourceCompiles) 3include(CheckIncludeFile) 4include(CheckIncludeFiles) 5include(CheckLibraryExists) 6include(CheckSymbolExists) 7include(TestBigEndian) 8 9check_include_file("dlfcn.h" HAVE_DLFCN_H) 10check_include_file("fcntl.h" HAVE_FCNTL_H) 11check_include_file("inttypes.h" HAVE_INTTYPES_H) 12check_include_file("memory.h" HAVE_MEMORY_H) 13check_include_file("stdint.h" HAVE_STDINT_H) 14check_include_file("stdlib.h" HAVE_STDLIB_H) 15check_include_file("strings.h" HAVE_STRINGS_H) 16check_include_file("string.h" HAVE_STRING_H) 17check_include_file("sys/stat.h" HAVE_SYS_STAT_H) 18check_include_file("sys/types.h" HAVE_SYS_TYPES_H) 19check_include_file("unistd.h" HAVE_UNISTD_H) 20 21check_symbol_exists("getpagesize" "unistd.h" HAVE_GETPAGESIZE) 22check_symbol_exists("mmap" "sys/mman.h" HAVE_MMAP) 23check_symbol_exists("getrandom" "sys/random.h" HAVE_GETRANDOM) 24 25if(EXPAT_WITH_LIBBSD) 26 set(CMAKE_REQUIRED_LIBRARIES "${LIB_BSD}") 27 set(_bsd "bsd/") 28else() 29 set(_bsd "") 30endif() 31check_symbol_exists("arc4random_buf" "${_bsd}stdlib.h" HAVE_ARC4RANDOM_BUF) 32if(NOT HAVE_ARC4RANDOM_BUF) 33 check_symbol_exists("arc4random" "${_bsd}stdlib.h" HAVE_ARC4RANDOM) 34endif() 35set(CMAKE_REQUIRED_LIBRARIES) 36 37#/* Define to 1 if you have the ANSI C header files. */ 38check_include_files("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS) 39 40test_big_endian(WORDS_BIGENDIAN) 41#/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */ 42if(WORDS_BIGENDIAN) 43 set(BYTEORDER 4321) 44else(WORDS_BIGENDIAN) 45 set(BYTEORDER 1234) 46endif(WORDS_BIGENDIAN) 47 48if(HAVE_SYS_TYPES_H) 49 check_c_source_compiles(" 50 #include <sys/types.h> 51 int main(void) { 52 const off_t offset = -123; 53 return 0; 54 }" 55 HAVE_OFF_T) 56endif() 57 58if(NOT HAVE_OFF_T) 59 set(off_t "long") 60endif() 61 62check_c_source_compiles(" 63 #define _GNU_SOURCE 64 #include <stdlib.h> /* for NULL */ 65 #include <unistd.h> /* for syscall */ 66 #include <sys/syscall.h> /* for SYS_getrandom */ 67 int main(void) { 68 syscall(SYS_getrandom, NULL, 0, 0); 69 return 0; 70 }" 71 HAVE_SYSCALL_GETRANDOM) 72 73check_c_compiler_flag("-fno-strict-aliasing" FLAG_NO_STRICT_ALIASING) 74check_c_compiler_flag("-fvisibility=hidden" FLAG_VISIBILITY) 75 76check_library_exists(m cos "" _EXPAT_LIBM_FOUND) 77