ConfigureChecks.cmake 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. include(CheckCCompilerFlag)
  2. include(CheckCSourceCompiles)
  3. include(CheckIncludeFile)
  4. include(CheckIncludeFiles)
  5. include(CheckSymbolExists)
  6. include(TestBigEndian)
  7. check_include_file("dlfcn.h" HAVE_DLFCN_H)
  8. check_include_file("fcntl.h" HAVE_FCNTL_H)
  9. check_include_file("inttypes.h" HAVE_INTTYPES_H)
  10. check_include_file("memory.h" HAVE_MEMORY_H)
  11. check_include_file("stdint.h" HAVE_STDINT_H)
  12. check_include_file("stdlib.h" HAVE_STDLIB_H)
  13. check_include_file("strings.h" HAVE_STRINGS_H)
  14. check_include_file("string.h" HAVE_STRING_H)
  15. check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
  16. check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
  17. check_include_file("unistd.h" HAVE_UNISTD_H)
  18. check_symbol_exists("getpagesize" "unistd.h" HAVE_GETPAGESIZE)
  19. check_symbol_exists("bcopy" "strings.h" HAVE_BCOPY)
  20. check_symbol_exists("memmove" "string.h" HAVE_MEMMOVE)
  21. check_symbol_exists("mmap" "sys/mman.h" HAVE_MMAP)
  22. check_symbol_exists("getrandom" "sys/random.h" HAVE_GETRANDOM)
  23. if(USE_libbsd)
  24. set(CMAKE_REQUIRED_LIBRARIES "${LIB_BSD}")
  25. set(_bsd "bsd/")
  26. else()
  27. set(_bsd "")
  28. endif()
  29. check_symbol_exists("arc4random_buf" "${_bsd}stdlib.h" HAVE_ARC4RANDOM_BUF)
  30. if(NOT HAVE_ARC4RANDOM_BUF)
  31. check_symbol_exists("arc4random" "${_bsd}stdlib.h" HAVE_ARC4RANDOM)
  32. endif()
  33. set(CMAKE_REQUIRED_LIBRARIES)
  34. #/* Define to 1 if you have the ANSI C header files. */
  35. check_include_files("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
  36. test_big_endian(WORDS_BIGENDIAN)
  37. #/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
  38. if(WORDS_BIGENDIAN)
  39. set(BYTEORDER 4321)
  40. else(WORDS_BIGENDIAN)
  41. set(BYTEORDER 1234)
  42. endif(WORDS_BIGENDIAN)
  43. if(HAVE_SYS_TYPES_H)
  44. check_symbol_exists("off_t" "sys/types.h" OFF_T)
  45. check_symbol_exists("size_t" "sys/types.h" SIZE_T)
  46. else(HAVE_SYS_TYPES_H)
  47. set(OFF_T "long")
  48. set(SIZE_T "unsigned")
  49. endif(HAVE_SYS_TYPES_H)
  50. check_c_source_compiles("
  51. #include <stdlib.h> /* for NULL */
  52. #include <unistd.h> /* for syscall */
  53. #include <sys/syscall.h> /* for SYS_getrandom */
  54. int main() {
  55. syscall(SYS_getrandom, NULL, 0, 0);
  56. return 0;
  57. }"
  58. HAVE_SYSCALL_GETRANDOM)
  59. configure_file(expat_config.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/expat_config.h")
  60. add_definitions(-DHAVE_EXPAT_CONFIG_H)
  61. check_c_compiler_flag("-fno-strict-aliasing" FLAG_NO_STRICT_ALIASING)